Skip to content

perf: retrieve the VB data context cache once per dispatch - #411

Open
marius-bughiu wants to merge 1 commit into
codex/corewf-03-share-vb-cache-helpersfrom
codex/corewf-04-hoist-vb-cache-retrieval
Open

marius-bughiu wants to merge 1 commit into
codex/corewf-03-share-vb-cache-helpersfrom
codex/corewf-04-hoist-vb-cache-retrieval

Conversation

@marius-bughiu

Copy link
Copy Markdown
Contributor

Standalone Visual Basic source repeats the cache-array lookup in every expression-ID branch. Retrieve the array once before dispatch when IDs are dense, then keep each expression's existing cache slot and lazy data-context construction. Guard invalid IDs before touching the activity context. Empty/sparse IDs, C#, partial classes and the location-list overload retain their previous paths. This cohort shows lower allocations but no whole-process elapsed-time improvement; the measured time increases are shown below.

Stack 4/4; base branch codex/corewf-03-share-vb-cache-helpers. 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.684 s
Whole-process managed allocation With 9.8 GB 9.6 GB -169.73 MB
Compile With 14 s 13 s -0.273 s
Compile managed allocation With 5.5 GB 5.3 GB -135.41 MB
ExpressionsCompiler.CompileExpressions With 8.20 s 7.43 s -0.769 s
Source-generation thread allocation With 640.62 MB 608.38 MB -32.24 MB
Source-parsing thread allocation With 141.48 MB 138.55 MB -2.94 MB
Generated source With 43,327,093 characters 40,538,754 characters -2,788,339 characters
Peak sampled private memory With 2.5 GB 2.4 GB -134.06 MB
Whole process Without 22 s 24 s +1.65 s
Whole-process managed allocation Without 9.4 GB 9.4 GB -65.63 MB
Compile Without 12 s 13 s +1.10 s
Compile managed allocation Without 5.3 GB 5.2 GB -125.59 MB
ExpressionsCompiler.CompileExpressions Without 5.78 s 7.52 s +1.74 s
Source-generation thread allocation Without 638.09 MB 605.67 MB -32.42 MB
Source-parsing thread allocation Without 139.05 MB 134.25 MB -4.80 MB
Generated source Without 43,158,131 characters 40,368,994 characters -2,789,137 characters
Peak sampled private memory Without 2.4 GB 2.2 GB -206.06 MB

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

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

Metric Templates Before After Delta
Whole process With 28 s 25 s -2.36 s
Whole-process managed allocation With 10.0 GB 9.6 GB -393.77 MB
ValidateProject With 2.76 s 2.64 s -0.117 s
ValidateProject managed allocation With 1.5 GB 1.5 GB -57.43 MB
AnalyzeProject With 4.18 s 3.53 s -0.651 s
AnalyzeProject managed allocation With 2.1 GB 2.1 GB -2.62 MB
Compile With 15 s 13 s -1.52 s
Compile managed allocation With 5.7 GB 5.3 GB -331.49 MB
Source-generation thread allocation With 689.36 MB 608.38 MB -80.98 MB
Source-parsing thread allocation With 147.00 MB 138.55 MB -8.45 MB
Generated source With 46,395,569 characters 40,538,754 characters -5,856,815 characters
Peak sampled private memory With 2.5 GB 2.4 GB -94.87 MB
Whole process Without 30 s 24 s -5.97 s
Whole-process managed allocation Without 9.6 GB 9.4 GB -251.36 MB
ValidateProject Without 3.39 s 2.60 s -0.790 s
ValidateProject managed allocation Without 1.5 GB 1.5 GB +34.88 MB
AnalyzeProject Without 5.90 s 3.70 s -2.20 s
AnalyzeProject managed allocation Without 2.1 GB 2.1 GB +1.22 MB
Compile Without 15 s 13 s -1.71 s
Compile managed allocation Without 5.5 GB 5.2 GB -287.83 MB
Source-generation thread allocation Without 686.70 MB 605.67 MB -81.03 MB
Source-parsing thread allocation Without 147.97 MB 134.25 MB -13.72 MB
Generated source Without 46,211,967 characters 40,368,994 characters -5,842,973 characters
Peak sampled private memory Without 2.4 GB 2.2 GB -211.01 MB

Validation: The exact publication commit passed 38 cumulative focused cases and 57 existing cases. This evolves the preceding source-generation test class, preserves its execution checks and root-only helper assertion, and adds invalid-ID/empty-input coverage. Sixteen behavior cases passed on the preceding implementation. The statement test preserves an existing generator rejection; it does not claim statement execution support. 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