ecs-framework icon indicating copy to clipboard operation
ecs-framework copied to clipboard

QuerySystem 缓存策略优化

Open esengine opened this issue 3 months ago • 1 comments

  • 每次实体变更都清空全部缓存
  • 缓存粒度过粗

需要优化为:

class QuerySystem {
  // 精细化缓存失效
  invalidateCache(entity: Entity) {
    const archetype = this.getArchetype(entity);
    // 只失效相关的查询缓存
    this.invalidateArchetypeQueries(archetype);
  }
  
  // 增量更新
  updateEntityCache(entity: Entity, oldMask: BitMask, newMask: BitMask) {
    // 计算差异
    const added = BitMask.xor(oldMask, newMask);
    // 只更新受影响的查询
  }
}

esengine avatar Oct 10 '25 04:10 esengine