Created
November 15, 2012 14:36
-
-
Save bnoordhuis/4078925 to your computer and use it in GitHub Desktop.
systemtap script that prints aggregated node.js garbage collector statistics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env stap | |
global samples | |
global all_samples | |
global timestamp | |
probe process("node").mark("gc__start") | |
{ | |
timestamp = gettimeofday_us() | |
} | |
probe process("node").mark("gc__done") | |
{ | |
sample = gettimeofday_us() - timestamp | |
samples <<< sample | |
all_samples <<< sample | |
} | |
probe timer.s(5) | |
{ | |
print(@hist_log(samples)) | |
printf("min:%d avg:%d max:%d count:%d\n", | |
@min(samples), @avg(samples), | |
@max(samples), @count(samples)) | |
delete samples | |
} | |
probe end | |
{ | |
print(@hist_log(all_samples)) | |
printf("min:%d avg:%d max:%d count:%d\n", | |
@min(all_samples), @avg(all_samples), | |
@max(all_samples), @count(all_samples)) | |
} |
That "timestamp" global should be indexed with tid(), in case multiple concurrent garbage collection events may be occurring on the machine.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is what the output looks like. Times are in microseconds.