3 ms·
I guess this is as good a time as any to make my post-PyParallel pet project public (holy alliteration Batman): https://github.com/tpn/tracer https://github.com
by trentnelson 9y ago
I guess this is as good a time as any to make my post-PyParallel pet project public (holy alliteration Batman): https://github.com/tpn/tracer https://github.com/tpn/tracer.
I started it about 2.5 years ago because I wasn't really happy with existing Python tracing tools. I didn't like:
a) the performance hit when tracing non-trivial programs,
b) the inability to say: "hey, trace all code living in modules mymodule1 and mymodule2; ignore everything else", and
c) the inability to say: "screw it, trace everything", and have an efficient means to persist tens of gigabytes worth of data (i.e. don't separate in-memory representation from on-disk representation).
So I came up with this tracing project, creatively named: tracer.
It has relatively low overhead, efficiently and optimally persists tens of gigabytes worth of data to disk with minimal overhead, and allows for module-based tracing directives so that you can capture info about your project and ignore all the other stuff (like stdlib and package code).
Like all fun pet projects, once the easy stuff was done, this one devolved into writing assembly to do remote thread injection (https://github.com/tpn/tracer/blob/master/Asm/InjectionThunk.asm#L357 https://github.com/tpn/tracer/blob/master/Asm/InjectionThunk...), coming up with new "string table" data structure as an excuse to use some AVX2 intrinsics (https://github.com/tpn/tracer/blob/master/StringTable/PrefixSearchStringTable.c https://github.com/tpn/tracer/blob/master/StringTable/Prefix...), and writing a sqlite3 virtual table interface to the flat-file memory maps, complete with CUDA kernels (https://github.com/tpn/tracer/blob/master/TraceStore/TraceStoreSqlite3ExtInit.c#L228 https://github.com/tpn/tracer/blob/master/TraceStore/TraceSt...).
Edit: something pretty fascinating I observed in the wild when running this code: a tracing-enabled Python run of a large project ran faster than a normal, non-traced version of Python in a low-memory environment (a VM with 8GB of RAM). My guess is that splaying the PyCodeObject structures each frame invocation has the very beneficial side effect of reducing the likelihood the OS swaps the underlying pages out at a later date (https://github.com/tpn/tracer/blob/master/Python/PythonFunction.c https://github.com/tpn/tracer/blob/master/Python/PythonFunct...).
- chubot 9y agoHm interesting -- what parts of it are tied to Windows? I recently strated playing with uftrace, a tracing framework for C++ using instrumented binaries. I got it working on CPython and I like it so far. The CLI seems to be well done. I haven't looked in detail your tracer (a README would help), but maybe there are some ideas that can be exchanged. This thread has a link to the repo and a video: https://www.reddit.com/r/ProgrammingLanguages/comments/7djreg/uftrace_a_function_graph_tracer_for_cc_userspace/ https://www.reddit.com/r/ProgrammingLanguages/comments/7djre...
- trentnelson 9y ago> Hm interesting -- what parts of it are tied to Windows? If I had to guess... I'd say... almost all of it? :-) I like systems programming in C on NT these days far more than Linux systems programming. Once you've gotten used to how NT does I/O and threading, it's tough to look back. Sure is lonely going against the grain, though. (Just added a README, in that I copy and pasted some notes I wrote a month or so ago into a text file. I'll add more stuff (you know, like, instructions) soon.)
- dagw 9y agoI guess this is as good a time as any to make my post-PyParallel pet project Does this mean the PyParallel is dead?