Repository navigation
perf(storage): cache column maps and intern archetypes by bitmask - #12
Merged
Merged
Conversation
Each archetype maps every registered component to its table column, and each cached transition stores the column map for its move. Get<T>, bundle writes, inserts, and row moves no longer binary-search component IDs. Archetypes are interned by component bitmask, the empty archetype is cached, and TryGet reads the directory entry once. Measurements are in benchmarks/step6-cached-column-maps.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://feat-step6-column-maps-archevolt.hayman.workers.dev (commit 65330d3)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
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.
Why
Get<T>, bundle writes, inserts, and every structural move binary-searched an archetype's sorted component IDs, and archetypes were interned by a joined string. This is ROADMAP step 6. Each archetype now holds a dense component-to-column lookup, and each cached transition holds the column map for its move. Archetypes are interned by their component bitmask.Scope
Archetype.ColumnsreplacesArray.BinarySearchinTryGet<T>,WriteBundle,ApplyInsert, andQueryState.Refresh.ArchetypeEdgeholds a transition's target and its column map.Table.CopyRowTocopies through it.AddTransitions,RemoveTransitions, andBundleBinding.Destinationscache edges.Worldinterns archetypes byulong[]mask and creates the empty archetype at build time.Archetypederives its sorted IDs from its mask.EntityTable.TryLocateletsTryGet<T>read the directory entry once.IsAlivedelegates to it.ROADMAP.mdstatus and amendments after step 6,benchmarks/step6-cached-column-maps.md, and one sentence indocs/concepts/architecture.mdx.Tradeoffs
The amendment after step 4 suggested that
BundleBindinghold its destination columns. The dense lookup costs one array read for every caller, so the binding does not need its own copy. Transition edges stay in per-archetype dictionaries. Dense edge arrays would cost memory for every archetype and component pair.Blast Radius
Internal storage only, with no public API change. Merging publishes a patch release through the release workflow. Every structural move and bundle write goes through the new column maps. The reference-model trace test and the multi-word mask test pass unchanged.
Verification
scripts/verify.ps1passed: 165 tests, Archeoids headless, package contents, JIT and NativeAOT consumers, the NativeAOT sample, and the performance smoke check. The docs site builds.Get<T>at 100,000 entities: 1,702 → 1,316 µs. Tag and wide round trips,Spawn, andSpawnBatchimproved at both sizes, and managed allocation did not change. The gate is met. Full interleaved measurements are inbenchmarks/step6-cached-column-maps.md.🤖 Generated with Claude Code