Japes: a high troughput ecs. bevy style
Last update on the optimization process, since i do not think there is much more to do. As the patterns that worked against escape analysis got clearer it was more mechanical work to look for places the anti patterns are used. the result is:
| Benchmark | Entities | B/op | System-loop EA |
|---|---|---|---|
| iterateWithWrite | 10k | 0 | 100% — zero heap allocation |
| NBody oneTick | 10k | 0 | 100% — zero heap allocation |
| SparseDelta | 10k | 3,214 | ~100% — residual from driver |
| RealisticTick | 10k | 11,270 | ~100% — residual from driver |
| PredatorPrey @ForEachPair | 500×2k | 34,564 | ~100% — residual from commands/spawn |
| ParticleScenario | 10k | 75,153 | ~100% — residual from 1% spawn/despawn |
| UnifiedDelta | 10k | 295,763 | 89% — residual from spawn/despawn/strip |
one op is basically a full world.tick()
a basic system like:
record Position(float x, float y, float z) {}
record Velocity(float dx, float dy, float dz) {}
record Mass(float m) {}
record DeltaTime(float dt) {}
static class IntegrateSystems {
@System
void integrate(@Read Velocity vel, @Write Mut<Position> pos, Res<DeltaTime> dt) {
var p = pos.get();
var d = dt.get().dt();
pos.set(new Position(p.x() + vel.dx() * d, p.y() + vel.dy() * d, p.z() + vel.dz() * d));
}
}
now gets executed completely allocation free. due to perfect data alignment in the array jit probably is vectorizing the execution since i am processing all 10k entities in 1.8microseconds. (on my cpu that is very close to 1 entity / clock cycle) Could not belive it so i am reading the values back in teardown. I suspected jit eliminates everything. (i am still sceptical)
Next few days i am going to bug search/fix, a storage backend / interface is still missing. then i might even try to upload to central.
Updated the “One JIT to rule them all” page to remove all the “facts” that later got disproved. So now it is more a collection of stuff that works rather than a progress log
Discussion in the ATmosphere