Arch icon indicating copy to clipboard operation
Arch copied to clipboard

Cached `Query`s

Open genaray opened this issue 2 years ago • 1 comments

Problem

Each Query currently iterates the whole list of Archetypes. This is bad for scenarios with many archetypes.

Instead each query should ONLY iterate archetypes that fits its description.

Solution

We need some way to map a Query to its Archetypes and a Archetype to its Querys in a decoupled way. Therefore, we could add a QueryCache to the World that exactly does this mapping and validates the process.

public class QueryCache{

   internal Dictionary<Query, List<Archetype>> QueryToArchetype;
   internal Dictionary<Archetype, List<Query>> ArchetypeToQuerys;
}

Or as an alternative we put those lists directly into the Query and Archetype. This however would couple the classes to another which is generally not a great idea for refactoring and maintainability reasons.

genaray avatar Aug 24 '23 11:08 genaray

the ecs project flecs query caches matched tables. can we use its implementation.

ctxdegithub avatar Jun 09 '24 00:06 ctxdegithub

Introduced in 3c738541b942c08608f2ee3d6e56f687dedc7a88

genaray avatar Aug 14 '24 23:08 genaray