gcstats: GC Statistics for Racket
The gcstats package provides GC (garbage collection) statistics for Racket programs, similar to GHC’s +RTS -s option.
1 Usage
To collect GC statistics for a Racket program, use:
racket -l gcstats <normal-racket-arguments>
For example:
racket -l gcstats -t "foo.rkt"
or
racket -l gcstats -l drracket
When the program exits, gcstats prints a summary of GC activity to standard output.
2 Example Output
2,715,625,408 bytes allocated in the heap |
2,687,494,428 bytes collected by GC |
73,728,640 bytes max heap size |
66,748,764 bytes max slop |
85,884,928 bytes peak total memory use |
|
Generation 0: 147 collections, 1,120ms, 1,157.53ms elapsed |
Generation 1: 6 collections, 596ms, 605.63ms elapsed |
|
INIT time 260 ms |
MUT time 8,996 ms ( 9,038.51 ms elapsed) |
GC time 1,716 ms ( 1,763.16 ms elapsed) |
TOTAL time 10,972 ms ( 11,061.67 ms elapsed) |
|
Max pause time: 123 ms |
%GC time 16.02 % ( 16.32 % elapsed) |
|
Alloc rate 301,870,321 bytes per MUT second |
3 Output Explanation
3.1 Memory Statistics
bytes allocated in the heap —
Total bytes allocated by the program. bytes collected by GC —
Total bytes reclaimed during garbage collection. bytes max heap size —
Largest heap size observed at any GC. bytes max slop —
Largest difference between memory allocated and memory the GC has reserved. bytes peak total memory use —
Largest total memory use, including GC overhead.
3.2 Collection Statistics
Generation 0 —
Nursery (minor) collections: count and time in both process and elapsed time. Generation 1 —
Major collections: count and time in both process and elapsed time. Incremental —
Incremental collections (if any): count and time. This line only appears if incremental collections occurred.
3.3 Time Statistics
INIT time —
Time spent before logging started, primarily Racket startup and code loading. MUT time —
Time the “mutator” (your program) was running, excluding GC. GC time —
Total time spent in garbage collection. TOTAL time —
Total time from initial invocation. Max pause time —
Longest individual GC pause. %GC time —
Percentage of time (after initialization) spent in GC. Alloc rate —
Average allocation rate in bytes per second of mutator time.