████████╗ ███╗ ███╗ ████████╗
╚══██╔══╝ ████╗ ████║ ╚══██╔══╝
██║ ██╔████╔██║ ██║
██║ ██║╚██╔╝██║ ██║
██║ ██║ ╚═╝ ██║ ██║
╚═╝ ╚═╝ ╚═╝ ╚═╝
T h r e a d M o n i t o r i n g T o o l
TMT is a lightweight C++ tool that leverages eBPF to trace and analyze how many threads a target application creates and uses during its execution.
It captures scheduling and process events directly from the kernel and exports structured data for post-processing and visualization.
Make sure you have:
- Linux kernel with eBPF support
clanglibbpfdevelopment filescmake- (optional, for plots)
gnuplot
To build the logger:
cmake -S . -B build
cmake --build buildThis will produce the tmt_logger binary under:
build/bin/tmt_logger
and all compiled eBPF programs under:
build/bin/*.bpf.o
To monitor an application with TMT, run:
sudo build/bin/tmt_logger --cmd "<command to trace>" [--print-raw]sudo build/bin/tmt_logger --cmd "sleep 1"
sudo build/bin/tmt_logger --cmd "python3 thread_test.py" --print-raw--cmd "<program>"— command to execute and trace (required)--print-raw— print raw kernel events as they are received
By default, TMT will generate several files under the out/ directory in the project root:
out/alive_series.csv— timeline of active threads per processout/oncpu_slices.csv— CPU scheduling slices
On the terminal, you will also see a "Top runtime per CPU" summary.
TMT can generate ready-to-use plots using gnuplot (if available).
gnuplotinstalled and visible inPATH- CMake option
TMT_ENABLE_PLOTSenabled (ON by default)
If you want to be explicit:
cmake -S . -B build -DTMT_ENABLE_PLOTS=ON
cmake --build buildAfter you have run tmt_logger at least once (so that out/alive_series.csv and out/oncpu_slices.csv exist), you can generate the plots via CMake custom targets.
From the build directory:
cmake --build build --target plot_threads_over_timeThis will run gnuplot with the script under plots/threads_over_time.gp and produce:
out/threads_over_time.png— visual summary of:- thread activity over time (alive threads)
- CPU scheduling slices aggregated over the timeline
To generate all available plots:
cmake --build build --target plots_allIf gnuplot is not installed, the plots_all target will simply print a message reminding you to install it and reconfigure.
-
Configure & build
cmake -S . -B build -DTMT_ENABLE_PLOTS=ON cmake --build build -
Run a trace
sudo build/bin/tmt_logger --cmd "python3 thread_test.py" -
Generate plots
cmake --build build --target plots_all
Then open
out/threads_over_time.pngwith your favorite image viewer.
TMT was originally developed by
Stefano Monaldi
and is now maintained by
Marco Edoardo Santimaria,
Robert Birke and
Cosmin Stoica.