Skip to content

Instantly share code, notes, and snippets.

@timo
Last active April 16, 2019 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timo/802d9d04b3ca8819fc4b48cffd564e2c to your computer and use it in GitHub Desktop.
Save timo/802d9d04b3ca8819fc4b48cffd564e2c to your computer and use it in GitHub Desktop.
snapper gives negative wallclock numbers for some reason
perl6 -e 'use Telemetry; snapper; snap "start"; my @fib-one = 1, 1, *+* ... * > 100_000; snap "fib 1 done"; my @fib-two = 1, 1, * + * ... * > 10_000; snap "fib2 done";'
Telemetry Report of Process #32508 (2019-04-16T17:37:40Z)
Number of Snapshots: 5
Initial/Final Size: 93472 / 98524 Kbytes
Total Time: 0.02 seconds
Total CPU Usage: 0.04 seconds
No supervisor thread has been running
wallclock util% max-rss
#-- start ----------------------------------------------------------------------
-21 58.33
#-- fib 1 done -----------------------------------------------------------------
19829 37.88 4972
#-- fib2 done ------------------------------------------------------------------
2492 54.58 80
176 25.14
--------- ------ --------
22476 39.61 5052
Legend:
wallclock Number of microseconds elapsed
util% Percentage of CPU utilization (0..100%)
max-rss Maximum resident set size (in Kbytes)
diff --git a/lib/Telemetry.pm6 b/lib/Telemetry.pm6
index 29ce75258..dde8fbb42 100644
--- a/lib/Telemetry.pm6
+++ b/lib/Telemetry.pm6
@@ -708,6 +708,16 @@ multi sub snap(Str:D $message --> Nil) {
T.message = $message;
$snaps.push(T);
}
+my int $snapshot-idx = 1;
+multi sub snap(:$heap! --> Nil) {
+ my str $filename = "heapsnapshot{$*PID}-{$snapshot-idx++}.mvmheap";
+ dd $filename;
+ nqp::mvmstartprofile(nqp::hash("kind", "heap", "filename", $filename));
+ nqp::mvmendprofile();
+ my \T := Telemetry.new;
+ T.message = $filename;
+ $snaps.push(T);
+}
multi sub snap(@s --> Nil) {
@s.push(Telemetry.new);
}
perl6-m -Ilib -e 'use Telemetry; snapper; snap :heap; my @fib-one = 1, 1, *+* ... * > 100_000; snap :heap; my @fib-two = 1, 1, * + * ... * > 10_000; snap :heap;'
Telemetry Report of Process #11539 (2019-04-16T18:07:04Z)
Number of Snapshots: 11
Initial/Final Size: 106712 / 211948 Kbytes
Total Time: 9.10 seconds
Total CPU Usage: 8.52 seconds
No supervisor thread has been running
wallclock util% max-rss
#-- taking heap snapshot... ----------------------------------------------------
-3 641.67
3148651 24.95 84612
#-- heapsnapshot11539-1.mvmheap ------------------------------------------------
995 71.23
#-- taking heap snapshot... ----------------------------------------------------
4085 49.37
3248800 20.51 4080
#-- heapsnapshot11539-2.mvmheap ------------------------------------------------
965 63.03
#-- taking heap snapshot... ----------------------------------------------------
2564 54.06
2692593 24.94 16544
#-- heapsnapshot11539-3.mvmheap ------------------------------------------------
797 66.12
245 25.10
--------- ------ --------
9099692 23.39 105236
Legend:
wallclock Number of microseconds elapsed
util% Percentage of CPU utilization (0..100%)
max-rss Maximum resident set size (in Kbytes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment