Repository navigation
Fix archetype and query matching on hash collisions, and TrimExcess id reuse - #317
Conversation
|
Thanks! Before we merge this, is there probably a Hash algo that we could replace it with so it does Not generate collisions? |
System.HashCode is probably close to the birthday bound, with thousands of archetypes, thousands of users each with hundreds of sessions, you're gonna get collisions. From napkin math with 2000 archetypes it's about 1 collision per 2000 sessions. Going to 64 bits would definitely fix it as well, but harder to test and prove, and then you have to do your hashing |
|
We just had a second confirmed collision ^^ two resource containers suddenly became crewmembers |
Alright, lets merge it than :) thanks! |
Hash collisions
QueryCachetreat equal hashes as equal component sets, but we got at least one confirmed hash collision. For context, we have up to 2000 archetypes on a normal game.Add,AddRange,CreateandRemovemove the entity to the wrong archetype, everything explodes. Dropped components, garbage new component. The add/remove pointers on archetypes keep the wrong archetype forever.World.Query()can return another description's query.Fix:
Signature.EqualsandQueryDescription.Equalscompare components after the hash checkTrimExcess reuses live ids (Fixes #315)
TrimExcessdropped recycled ids, which meant new entities could get existing id+version comboTests
9 new tests that fail on master and pass here.
Benchmark runs about the same