▲ | aapoalas 7 days ago | |||||||||||||||||||||||||||||||||||||||||||
It is very true that a general purpose computation can theoretically do anything and mess linearity of access patterns entirely up. But in practice programs do most of their work in very linear fashion. It's not by chance that eg. V8 will try to write objects parsed from a JSON array of objects one right after the other. So in a sense we can say that the JavaScript program itself becomes the System with a capital S. That is not to say that Nova's heap vectors will necessarily make sense: The two big possible stumbling blocks are 1) growing of heap vectors possibly taking too long, and 2) compacting of heap vectors during GC taking too long. The first point basically comes down to the fact that, at present, each heap vector is truly a single Rust Vec. When it can no longer fit all the heap data into it, it needs to reallocate. Imagine you have 2 billion ordinary objects, and suddenly the ordinary objects vector needs to reallocate: This will cause horrible stalls in the VM. This can be mitigated at the cost of splitting each heap vector into chunks, but this of course comes at the cost of an extra indirection and some lack of linearity in the memory layout. The second point is more or less a repeat of the first: Imagine you have 2 billion ordinary objects, and suddenly a single one at the beginning of the vector is removed by GC: The GC has to now move every object remaining in the vector down a step to make the vector dense again. This is something that I cannot really do anything about: I can make this less frequent by introducing a "minor GC" but eventually a "major GC" must happen and something like this can then be experienced. I can only hope that this sort of things are rare. The alternative would be to do a "swap to tail", so the last item in the vector is moved to take the removed item's place. But that then means that linear access is no longer guaranteed. It also plays havoc on how our GC is implemented but that's kind of a side point. Software engineering is architecture is full of trade-offs :) I'm just hoping that the ones we've made will prove to make sense. | ||||||||||||||||||||||||||||||||||||||||||||
▲ | kaoD 7 days ago | parent | next [-] | |||||||||||||||||||||||||||||||||||||||||||
> It's not by chance that eg. V8 will try to write objects parsed from a JSON array of objects one right after the other. Yes, but note this is still a different pattern of access (array of "entities"). V8 does this because it assumes that e.g. `foo.name` is very likely going to be accessed along with `foo.lastName` (which is likely the 99% case for general computing) whereas ECS assumes `foo.name` is very likely going to be accessed along with `foo2.name`, `foo3.name`, ..., `fooN.name` (which is the 99% case for videogame timestep loops). > Software engineering is architecture is full of trade-offs :) I'm just hoping that the ones we've made will prove to make sense. To clarify: my comment is not a criticism of Nova's design decisions. I was only trying to clarify the answer to "Why would a game benefit from ECS?" for those foreign to ECS's existential motive. I'm sure Nova's tradeoffs make sense for some workloads and I wish you the best! | ||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||
▲ | tubs 7 days ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||
Virtual alloc your vectors so you can add more backing memory without having to modify the addresses of existing items. Compaction can reap only empty pages but you’ll still need some moving to avoid over fragmentation. | ||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||
▲ | dinfuehr 7 days ago | parent | prev [-] | |||||||||||||||||||||||||||||||||||||||||||
> The GC has to now move every object remaining in the vector down a step to make the vector dense again Is there something which forces you to compact everything here? Or could you do what most GCs do and track that free entry in a free list? | ||||||||||||||||||||||||||||||||||||||||||||
|