Skip to content

Commit 95396fc

Browse files
authored
Merge pull request #71 from csprance/codex/review-and-optimize-ecs-for-speed
Remove unused QueryBuilder pooling
2 parents a703b47 + 738c1b1 commit 95396fc

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# GECS Changelog
22

3+
## [Unreleased]
4+
5+
### Removed
6+
- Removed the unused QueryBuilder pooling infrastructure; `World.query` now always creates a fresh builder while retaining cache invalidation wiring for clarity and predictable lifecycle management.
7+
38
## [5.0.0] - 2025-10-15 - Major ECS Overhaul & Performance Awesomeness (Some Small Breaking Changes)
49

510
**GECS v5.0.0 is a major release with massive performance improvements, API simplification, and relationship system overhaul.**

‎addons/gecs/ecs/world.gd‎

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,9 @@ var entity_to_archetype: Dictionary = {} # Entity -> Archetype
7272
## so that all queries are invalidated anytime we emit cache_invalidated.
7373
var query: QueryBuilder:
7474
get:
75-
var q: QueryBuilder
76-
if _query_builder_pool.is_empty():
77-
q = QueryBuilder.new(self )
78-
if not cache_invalidated.is_connected(q.invalidate_cache):
79-
cache_invalidated.connect(q.invalidate_cache)
80-
else:
81-
q = _query_builder_pool.pop_back()
82-
q.clear()
75+
var q: QueryBuilder = QueryBuilder.new(self)
76+
if not cache_invalidated.is_connected(q.invalidate_cache):
77+
cache_invalidated.connect(q.invalidate_cache)
8378
return q
8479
## Index for relationships to entities (Optional for optimization)
8580
var relationship_entity_index: Dictionary = {}
@@ -90,9 +85,6 @@ var _worldLogger = GECSLogger.new().domain("World")
9085
## Cache for commonly used query results - stores matching archetypes, not entities
9186
## This dramatically reduces cache invalidation since archetypes are stable
9287
var _query_archetype_cache: Dictionary = {} # query_sig -> Array[Archetype]
93-
## Pool of QueryBuilder instances to reduce creation overhead
94-
var _query_builder_pool: Array[QueryBuilder] = []
95-
var _pool_size_limit: int = 10
9688
## Track cache hits for performance monitoring
9789
var _cache_hits: int = 0
9890
var _cache_misses: int = 0
@@ -1058,13 +1050,6 @@ func _invalidate_cache(reason: String) -> void:
10581050
_cache_invalidation_reasons[reason] = _cache_invalidation_reasons.get(reason, 0) + 1
10591051

10601052

1061-
## Return a QueryBuilder instance to the pool for reuse
1062-
func _return_query_builder_to_pool(query_builder: QueryBuilder) -> void:
1063-
if _query_builder_pool.size() < _pool_size_limit:
1064-
query_builder.clear()
1065-
_query_builder_pool.append(query_builder)
1066-
1067-
10681053
## Calculate archetype signature for an entity based on its components
10691054
## Uses the same hash function as queries for consistency
10701055
## An entity signature is just a query with all its components (no any/exclude)

0 commit comments

Comments
 (0)