Skip to content

Speed up compile-time stunt generation - #287

Merged
kzu merged 2 commits into
mainfrom
perf/filter-generic-invocations
Oct 8, 2026
Merged

kzu merged 2 commits into
mainfrom
perf/filter-generic-invocations

Conversation

@kzu

@kzu kzu commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Static spends its generator time binding each stunt against the user compilation, formatting with NormalizeWhitespace, and rebinding constructors for registration. Metadata bases now bind on a treeless compilation, syntax-only processors skip that compilation update, top-level stunts register from symbols already in hand, and generation plus text emit run in parallel.
  • Explicit generic calls such as Select<T> still skip binding when the method name cannot be a generator. That does not change Static, where almost every call is Stunt.Of<T>.

Static benchmark

src/Acceptance/Static/Static.csproj (6,146 generated stunts from about 7,157 Stunt.Of<T>() calls), Release, direct csc /reportanalyzer. DynamicStunts is the same command with Stunts.CompiledProxy.dll removed.

StuntGenerator csc wall
Before 81.716 s
After 13.349 s 67.9 s
DynamicStunts (no compile-time stunts) 5.3 s

The generator is about 6x faster. The remaining gap versus DynamicStunts is compiling and analyzing those 6,146 generated types, which dynamic mode does not emit. Set STUNTS_PROFILE to a file path to write a per-phase breakdown; it stays off otherwise.

Test plan

  • StuntGeneratorTests (48) and StuntScaffoldTests.EnsureScaffold
  • Static csc /reportanalyzer exits 0, numbers above
  • Same Static command without the compiled-proxy generator, 5.3 s

kzu added 2 commits October 8, 2026 15:19
Explicit type arguments no longer force a semantic bind. The call is bound only when its method name is a known generator, same as inferred calls.
Binding every stunt against the user compilation, then formatting and rebinding it for registration, was most of the generator time on Static.
@kzu kzu changed the title Skip binding generic calls that are not stunt generators Speed up compile-time stunt generation Oct 8, 2026
@kzu kzu added the enhancement New feature or request label Oct 8, 2026
@kzu
kzu merged commit e35e23e into main Oct 8, 2026
6 checks passed
@kzu
kzu deleted the perf/filter-generic-invocations branch October 8, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant