#agent #linux #java #interact #fs #tasks

resctrl

一个简单的代理,用于与 Linux resctrl 交互

1 个不稳定版本

0.1.0 2023年10月6日

#76 in #agent

MIT 许可证

15KB

resctrl 代理

这是一个用于将 JVM 放入 COS (服务类别) 的包装共享库,使用 Linux resctrl 接口。共享库由两个环境变量控制,即 RESCTRL_COSRESCTRL_SCHEMATA;

库将在 /sys/fs/resctrl/$RESCTRL_COS 下运行。如果当前进程是 java (即,argv[0]java 结尾),则 PID 将写入 /sys/fs/resctrl/$RESCTRL_COS/tasks,所有子线程将自动添加到 COS 中。否则,代理将不执行任何操作。

如果您设置了 RESCTRL_SCHEMATA,则内容将写入 /sys/fs/resctrl/$RESCTRL_COS/schemata。否则,将保留当前方案。

当进程退出时,如果代理处于活动状态(即,与 JVM 运行),则将清除 /sys/fs/resctrl/$RESCTRL_COS/tasks 中的内容。

您需要确保当前用户是 /sys/fs/resctrl/$RESCTRL_COS/tasks/sys/fs/resctrl/$RESCTRL_COS/schemata 的所有者,以便可以写入这些文件。

示例

设置

sudo mount -t resctrl resctrl /sys/fs/resctrl
cd /sys/fs/resctrl
sudo mkdir dacapo_cos
cd dacapo_cos
sudo chown zixianc:zixianc tasks
sudo chown zixianc:zixianc schemata

构建

cargo build --release

运行程序

$ RESCTRL_COS="dacapo_cos" RESCTRL_SCHEMATA="L3:0=0000;1=0000" LD_PRELOAD=$PWD/target/release/libresctrl.so perf stat /usr/lib/jvm/temurin-
17-jdk-amd64/bin/java -jar /usr/share/benchmarks/dacapo/dacapo-23.9-RC3-chopin.jar h2 -n 3
Operating on COS dacapo_cos
Setting schemata to L3:0=0000;1=0000
Setting tasks to 1258882
Hello 1258882, schemata     MB:0=2048;1=2048
    L3:0=0000;1=0000
, tasks 1258882

Using scaled threading model. 32 processors detected, 32 threads used to drive the workload, in a possible range of [1,1024]
Version: h2 2.2.220 derby 10.15.2.0 (use -p to print nominal benchmark stats)
Preparing the H2 database...
TPCC configuration: scale: 16, terminals: 32, transactions: 100000
===== DaCapo 23.9-RC3-chopin h2 starting warmup 1 =====
Starting 100000 requests...
100%
Completed requests
        Stock level .............   3973 ( 4.0%)
        Order status by name ....   2361 ( 2.4%)
        Order status by ID ......   1609 ( 1.6%)
        Payment by name .........  25847 (25.8%)
        Payment by ID ...........  17220 (17.2%)
        Delivery schedule .......   4029 ( 4.0%)
        New order ...............  44509 (44.5%)
        New order rollback ......    452 ( 0.5%)
===== DaCapo 23.9-RC3-chopin h2 completed warmup 1 in 6878 msec =====
===== DaCapo simple tail latency: 50% 602 usec, 90% 5951 usec, 99% 18979 usec, 99.9% 35013 usec, 99.99% 55585 usec, max 89408 usec, measured over 100000 events =====
===== DaCapo metered tail latency: 50% 792915 usec, 90% 1039091 usec, 99% 1049864 usec, 99.9% 1058446 usec, 99.99% 1067496 usec, max 1085802 usec, measured over 100000 events =====
===== DaCapo 23.9-RC3-chopin h2 starting warmup 2 =====
Starting 100000 requests...
100%
Completed requests
        Stock level .............   3973 ( 4.0%)
        Order status by name ....   2361 ( 2.4%)
        Order status by ID ......   1609 ( 1.6%)
        Payment by name .........  25847 (25.8%)
        Payment by ID ...........  17220 (17.2%)
        Delivery schedule .......   4029 ( 4.0%)
        New order ...............  44509 (44.5%)
        New order rollback ......    452 ( 0.5%)
===== DaCapo 23.9-RC3-chopin h2 completed warmup 2 in 4718 msec =====
===== DaCapo simple tail latency: 50% 417 usec, 90% 3939 usec, 99% 13867 usec, 99.9% 25405 usec, 99.99% 35936 usec, max 48642 usec, measured over 100000 events =====
===== DaCapo metered tail latency: 50% 106652 usec, 90% 207804 usec, 99% 238194 usec, 99.9% 244516 usec, 99.99% 254887 usec, max 266923 usec, measured over 100000 events =====
===== DaCapo 23.9-RC3-chopin h2 starting =====
Starting 100000 requests...
100%
Completed requests
        Stock level .............   3973 ( 4.0%)
        Order status by name ....   2361 ( 2.4%)
        Order status by ID ......   1609 ( 1.6%)
        Payment by name .........  25847 (25.8%)
        Payment by ID ...........  17220 (17.2%)
        Delivery schedule .......   4029 ( 4.0%)
        New order ...............  44509 (44.5%)
        New order rollback ......    452 ( 0.5%)
===== DaCapo 23.9-RC3-chopin h2 PASSED in 4509 msec =====
===== DaCapo simple tail latency: 50% 382 usec, 90% 3622 usec, 99% 13813 usec, 99.9% 24198 usec, 99.99% 34614 usec, max 47028 usec, measured over 100000 events =====
===== DaCapo metered tail latency: 50% 665 usec, 90% 14654 usec, 99% 25503 usec, 99.9% 34197 usec, 99.99% 44125 usec, max 59935 usec, measured over 100000 events =====
Operating on COS dacapo_cos
Clearing tasks

 Performance counter stats for '/usr/lib/jvm/temurin-17-jdk-amd64/bin/java -jar /usr/share/benchmarks/dacapo/dacapo-23.9-RC3-chopin.jar h2 -n 3':

        379,003.50 msec task-clock                       #   13.186 CPUs utilized             
           150,277      context-switches                 #  396.506 /sec                      
            23,173      cpu-migrations                   #   61.142 /sec                      
         2,180,511      page-faults                      #    5.753 K/sec                     
 1,276,062,771,368      cycles                           #    3.367 GHz                         (83.29%)
     4,364,759,840      stalled-cycles-frontend          #    0.34% frontend cycles idle        (83.33%)
    82,311,638,243      stalled-cycles-backend           #    6.45% backend cycles idle         (83.39%)
   847,207,831,918      instructions                     #    0.66  insn per cycle            
                                                  #    0.10  stalled cycles per insn     (83.40%)
   162,966,950,783      branches                         #  429.988 M/sec                       (83.34%)
     2,309,449,633      branch-misses                    #    1.42% of all branches             (83.29%)

      28.742477886 seconds time elapsed

     368.652118000 seconds user
      10.141901000 seconds sys
$ RESCTRL_COS="dacapo_cos" RESCTRL_SCHEMATA="L3:0=ffff;1=ffff" LD_PRELOAD=$PWD/target/release/libresctrl.so perf stat /usr/lib/jvm/temurin-
17-jdk-amd64/bin/java -jar /usr/share/benchmarks/dacapo/dacapo-23.9-RC3-chopin.jar h2 -n 3
Operating on COS dacapo_cos
Setting schemata to L3:0=ffff;1=ffff
Setting tasks to 1259428
Hello 1259428, schemata     MB:0=2048;1=2048
    L3:0=ffff;1=ffff
, tasks 1259428

Using scaled threading model. 32 processors detected, 32 threads used to drive the workload, in a possible range of [1,1024]
Version: h2 2.2.220 derby 10.15.2.0 (use -p to print nominal benchmark stats)
Preparing the H2 database...
TPCC configuration: scale: 16, terminals: 32, transactions: 100000
===== DaCapo 23.9-RC3-chopin h2 starting warmup 1 =====
Starting 100000 requests...
100%
Completed requests
        Stock level .............   3973 ( 4.0%)
        Order status by name ....   2361 ( 2.4%)
        Order status by ID ......   1609 ( 1.6%)
        Payment by name .........  25847 (25.8%)
        Payment by ID ...........  17220 (17.2%)
        Delivery schedule .......   4029 ( 4.0%)
        New order ...............  44509 (44.5%)
        New order rollback ......    452 ( 0.5%)
===== DaCapo 23.9-RC3-chopin h2 completed warmup 1 in 3585 msec =====
===== DaCapo simple tail latency: 50% 322 usec, 90% 3050 usec, 99% 10479 usec, 99.9% 21308 usec, 99.99% 30042 usec, max 54112 usec, measured over 100000 events =====
===== DaCapo metered tail latency: 50% 367590 usec, 90% 571691 usec, 99% 612931 usec, 99.9% 617580 usec, 99.99% 622906 usec, max 627753 usec, measured over 100000 events =====
===== DaCapo 23.9-RC3-chopin h2 starting warmup 2 =====
Starting 100000 requests...
100%
Completed requests
        Stock level .............   3973 ( 4.0%)
        Order status by name ....   2361 ( 2.4%)
        Order status by ID ......   1609 ( 1.6%)
        Payment by name .........  25847 (25.8%)
        Payment by ID ...........  17220 (17.2%)
        Delivery schedule .......   4029 ( 4.0%)
        New order ...............  44509 (44.5%)
        New order rollback ......    452 ( 0.5%)
===== DaCapo 23.9-RC3-chopin h2 completed warmup 2 in 2788 msec =====
===== DaCapo simple tail latency: 50% 251 usec, 90% 1939 usec, 99% 9236 usec, 99.9% 19570 usec, 99.99% 27703 usec, max 38695 usec, measured over 100000 events =====
===== DaCapo metered tail latency: 50% 9810 usec, 90% 35904 usec, 99% 44756 usec, 99.9% 50006 usec, 99.99% 56204 usec, max 64875 usec, measured over 100000 events =====
===== DaCapo 23.9-RC3-chopin h2 starting =====
Starting 100000 requests...
100%
Completed requests
        Stock level .............   3973 ( 4.0%)
        Order status by name ....   2361 ( 2.4%)
        Order status by ID ......   1609 ( 1.6%)
        Payment by name .........  25847 (25.8%)
        Payment by ID ...........  17220 (17.2%)
        Delivery schedule .......   4029 ( 4.0%)
        New order ...............  44509 (44.5%)
        New order rollback ......    452 ( 0.5%)
===== DaCapo 23.9-RC3-chopin h2 PASSED in 2788 msec =====
===== DaCapo simple tail latency: 50% 243 usec, 90% 1921 usec, 99% 9175 usec, 99.9% 19241 usec, 99.99% 29108 usec, max 34147 usec, measured over 100000 events =====
===== DaCapo metered tail latency: 50% 260 usec, 90% 2070 usec, 99% 9198 usec, 99.9% 19260 usec, 99.99% 29108 usec, max 34147 usec, measured over 100000 events =====
Operating on COS dacapo_cos
Clearing tasks

 Performance counter stats for '/usr/lib/jvm/temurin-17-jdk-amd64/bin/java -jar /usr/share/benchmarks/dacapo/dacapo-23.9-RC3-chopin.jar h2 -n 3':

        210,033.51 msec task-clock                       #   10.480 CPUs utilized             
           129,766      context-switches                 #  617.835 /sec                      
            17,137      cpu-migrations                   #   81.592 /sec                      
         2,693,834      page-faults                      #   12.826 K/sec                     
   708,207,359,243      cycles                           #    3.372 GHz                         (83.30%)
     3,712,326,657      stalled-cycles-frontend          #    0.52% frontend cycles idle        (83.37%)
    42,684,433,254      stalled-cycles-backend           #    6.03% backend cycles idle         (83.31%)
   834,079,372,035      instructions                     #    1.18  insn per cycle            
                                                  #    0.05  stalled cycles per insn     (83.50%)
   161,719,077,903      branches                         #  769.968 M/sec                       (83.27%)
     2,160,291,673      branch-misses                    #    1.34% of all branches             (83.30%)

      20.041644681 seconds time elapsed

     203.553157000 seconds user
       6.357287000 seconds sys

依赖项

~290–790KB
~19K SLoC