Skip to content

perf: defer dictionaries for single location declarations - #409

Open
marius-bughiu wants to merge 1 commit into
codex/corewf-01-lockfree-location-cachefrom
codex/corewf-02-single-location-scope
Open

marius-bughiu wants to merge 1 commit into
codex/corewf-01-lockfree-location-cachefrom
codex/corewf-02-single-location-scope

Conversation

@marius-bughiu

Copy link
Copy Markdown
Contributor

A scope containing one named location currently allocates a dictionary. Store that first declaration directly and allocate the dictionary when a second name or an enumerable view requires it. Preserve the original key after a variable rename, parent lookup, duplicate-name diagnostics, and the live enumeration view. This cohort shows lower allocations but no whole-process elapsed-time improvement; the measured time increases are shown below.

Stack 2/4; base branch codex/corewf-01-lockfree-location-cache. Cumulative results start at public CoreWF commit 65caba7c7fc7d141e847775b00f2c9558e8daa59. None of these optimizations relies on duplicate expression text.

Measured on six synthetic authored cases with scenario-local variables and mostly unique expressions, with execution templates assigned versus removed. All validation and analyzer rules are enabled. Each of the five source-built CoreWF states ran twice per variant in forward/reverse order, serially on the same machine and compiler host. Every run deleted the isolated project .local first. The actual loaded CoreWF image hashes, input inventories, diagnostics and output coverage were verified.

Adjacent change (preceding stack state → this state; medians of two runs):

Metric Templates Before After Delta
Whole process With 24 s 25 s +0.889 s
Whole-process managed allocation With 9.9 GB 9.9 GB -45.89 MB
ValidateProject With 2.34 s 2.42 s +0.079 s
ValidateProject managed allocation With 1.5 GB 1.5 GB -34.90 MB
Peak sampled private memory With 2.5 GB 2.3 GB -182.07 MB
Whole process Without 23 s 24 s +0.381 s
Whole-process managed allocation Without 9.6 GB 9.6 GB -35.24 MB
ValidateProject Without 2.28 s 2.36 s +0.082 s
ValidateProject managed allocation Without 1.5 GB 1.5 GB -26.19 MB
Peak sampled private memory Without 2.3 GB 2.3 GB -32.99 MB

Whole-process observations behind the adjacent medians: With templates: before [25 s, 23 s], after [25 s, 25 s]. Without templates: before [23 s, 24 s], after [24 s, 24 s].

Cumulative change (original CoreWF state → this state; same cohort):

Metric Templates Before After Delta
Whole process With 28 s 25 s -2.68 s
Whole-process managed allocation With 10.0 GB 9.9 GB -84.14 MB
ValidateProject With 2.76 s 2.42 s -0.343 s
ValidateProject managed allocation With 1.5 GB 1.5 GB -63.05 MB
AnalyzeProject With 4.18 s 3.38 s -0.805 s
AnalyzeProject managed allocation With 2.1 GB 2.1 GB -2.17 MB
Compile With 15 s 14 s -1.26 s
Compile managed allocation With 5.7 GB 5.7 GB -17.20 MB
Peak sampled private memory With 2.5 GB 2.3 GB -161.51 MB
Whole process Without 30 s 24 s -6.30 s
Whole-process managed allocation Without 9.6 GB 9.6 GB -2.93 MB
ValidateProject Without 3.39 s 2.36 s -1.02 s
ValidateProject managed allocation Without 1.5 GB 1.5 GB -20.41 MB
AnalyzeProject Without 5.90 s 3.92 s -1.98 s
AnalyzeProject managed allocation Without 2.1 GB 2.1 GB +5.89 MB
Compile Without 15 s 13 s -2.14 s
Compile managed allocation Without 5.5 GB 5.5 GB +11.30 MB
Peak sampled private memory Without 2.4 GB 2.3 GB -136.68 MB

Validation: 11 new behavior cases passed on the preceding and changed implementation; the complete 21-case location suite and 57 existing expression, validation and serialization cases passed on both states. Release owner builds used SDK 8.0.426 and net6.0-windows; the compiler host used .NET 10.0.11. The complete CoreWF test suite was not run. Build copies disabled the repository's package-generation/global-cache-cleanup postbuild actions; no such project changes are included in this PR.

These are descriptive six-case diagnostics, not a 1,000-case throughput result or a statistical confidence claim. Host load, GC and run order can affect elapsed time; increases are retained in the tables. Managed allocation is not retained heap size. Nested phases overlap and must not be summed. Deltas use unrounded values; displayed values are rounded independently. Matching compiler output coverage does not establish arbitrary workflow execution or persistence equivalence.

Note

This change and description were prepared with AI assistance; the measurements and test results above were collected locally.

This branch has not been deployed

No deployments
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