Skip to content

Commit f6b8844

Browse files
authored
Merge pull request #40 from BlackMATov/dev
Dev
2 parents e48bdf0 + 7ce5ee9 commit f6b8844

7 files changed

Lines changed: 777 additions & 269 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
- [Chunk](#chunk)
6464
- [Builder](#builder)
6565
- [Changelog](#changelog)
66+
- [v1.9.0](#v190)
6667
- [v1.8.0](#v180)
6768
- [v1.7.0](#v170)
6869
- [v1.6.0](#v160)
@@ -1565,6 +1566,11 @@ builder_mt:destruction_policy :: id -> builder
15651566

15661567
## Changelog
15671568

1569+
### v1.9.0
1570+
1571+
- Performance improvements of the [`evolved.destroy`](#evolveddestroy) and [`evolved.batch_destroy`](#evolvedbatch_destroy) functions
1572+
- Ensured deterministic chunk ordering to improve processing consistency across runs
1573+
15681574
### v1.8.0
15691575

15701576
- Added the new [`evolved.REALLOC`](#evolvedrealloc) and [`evolved.COMPMOVE`](#evolvedcompmove) fragment traits that allow customizing component storages

develop/ROADMAP.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@
55
- observers and events
66
- add INDEX fragment trait
77
- use compact prefix-tree for chunks
8-
- optional ffi component storages
98

109
## Thoughts
1110

1211
- We should have a way to not copy components on deferred spawn/clone
13-
- Not all assoc_list_remove operations need to keep order, we can have an unordered variant also
14-
- We still have several places where we use __lua_next without deterministic order, we should fix that
1512
- Having a light version of the gargabe collector can be useful for some use-cases
16-
- We can shrink the table pool tables on garbage collection if they are too large
17-
- Should we sort chunk children by fragment id?
1813
- Basic default component value as true looks awful, should we use something else?
1914

2015
## Known Issues

develop/all.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require 'develop.testing.system_as_query_tests'
1616

1717
require 'develop.benchmarks.clone_bmarks'
1818
require 'develop.benchmarks.common_bmarks'
19+
require 'develop.benchmarks.destroy_bmarks'
1920
require 'develop.benchmarks.migration_bmarks'
2021
require 'develop.benchmarks.process_bmarks'
2122
require 'develop.benchmarks.spawn_bmarks'
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
local evo = require 'evolved'
2+
local basics = require 'develop.basics'
3+
4+
evo.debug_mode(false)
5+
6+
local N = 1000
7+
8+
print '----------------------------------------'
9+
10+
basics.describe_bench(string.format('Destroy Benchmarks: Acquire and Release %d ids', N),
11+
function(tables)
12+
local id = evo.id
13+
local destroy = evo.destroy
14+
15+
for i = 1, N do
16+
tables[i] = id()
17+
end
18+
19+
for i = 1, N do
20+
destroy(tables[i])
21+
end
22+
end, function()
23+
return {}
24+
end)
25+
26+
basics.describe_bench(string.format('Destroy Benchmarks: Acquire and Release %d double ids', N),
27+
function(tables)
28+
local id = evo.id
29+
local destroy = evo.destroy
30+
31+
for i = 1, N, 2 do
32+
tables[i], tables[i + 1] = id(2)
33+
end
34+
35+
for i = 1, N, 2 do
36+
destroy(tables[i], tables[i + 1])
37+
end
38+
end, function()
39+
return {}
40+
end)
41+
42+
basics.describe_bench(string.format('Destroy Benchmarks: Acquire and Release %d triple ids', N),
43+
function(tables)
44+
local id = evo.id
45+
local destroy = evo.destroy
46+
47+
for i = 1, N, 3 do
48+
tables[i], tables[i + 1], tables[i + 2] = id(3)
49+
end
50+
51+
for i = 1, N, 3 do
52+
destroy(tables[i], tables[i + 1], tables[i + 2])
53+
end
54+
end, function()
55+
return {}
56+
end)

develop/testing/main_tests.lua

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,27 +2302,66 @@ do
23022302
evo.set(e2, f2, 44)
23032303

23042304
do
2305-
local iter, state = evo.execute(q)
2306-
local chunk = iter(state)
2307-
assert(chunk and chunk ~= evo.chunk(f1))
2305+
local e1_count = 0
2306+
local e2_count = 0
2307+
2308+
for _, entity_list, entity_count in evo.execute(q) do
2309+
for i = 1, entity_count do
2310+
if entity_list[i] == e1 then
2311+
e1_count = e1_count + 1
2312+
elseif entity_list[i] == e2 then
2313+
e2_count = e2_count + 1
2314+
end
2315+
end
2316+
end
2317+
2318+
assert(e1_count == 1)
2319+
assert(e2_count == 1)
23082320
end
23092321

23102322
evo.set(q, evo.EXCLUDES, { f2 })
23112323

23122324
do
2313-
local iter, state = evo.execute(q)
2314-
local chunk = iter(state)
2315-
assert(chunk and chunk ~= evo.chunk(f1))
2325+
local e1_count = 0
2326+
local e2_count = 0
2327+
2328+
for chunk, entity_list, entity_count in evo.execute(q) do
2329+
assert(not chunk:has(f2))
2330+
2331+
for i = 1, entity_count do
2332+
if entity_list[i] == e1 then
2333+
e1_count = e1_count + 1
2334+
elseif entity_list[i] == e2 then
2335+
e2_count = e2_count + 1
2336+
end
2337+
end
2338+
end
2339+
2340+
assert(e1_count == 1)
2341+
assert(e2_count == 0)
23162342
end
23172343

23182344
evo.set(q, evo.INCLUDES, { f1 })
23192345

23202346
do
2321-
local iter, state = evo.execute(q)
2322-
local chunk, entity_list, entity_count = iter(state)
2323-
assert(chunk == evo.chunk(f1))
2324-
assert(entity_list and entity_list[1] == e1)
2325-
assert(entity_count == 1)
2347+
local e1_count = 0
2348+
local e2_count = 0
2349+
2350+
for chunk, entity_list, entity_count in evo.execute(q) do
2351+
assert(chunk:has(f1))
2352+
assert(not chunk:has(f2))
2353+
2354+
for i = 1, entity_count do
2355+
if entity_list[i] == e1 then
2356+
e1_count = e1_count + 1
2357+
elseif entity_list[i] == e2 then
2358+
e2_count = e2_count + 1
2359+
end
2360+
end
2361+
end
2362+
2363+
assert(e1_count == 1)
2364+
assert(e2_count == 0)
23262365
end
23272366
end
23282367

0 commit comments

Comments
 (0)