I am considering to allocate most persistent data of my ECS framework on a one-frame allocator.
To extend their life to exist on > 1 frame, I will need to copy it to another buffer.
Initialization I create Buffer X and Y. Each has 50-300MB.
1st timestep : every Entity / Components will use buffer X to allocate.
1st-end : copy every Entity/Component that are not marked as deleted to buffer Y, clear X.
2st timestep : every Entity / Components will use buffer Y to allocate.
2st-end : copy every Entity/Component that are not marked as deleted to buffer X, clear Y. ...
Advantage
almost 0 fragmentation cost, pool is not needed anymore
very low cache miss in game-logic
Disadvantage
high cost of memory swapping (X<-->Y 50-300 MB every timestep)
Reason : computer can read or write memory at 10 GB/s = 170 MB/timestep
(reference : https://stackoverflow.com/questions/25827416/ )
(minor) pointer become invalidated, I must use ID instead
Note: Luckily, every components are POD (plain old data = no pointer as field).
After some draft, it strongly believe it is possible to implement.
Question
Does it sound bad? Is it a good practice / technique?
Is "ping-pong buffer" a correct name of this technique? What are other names?
↧