kpreid / all-is-cubes

Yet another block/voxel game; in this one the blocks are made out of blocks. Runs in browsers on WebGL+WebAssembly.
https://kpreid.dreamwidth.org/tag/all+is+cubes
Apache License 2.0
147 stars 8 forks source link

Batched notifications #457

Closed kpreid closed 3 months ago

kpreid commented 5 months ago

Right now, each individual change to a Space or other entity using listen::Notifier immediately iterates through the set of listeners and invokes all of them. This is probably rather cache-unfriendly and also contains redundant operations.

Try buffering notifications until the end of the overall operation (e.g. a transaction). Benchmark the results (e.g. modifying a Space with a listening raytracer). The buffer could be stored in the notifier itself, or it could be in a guard object which flushes the buffer on drop.

On the Listener side, change the signature to accept a slice of messages.

kpreid commented 3 months ago

As of 7b9d68bd5e1c00838de3fb2c3b755d34817b40da: