Skip to content

Performance: don't iterate on all archetypes on all queries for new archetypes - #323

Merged
genaray merged 2 commits into
genaray:masterfrom
lgarczyn:query-match-perf
Nov 9, 2026
Merged

genaray merged 2 commits into
genaray:masterfrom
lgarczyn:query-match-perf

Conversation

@lgarczyn

@lgarczyn lgarczyn commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

When archetype counts gets too big, we get +10ms total cost each time a new archetype is added, because every query has to scan all archetypes

This adds a version count to Archetypes and a _matchedCount/_matchedVersion to Queries so they can skip the ones they already checked

Would break if anyone edits Archetypes.Items directly I guess

Added claude-generated benchmarks and tests

Fix Archetypes.Clear and index setter not clearing the cache, and queries accidentally returning removed archetypes

@genaray
genaray merged commit decd8ba into genaray:master Nov 9, 2026
8 checks passed
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.

2 participants