Halloween Spooktacular Day 9: What's Left?
In yesterday’s hint, I pointed everyone to Mārtiņš Možeiko's miniperf gist, an invaluable resource for getting PMC collection working via ETW. Hopefully, anyone who was stuck is now un-stuck thanks to Mārtiņš!
But unfortunately, getting PMC collection working is only half the battle. Mārtiņš gist shows how to collect PMC counters only for the full run of a single thread. To complete the challenge, this must be extended to allow the user to bracket any piece of code they want, and have PMC counts retrieved for that specific section.
This isn’t possible using only the CSwitch
event collection shown in Mārtiņš gist. Remember, as detailed on Day 1, your challenge API must support flexible rdtsc
-like usage:
pmc_traced_thread TracedThread;
StartCountingPMCs(&Tracer, &TracedThread);
// ... code to measure goes here ...
StopCountingPMCs(&Tracer, &TracedThread);
The only way to make that work using nothing but CSwitch
events would be to force Windows to task switch away and back to the user’s thread at both the StartCountingPMCs
point and the StopCountingPMCs
point. These task switches would cause massive fluctuation in the profiling results, especially if the user was trying to do something like repetition testing — a very likely use care for this kind of profiling.
That brings us to today’s hint: in order to finish the challenge, you must figure out some way to get ETW to record EVENT_RECORD
s at specific points in a program without any severe performance penalty, and these event records will need to have PMCs attached so you can difference them. Without this capability, there will be no way for a user to bracket a piece of code and get the elapsed PMCs for just that section.
That concludes today’s hint. Until tomorrow, good luck making progress on the Spooktacular Challenge!
I will post additional hints here every day until Halloween. If you’d like the rest of the Spooktacular Challenge to be delivered automatically to your inbox, you can select a subscription option here: