Skip to content

Draft: Add requestTickyCounterSamples to GHC.Profiling

Luite Stegeman requested to merge luite/ghc:reqticky into master

This adds requestTickyCounterSamples :: IO () to GHC.Profiling to write the current values of the ticky counters to the eventlog (and reset the counters).

I found this useful in combination eventlog trace markers with for profiling a program that repeatedly executes a pipeline with multiple stages (while not doing much in background threads at the same time):

requestTickyCounterSamples
traceMarkerIO "stage1_start"
-- stage 1 here
requestTickyCounterSamples
traceMarkerIO "stage2_start"
-- stage 2 here
requestTickyCounterSamples
traceMarkerIO "stage3_start"
-- stage 3 here
requestTickyCounterSamples
traceMarkerIO "pipeline_end"

A simple ghc-events based program can then group or filter the counts by pipeline stage(s).

Draft notes: At the moment this directly writes by calling the existing eventlog output functions. Do we need any locking or memory barriers?

Merge request reports