Add PMU performance counters to LTTng execution events table - #139
Open
Hani Nemati (Nemati) wants to merge 1 commit into
Open
Hani Nemati (Nemati) wants to merge 1 commit into
Hani Nemati (Nemati) wants to merge 1 commit into
Conversation
Ports the performance counter support from 560cd2f onto develop: - Capture integer perf context fields on each sched_switch - Compute per-execution-event counter deltas between switch-in and switch-out - Add Instruction Count, LLC Misses, CPU Cycle and Cache Misses columns Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new columns are hidden from every table configuration, and the PMU calculation path lacks coverage.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Adds per-thread PMU counter deltas to LTTng execution events and exposes them in the Execution Events table.
Changes:
- Captures perf context values during context switches.
- Computes counter deltas across execution intervals.
- Registers four PMU counter columns.
| File | Description |
|---|---|
ExecutionEventTable.cs |
Registers PMU counter columns. |
LTTngThreadDataCooker.cs |
Associates switch-in and switch-out contexts. |
ExecutionEvent.cs |
Computes and exposes counter deltas. |
ContextSwitch.cs |
Captures perf context fields. |
IExecutionEvent.cs |
Adds the counter-delta output contract. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+294
to
+297
| table.AddColumn(instructionCountColumn, Projection.CreateUsingFuncAdaptor((i) => GetPerformanceCounterDiff(threads[i], "_perf_cpu_instructions"))); | ||
| table.AddColumn(lastLevelCacheMissesColumn, Projection.CreateUsingFuncAdaptor((i) => GetPerformanceCounterDiff(threads[i], "_perf_cpu_LLC_load_misses"))); | ||
| table.AddColumn(cpuCycleColumn, Projection.CreateUsingFuncAdaptor((i) => GetPerformanceCounterDiff(threads[i], "_perf_cpu_cpu_cycles"))); | ||
| table.AddColumn(cacheMissesColumn, Projection.CreateUsingFuncAdaptor((i) => GetPerformanceCounterDiff(threads[i], "_perf_cpu_cache_misses"))); |
Comment on lines
+61
to
+63
| if (switchOutContextSwitch.PerformanceCountersByName.TryGetValue(counter.Key, out long switchOutValue)) | ||
| { | ||
| this.performanceCountersDiffByName[counter.Key] = switchOutValue - counter.Value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Adds per-thread CPU performance counter (PMU) deltas to the LTTng Execution Events table.
When a kernel trace is recorded with perf counter contexts (
lttng add-context -k -t perf:cpu:...), eachsched_switchcarries the current counter values. This change:perfcontext fields on each context switch (ContextSwitch)ExecutionEvent.PerformanceCountersDiffByName, exposed onIExecutionEvent)Existing behavior is unchanged for traces without counters: the thread state/timing columns are computed exactly as before, and missed context switches produce zero-length events with no counter deltas.
Record with, e.g.:
Testing:
LTTngDataExtensionsbuilds; allLTTngDataExtUnitTesttests pass.