-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework SymbolizationComplete #307
Conversation
3541f2b
to
9991fa8
Compare
@@ -117,11 +117,8 @@ func newTraceHandler(rep reporter.TraceReporter, traceProcessor TraceProcessor, | |||
} | |||
|
|||
func (m *traceHandler) HandleTrace(bpfTrace *host.Trace) { | |||
defer m.traceProcessor.SymbolizationComplete(bpfTrace.KTime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplifying, SymbolizationComplete
is now called from tracer/events.go
with an introduced upper bound to the calling frequency.
pollFrequency time.Duration, perCPUBufferSize int, triggerFunc func([]byte, int), | ||
) func() (lost, noData, readError uint64) { | ||
eventReader, err := perf.NewReader(perfEventMap, perCPUBufferSize) | ||
func (t *Tracer) startTraceEventMonitor(ctx context.Context, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No point in having this be a generic function when:
- Nothing else is currently using it (other than receiving trace events)
- I'm introducing logic that's specialized to trace event handling
Instead, switching it to a Tracer
method also simplifies the interface.
This is how the logic looks now (polling loop and On a system with low CPU load
We see 4 iterations of the polling loop per second (as expected due to 250ms polling interval) and On a fully loaded system
Again we see 4 iterations of the polling loop per second, but this time |
9991fa8
to
870479d
Compare
tracer/events.go
Outdated
kt := oldKTime | ||
if minKTime > 0 && minKTime < kt { | ||
// If current minKTime is smaller than oldKTime, use it | ||
// instead of oldKTime (and set it to 0 to avoid a repeat). | ||
kt = minKTime | ||
minKTime = 0 | ||
} | ||
t.TraceProcessor().SymbolizationComplete(kt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without a kt
temp variable, the code is easier to read.
kt := oldKTime | |
if minKTime > 0 && minKTime < kt { | |
// If current minKTime is smaller than oldKTime, use it | |
// instead of oldKTime (and set it to 0 to avoid a repeat). | |
kt = minKTime | |
minKTime = 0 | |
} | |
t.TraceProcessor().SymbolizationComplete(kt) | |
if oldKTime <= minKTime { | |
t.TraceProcessor().SymbolizationComplete(oldKTime) | |
} else { | |
// If minKTime is smaller than oldKTime, use it | |
// and reset it to avoid a repeat. | |
t.TraceProcessor().SymbolizationComplete(minKTime) | |
minKTime = 0 | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard to rework this a bit as the suggested logic was incorrect when minKTime == 0
. See d12a80a.
c7a47e4
to
ad771d9
Compare
5dc9499
to
0009388
Compare
if minKTime == 0 || trace.KTime < minKTime { | ||
minKTime = trace.KTime | ||
} | ||
traceOutChan <- trace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that you moved that code here it becomes obvious that we enforce a task/context switch for every trace. Possibly not for this PR, but we should improve this (e.g. with batch processing or a buffered channel).
Update SymbolizationComplete mechanism to reflect current semantics around trace processing and timestamping (no batching, in-kernel high resolution timestamps)
Co-authored-by: Tim Rühsen <tim.ruhsen@elastic.co>
Co-authored-by: Florian Lehner <florian.lehner@elastic.co>
51f78ac
to
eded6cb
Compare
Summary
Updated
SymbolizationComplete
mechanism to reflect current semantics around trace processing and timestamping (no batching, in-kernel high resolution timestamps):SymbolizationComplete
per-Trace, instead call it after each iteration of the perf event batch-drain loop. This introduces a call frequency upper bound (currently: 4Hz).KTime
seen during trace event retrieval and report the minimumKTime
belonging to the previous processing iteration withSymbolizationComplete
.startPollingPerfEventMonitor
is now specialized to trace event processing, this also simplifies caller logic.TODO:
GenerifyWill open new PR for this.SymbolizationComplete
, fix Sending executable path for processes that have exited #278Also see: