Skip to content

Reduce ETLX conversion memory with compact stack indexes - #2485

Merged
Brian Robbins (brianrob) merged 2 commits into
microsoft:mainfrom
JeremyKuhne:etlx-conversion-performance
Oct 22, 2026
Merged

Brian Robbins (brianrob) merged 2 commits into
microsoft:mainfrom
JeremyKuhne:etlx-conversion-performance

Conversation

@JeremyKuhne

@JeremyKuhne Jeremy Kuhne (JeremyKuhne) commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Replace per-caller stack-child lists with compact first-child/next-sibling arrays.

Most stack nodes have only one child. The previous representation allocated a List<T> and backing array for each caller, creating millions of small objects on large traces. The new representation eliminates those objects while preserving newest-first lookup, stack IDs, caller relationships, and thread roots.

No public API or ETLX format changes. Also correct stale XML documentation about the default event-count and file-size limits.

Impact

Measured on Windows x64 / .NET 11 using identical inputs and matched original/modified converter builds based on TraceEvent 3.2.6:

Trace Managed allocation Peak process commit Conversion time
16 GB, 61 million stack nodes -12.4% 23.9 -> 19.9 GB 350.8 -> 332.8 s
16 GB, 66 million stack nodes -13.2% 24.3 -> 19.4 GB 360.0 -> 361.3 s
80 GB, 823 million stack nodes -41.7% 87.0 -> 41.3 GB 158.9 -> 26.5 min

CPU time fell by 3.2%, 6.6%, and 84.2%, respectively.

Smaller conversions primarily benefit from reduced allocation and memory usage; wall-time improvement is not guaranteed. On the largest trace, the original converter exceeded available physical memory and paged heavily. Reducing its working set produced an approximately 6x observed speedup. A repeat optimized run completed in 26.4 minutes.

These are local measurements, not a universal speedup claim or confirmation confidence interval. GB values are decimal; process commit is not managed live memory.

Validation

  • Fresh full Debug/.NET 8 test run: 2,495 passed, 4 skipped, zero failed:
    dotnet test .\src\TraceEvent\TraceEvent.Tests\TraceEvent.Tests.csproj -c Debug -f net8.0 --logger "trx;LogFileName=TraceEventTests-pre-pr-net8-Debug.trx" --results-directory <local-results> -v quiet -nodeReuse:false
  • Four regressions cover thread roots, high fan-out, growth/interleaving against an independent identity map, and allocation behavior.
  • An unchanged packaged TraceEvent 3.2.6 reader verified identical event headers and all payload bytes, every event-to-stack association, stack nodes/thread roots, method/address mappings, and IL offsets on the known small trace and all three large inputs, including the stress repeat.
  • No reported event loss or truncation; ETLX output sizes unchanged.
  • Initial full-suite runs hit a DispatcherTests collection-modified failure also reproduced on clean baseline source. Final and fresh pre-PR reruns passed without an unrelated fix or test exclusion.

Current-main integration

CI exposed an upstream live-session TraceCallStacks.Clear() method added after the measured release tag. It is now updated to reset all compact lookup arrays, with a repeated clear/reuse regression.

  • Full current-main Debug/.NET 10 test project: 2,804 passed, 4 skipped, zero failed.
  • Release TraceEvent library build: zero warnings/errors.
  • Release compact-index regressions: 5 passed, zero failed/skipped.
  • Full native/WPF solution builds could not run locally because the required Visual Studio 2026 components are missing; CI supplies that validation.

Replace per-caller lists with first-child and next-sibling arrays while preserving stack identity and serialized output. Add interning and allocation regressions and correct stale event-limit XML documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@JeremyKuhne
Jeremy Kuhne (JeremyKuhne) requested a review from a team as a code owner October 12, 2026 18:04
Integrate current main and update TraceCallStacks.Clear to reset firstCallee, nextSibling and thread-root indexes. Add a repeated clear/reuse regression for the live-session trimming path that CI exposed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@brianrob Brian Robbins (brianrob) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Jeremy Kuhne (@JeremyKuhne) for contributing this. LGTM.

@brianrob
Brian Robbins (brianrob) merged commit b00b8e1 into microsoft:main Oct 22, 2026
5 checks passed
@JeremyKuhne
Jeremy Kuhne (JeremyKuhne) deleted the etlx-conversion-performance branch October 23, 2026 01:21
This was referenced Nov 21, 2026
Nick Moger (nubbymong) added a commit to nubbymong/poolwatch that referenced this pull request Nov 27, 2026
Updated
[Microsoft.Diagnostics.Tracing.TraceEvent](https://github.com/Microsoft/perfview)
from 4.0.0 to 4.0.2.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.Diagnostics.Tracing.TraceEvent's
releases](https://github.com/Microsoft/perfview/releases)._

## 4.0.2

## What's Changed
* Fix Capitalize in GetManifestForRegisteredProvider event names by
@​jdu2600 in microsoft/perfview#2481
* Update .NET SDK To 10.0.402 by @​brianrob in
microsoft/perfview#2494
* Fix `GetManifestForRegisteredProvider` returning wrong event details
for `EventlogClassic` events. by @​jdu2600 in
microsoft/perfview#2482
* Label GetManifestForRegisteredProvider's string table with
CurrentUICulture by @​jdu2600 in
microsoft/perfview#2488
* Reduce ETLX conversion memory with compact stack indexes by
@​JeremyKuhne in microsoft/perfview#2485
* Use bulk copying in GrowableArray.RemoveRange by @​JeremyKuhne in
microsoft/perfview#2489
* Select Processes Before Building ETL And EventPipe Stack Sources by
@​brianrob in microsoft/perfview#2496
* Fix Unsigned Integer Decoding In TDH Payloads by @​brianrob in
microsoft/perfview#2495
* Honor StopProcessing in EventPipeEventSource by @​pcshrosbree in
microsoft/perfview#2497
* Validate Scenario Export Output File Names by @​brianrob in
microsoft/perfview#2504
* Skip Predefined Template Lookups For Unrelated EventPipe Providers by
@​brianrob in microsoft/perfview#2503
* Avoid Allocating Predefined Dynamic Parser Lookup Keys by @​brianrob
in microsoft/perfview#2502
* Increase File-Backed Serialization Buffer To Reduce ETLX Write
Overhead by @​brianrob in
microsoft/perfview#2505
* Fix Hidden PDB Trust Dialog After Switching Applications by @​brianrob
in microsoft/perfview#2507
* Fix reserved keyword threshold in GetManifestForRegisteredProvider by
@​jdu2600 in microsoft/perfview#2509
* Validate Event Payload Fields, Strings, Arrays, And Related-Activity
GUIDs
* Validate BPerf Session Headers, Compressed Blocks, And Decompression
Bounds
* Require Complete CTF Reads And Validate Array Sizes And Payload
Lengths
* Bound Captured Packet Headers And TCP Options While Preserving Non-IP
And Fragment Handling
* Validate PE Cache Ranges And Require Complete Pointer Reads
* Decode Kernel TCP Connection IDs And Sequence Numbers According To
Event Version

## New Contributors
* @​jdu2600 made their first contribution in
microsoft/perfview#2481
* @​pcshrosbree made their first contribution in
microsoft/perfview#2497

**Full Changelog**:
microsoft/perfview@v4.0.0...v4.0.2


Commits viewable in [compare
view](microsoft/perfview@v4.0.0...v4.0.2).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Microsoft.Diagnostics.Tracing.TraceEvent&package-manager=nuget&previous-version=4.0.0&new-version=4.0.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: nubbymong <192402368+nubbymong@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants