Search code examples
rmemoryshinydata-visualizationstrace

Visualization library for disjoint intervals


I want to visualize memory mapping states of processes. For this I parsed the output of

# strace -s 256 -v -k -f -e trace=memory,process command

and now I have a time series of disjoint sums of intervals on the real line. Is there a convenient visualization library for such data? Haskell interface would be the most time-saving for me, but any suggestion is welcome. Thanks!


Solution

  • Just in case this might be useful for anyone, I hacked up a little tool to do this. (By the way I ended up using R/Shiny for interactive visualization.)

    Here's the github repo. screenshot

    It's interactive in that if you click a region, the stack traces responsible for the memory mapping will be shown like this:

    trace:
     22695 mmap(NULL, 251658240, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x2b4210000000
    /lib/x86_64-linux-gnu/libc-2.19.so(mmap64+0xa) [0xf487a]
    /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so(_ZN2os17pd_reserve_memoryEmPcm+0x31) [0x91e9c1]
    /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so(_ZN2os14reserve_memoryEmPcm+0x20) [0x91ced0]
    /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so(_ZN13ReservedSpace10initializeEmmbPcmb+0x256) [0xac20a6]
    /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so(_ZN17ReservedCodeSpaceC1Emmb+0x2c) [0xac270c]
    /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so(_ZN8CodeHeap7reserveEmmm+0xa5) [0x61a3c5]
    /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so(_ZN9CodeCache10initializeEv+0x80) [0x47ff50]
    /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so(_Z12init_globalsv+0x45) [0x63c905]
    /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so(_ZN7Threads9create_vmEP14JavaVMInitArgsPb+0x23e) [0xa719be]
    /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so(JNI_CreateJavaVM+0x74) [0x6d11c4]
    /usr/lib/jvm/java-8-oracle/lib/amd64/jli/libjli.so(JavaMain+0x9e) [0x745e]
    /lib/x86_64-linux-gnu/libpthread-2.19.so(start_thread+0xc4) [0x8184]
    /lib/x86_64-linux-gnu/libc-2.19.so(clone+0x6d) [0xfa37d]
    

    The same colors correspond to the same flags for mmap/msync/madvise etc.

    Synopsis

    $ make show-prerequisites
    # (Follow the instructions)
    
    $ make COMMAND="time ls"
    ...
    DATA_DIR=build/data-2016-12-12_02h38m13s
    Listening on http://127.0.0.1:5000
    ....
    $ firefox http://127.0.0.1:5000
    
    $ # Re-browse the previous results
    $ make DATA_DIR=build/data-2016-12-12_02h38m13s
    

    In the process of development I realized the striking geometricity of the problem. So I created a module called Sheaf and described there a recipe for defining a Grothendieck topology and a constant sheaf on it. It now seems the Grothendieck (or Lawvere-Tierney) topologies are actually ubiquitous for programming.. but I'm not sure if it will prove anything worthy. So feel free to check it!