Repository navigation
Keep compile-time hashtables in a nested map - #1367
Merged
Merged
Conversation
The interpreter stored every hashtable entry in one LinkedListMultimap keyed by (parent, child), so flushing a parent key scanned the whole table. Use nested maps keyed by parent, child and value type, replay them without the multimap, and look the natives up once.
New tests cover a slot holding several value types, removing one child, removing only the string, and an integer and a real of equal value sharing a slot (the old multimap removed the integer when the real was removed or replaced).
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Frotty
added a commit
to Code-Fixxers/WurstScript
that referenced
this pull request
Oct 6, 2026
Drop changes that are split out or independent of the chunk cache and validation cache: the hashtable rewrite and compile-time runner changes (wurstscript#1367), the ABI-gated model invalidation (wurstscript#1368), the EliminateGenerics rewrite, parallel/fused lowering passes, the reachable-only LocalPlayerContextAnalyzer, the w3i cache, the closure-name suffix and timing/micro-optimisation churn. Keeps what -incremental needs: chunk cache, PackageAbi, validation cache, modular Lua translation, the CLI/LSP incremental pipeline and their tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #1353. It is independent of incremental compilation and changes nothing in the Lua backend.
The compile-time interpreter stored every hashtable entry in one
LinkedListMultimapkeyed by (parent, child), so typed lookups and flushes scanned the table. It is now nested maps keyed by parent, child and value type. Replaying a compile-time hashtable into the runtime program no longer goes through the multimap, natives are looked up once instead of once per entry, and the dead multimap path andKeyPairare removed.Fix: an integer and a real of equal value no longer replace each other. The old multimap removed the first
equals()element, soSaveInteger(h,1,1,3); SaveReal(h,1,1,3.0); SaveReal(h,1,1,5.0)lost the integer (test fails on master).Performance: neutral for ordinary compile-time use, faster for flush-heavy use. Measured as whole compile-time test programs on this machine (noisy, three runs each, ms):
FlushParentHashtableFlushChildHashtableon halfThe first three are within noise of each other: their time is spent in the interpreter and in replaying the saves, not in the table. Only the last, flushing children out of a large table, shows a gain (about 25-30%), because
FlushChildHashtableis O(1) now instead of a scan of the whole table.Cost: each (parent, child) slot holds a small map, so a table uses more memory per entry (roughly 150 to 380 B instead of 150 to 170 B). A micro-benchmark that creates many fresh parents and flushes them with
FlushParentHashtablewas about 1.5x slower in the data structure alone; it did not show up in the whole-program run above.Tests:
CompiletimeHashtableTestscovers a slot with several value types, removing one child, removing only the string, the int/real case, flush child/parent, and a Lua run.