Skip to content

Improve jit-analyze performance and memory usage - #441

Open
MihaZupan wants to merge 18 commits into
dotnet:mainfrom
MihaZupan:perf
Open

Improve jit-analyze performance and memory usage#441
MihaZupan wants to merge 18 commits into
dotnet:mainfrom
MihaZupan:perf

Conversation

@MihaZupan

@MihaZupan MihaZupan commented Sep 5, 2026

Copy link
Copy Markdown
Member

Reduce allocations and repeated work, reuse analysis for identical inputs, and parallelize independent comparisons.

Also fix the text-only summary: diff counts were stored under absolute paths but looked up using relative filenames, causing files with textual changes but unchanged aggregate metrics to be omitted. The benchmark input contains 106 such files, which are now reported.

Performance

Using the artifacts from MihuBot/runtime-utils#2148—760 assemblies per side, totaling 25.5 GB of disassembly:

Before After
Wall time 229.39 s 15.02 s
Peak RSS 13.30 GiB 1.24 GiB

Approximately 15× faster with 91% lower peak RSS.

Measurements are medians of three runs on a 16-logical-processor Linux machine using a Release build with .NET 10, with textual comparisons enabled.

Incremental improvements

Commit Change Wall time Reduction
27ea778 Materialize comparisons instead of repeatedly evaluating deferred queries 177.20 s 52.19 s
b973865 Parse and compare file pairs in parallel 132.67 s 44.53 s
bc47d72 Scan disassembly without allocating strings for instruction lines 111.59 s 21.08 s
bcb13f8 Aggregate metrics while parsing, using generated regexes 104.14 s 7.45 s
c882924 Store metric values compactly and eliminate unnecessary copies 71.34 s 32.80 s
bb910ad Parallelize textual comparisons and bypass Git for identical files 41.65 s 29.69 s
a816f75 Reuse parsed methods for identical file pairs 32.74 s 8.91 s
e80f9a4 Compute detailed text counts only for files eligible for the text-only report 15.16 s 17.58 s

These are historical single-run measurements of successive optimization snapshots, starting at 229.39 s. Reductions are relative to the preceding measured snapshot. The final medians above include subsequent simplifications, including removal of the redundant pre-Git equality scan.

(copilot generated description)

MihaZupan and others added 18 commits September 4, 2026 23:02
…ggregate

Cache the join, unique-method lists and filtered deltas. Add dependency-free parser and CLI regression coverage, including optional baseline comparison.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Enumerate paths without parsing, then parse and compare each pair for all requested metrics before releasing unchanged method data. Preserve result order while bounding concurrent work.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Avoid allocating strings and LINQ records for instruction lines that contain no metrics. Preserve StreamReader encoding and newline handling, including long records split across buffers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use shared generated regexes and span captures, and accumulate directly into per-name method records instead of retaining and repeatedly traversing groups of line records.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep doubles in a single array per collection rather than allocating a polymorphic object per metric. Materialize metric display objects only for reports and reuse parsed values when forming deltas.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bound git workers, compare equal-size inputs with pooled buffers, cache text counts across metrics, pass paths without shell quoting, and surface git failures. Match absolute count keys when reporting text-only changes, fixing the previously missing section.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Recognize byte-identical inputs before parsing the second side, and avoid building joins or method deltas for them. Preserve absent-metric relative delta semantics.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Walk matched directories without following directory links, include dangling links, and cover link cycles and quoted paths. Compare JSON and Markdown against the original analyzer as well as stdout and TSV.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Record the issue 2148 artifact workload, seven incremental optimizations, repeated end-to-end timings, peak RSS, and benchmark commands and caveats.

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

Use git diff --quiet for other files while preserving their contribution to the changed-file count. Avoid unused numstat work, including streaming object hashes for very large files, and retain full counts for callers of DiffInText.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Record per-file profiling, three complete workload timings, and the reduced peak RSS.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6ce50c2b-b096-4210-9633-948434c43ee4
Remove the application-specific eight-worker cap from both phases. Record fresh interleaved full-workload benchmarks: capped median 13.93s and 0.86 GiB peak RSS, default median 14.34s and 1.12 GiB.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6ce50c2b-b096-4210-9633-948434c43ee4
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6ce50c2b-b096-4210-9633-948434c43ee4
Replace the pooled buffer with a 32K-character array and grow it with Array.Resize for long lines. Remove pool cleanup and update the reader documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6ce50c2b-b096-4210-9633-948434c43ee4
Add a ProcessStartInfo overload so ArgumentList preserves literal paths, while retaining the existing overload's pre-quoted argument behavior. Share output capture and process disposal instead of duplicating them in jit-analyze.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6ce50c2b-b096-4210-9633-948434c43ee4
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6ce50c2b-b096-4210-9633-948434c43ee4
Retain equality detection for sharing parsed methods, but let Git check text pairs directly. Update the description of the text-analysis pipeline.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6ce50c2b-b096-4210-9633-948434c43ee4
Keep the cumulative changes focused on the analyzer optimizations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6ce50c2b-b096-4210-9633-948434c43ee4
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.

1 participant