dynamorio icon indicating copy to clipboard operation
dynamorio copied to clipboard

Add drmemtrace schedule analysis tool

Open derekbruening opened this issue 1 year ago • 0 comments

#5843 covered creating a drmemtrace scheduler supporting a variety of schedules.

#5694 hooked the scheduler up to the analysis tool framework.

This issue covers creating an analysis tool that computes statistics about a schedule and provides some rough visualization of the interleavings. The sched_launcher tool was a step in that direction, but an analysis tool is a better solution as it more easily fits into and combines with other tools and existing framework adaptations.

Here is my prototype, where I cranked up the quantum so we have no preempts as a test to see 100% voluntary switches (this counts a thread exit as a voluntary switch):

$ bin64/drrun -t drcachesim -simulator_type schedule_stats -indir ../src/clients/drcachesim/tests/drmemtrace.threadsig.x64.tracedir/ -core_sharded -print_every 5000 -sched_quantum 1000000
Schedule stats tool results:
Total counts:
           4 cores
           8 threads
      638938 instructions
           5 total context switches
   0.0000078 CSPKI (context switches per 1000 instructions)
           5 voluntary context switches
           0 direct context switches
      100.00% voluntary switches
        0.00% direct switches
         161 system calls
           2 maybe-blocking system calls
           0 direct switch requests
Core #0 counts:
           2 threads
      117015 instructions
           2 total context switches
   0.0000171 CSPKI (context switches per 1000 instructions)
           2 voluntary context switches
           0 direct context switches
      100.00% voluntary switches
        0.00% direct switches
         125 system calls
           2 maybe-blocking system calls
           0 direct switch requests
Core #1 counts:
           2 threads
      170399 instructions
           1 total context switches
   0.0000059 CSPKI (context switches per 1000 instructions)
           1 voluntary context switches
           0 direct context switches
      100.00% voluntary switches
        0.00% direct switches
          10 system calls
           0 maybe-blocking system calls
           0 direct switch requests
Core #2 counts:
           2 threads
      175759 instructions
           1 total context switches
   0.0000057 CSPKI (context switches per 1000 instructions)
           1 voluntary context switches
           0 direct context switches
      100.00% voluntary switches
        0.00% direct switches
          13 system calls
           0 maybe-blocking system calls
           0 direct switch requests
Core #3 counts:
           2 threads
      175765 instructions
           1 total context switches
   0.0000057 CSPKI (context switches per 1000 instructions)
           1 voluntary context switches
           0 direct context switches
      100.00% voluntary switches
        0.00% direct switches
          13 system calls
           0 maybe-blocking system calls
           0 direct switch requests
Core #0 schedule: FFFFFF,HHHHHHHHHHHHHHHHHHH,FFF
Core #1 schedule: DDDDDDDDDDDDDDDDDD,CCCCCCCCCCCCCCCCCCC
Core #2 schedule: GGGGGGGGGGGGGGGGGGG,EEEEEEEEEEEEEEEEEEE
Core #3 schedule: BBBBBBBBBBBBBBBBBBB,AAAAAAAAAAAAAAAAAAA

derekbruening avatar Nov 09 '23 02:11 derekbruening