Skip to content

Instantly share code, notes, and snippets.

@timo
Created September 12, 2019 16:01
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/c729d8899b482b2fd35cd07fc5229a21 to your computer and use it in GitHub Desktop.
Save timo/c729d8899b482b2fd35cd07fc5229a21 to your computer and use it in GitHub Desktop.
how to subscribe to speshevent and gcevent
use nqp;
my $eventqueue;
class QueueType is repr<ConcBlockingQueue> {}
constant $evq = QueueType.new;
class GCEvent is array[int64] is repr<VMArray> is array_type(int64) {
method gist {
"GCEvent:\n " ~ (<seqnum starttime vmtime duration is_major promoted promoted_ttl thread gen2roots> Z=> self.list).join("\n ");
}
}
class SpeshOverviewEvent is array[int64] is repr<VMArray> is array_type(int64) {
method gist {
"SpeshEvent:\n " ~ (<seqnum starttime vmtime wait_before thread_id statstime new_frames updated_frames plantime certain_spesh observed_spesh osr_spesh speshtime frames_with_stats totaltime> Z=> self.list).join("\n ");
}
}
nqp::vmeventsubscribe($evq<>,
nqp::hash(
'gcevent', GCEvent,
#'speshoverviewevent', SpeshOverviewEvent)
)
);
$eventqueue = $evq;
start {
loop {
my $thing = nqp::shift($eventqueue<>);
if $thing.list[4] {
say "---- ---- ---- ---- ----";
say "GC EVENT";
$thing.say;
say "---- ---- ---- ---- ----";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment