Closed MaxCWhitehead closed 1 year ago
Good find! I think having a feature flag in bevy_simple_tilemap
for rayon makes sense. It's already avoiding rayon on WASM targets, so it should be an extremely simple change to parameterize it for a feature as well.
I opened a PR adding this feature flag in bevy_simple_tilemap
, if this is merged / released we can disable this.
Description
I have consistently seen hitches in extract_tilemaps system in bevy_simple_tilemap. I dug into this as it seems like it should be a very straightforward function, just looping and math. It turns out when iterating over tiles, it is using 'par_iter', which seems to be Rayon's implementation of a magic parallel loop.
Issues with magic parallel loops are pretty common,I didn't look into what it's doing, but sometimes we get 10ms hitches here. Probably overhead spinning up a large amount of tasks, cache missing, copying all the data to other threads, etc.
Below is a screenshot of histogram of this scope with and without this par_iter call. Yellow is without, red is with. Will probably open an issue/PR with bevy_simple_tilemap on this, would be good to get this behind a feature flag, or have it off by default.