Skip to content

EventPipe: Fix event loss during final session flush - #137991

Merged
pavelsavara merged 1 commit into
mainfrom
pavelsavara/browser-coreclr-eventpipe-final-flush
Nov 21, 2026
Merged

pavelsavara merged 1 commit into
mainfrom
pavelsavara/browser-coreclr-eventpipe-final-flush

Conversation

@pavelsavara

Copy link
Copy Markdown
Member

Summary

EventPipe's final session drain uses the same exclusive current-timestamp cutoff as live streaming. Events sharing the final flush's clock tick can remain buffered and be discarded when the session is destroyed. Browser clock quantization makes this observable as lost events at the final sequence point.

  • Use an unbounded timestamp cutoff only for the final drain, after the session is unpublished and all in-flight writers have completed.
  • Preserve the existing exclusive timestamp boundary for live streaming and the earlier pre-rundown flush.
  • Add deterministic frozen-clock regressions for netperf v3 and nettrace v4. Both verify that live streaming excludes events at the cutoff and that shutdown serializes all ten events.

Found while investigating #134929. This PR does not remove its SDK/TFM pins or close that issue.

Validation

  • Before the fix: both new regressions failed, serializing 0/10 events at the stop timestamp.
  • After the fix: both regressions passed, serializing 10/10 events.
  • cmake --build artifacts\tests\coreclr\obj\windows.x64.Debug\Native --target NativeEventPipeTestsDriver -- passed in a Visual Studio x64 developer environment; rechecked before committing.
  • .\artifacts\tests\coreclr\obj\windows.x64.Debug\Native\native\eventpipe\NativeEventPipeTestsDriver.exe -- 92/92 passed.
  • .\build.cmd -bl -os browser -subset clr+libs+host -c Debug /p:RuntimeFlavor=CoreCLR /p:EnableHotReloadInRuntimeConfigDevFile=false -- passed, zero warnings/errors. The initial attempt hit the known WasmAppHost hot-reload static-web-assets packaging issue; the documented command-line workaround was used.
  • Manual Chrome validation with a net12 Blazor app and the locally built CoreCLR Debug runtime: verified the served native Wasm SHA256 against the built binary, exercised ten counter clicks and five Weather rows, and collected three EventPipe traces with 36,045 / 36,003 / 36,011 events and zero lost events in every trace.
  • git diff --check -- passed.

Validation limitation

The PGO-enabled browser attempt hit a separate crash in PgoManager::Header::SchemaSizeMax during LogInstrumentationData, invoked by session_stopping before the modified final-drain path runs. The successful browser trace checks therefore used DOTNET_InterpPGO=0; this PR does not claim successful end-to-end interpreter PGO collection on current main.

Note

This PR and its description were created with GitHub Copilot.

Drain all buffered events after the session is unpublished and its writers
have quiesced. Preserve the exclusive timestamp cutoff for live streaming,
but do not discard shutdown events that share the final flush's clock tick.

Add deterministic frozen-clock regressions for netperf v3 and nettrace v4.

Co-authored-by: Copilot <[email protected]>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants