afonsolage / projekto

Voxel game made with Bevy Engine
MIT License
59 stars 4 forks source link

Move heavy computational systems to a separated thread? #1

Closed afonsolage closed 2 years ago

afonsolage commented 2 years ago

Currently, when moving quick there are 4 systems that heavily decreases the FPS:

While there are a lot of improvements to do on those systems, it's better to move'em to another thread and postpone the optimizations.

As a general rule, any system that takes more than 1ms on average (1.000μs) should be either optimized or moved to a separated thread, since our project aims 60fps (16.6666ms) and there are a lot of other things to do every frame.

Sep 20 13:26:34.960  INFO projekto::debug::perf: Performance Counter: 
gen_cache_system               avg: 34623μs, samples:    35, min: 29802μs, max: 51531μs, meta:    12μs
faces_merging_system           avg: 18806μs, samples:   505, min: 14464μs, max: 35194μs, meta:    15μs
load_cache_system              avg:  5423μs, samples:   540, min:    33μs, max: 16368μs, meta:     8μs
faces_occlusion_system         avg:  3366μs, samples:   505, min:   965μs, max: 12457μs, meta:    18μs
update_landscape_system        avg:   189μs, samples:   757, min:     7μs, max: 15589μs, meta:     1μs
spawn_chunks_system            avg:    85μs, samples:   505, min:    31μs, max:   614μs, meta:     5μs
mesh_generation_system         avg:    68μs, samples:   505, min:     8μs, max:   238μs, meta:    11μs
vertices_computation_system    avg:    28μs, samples:   434, min:     1μs, max:   226μs, meta:    14μs
despawn_chunks_system          avg:     9μs, samples:   380, min:     5μs, max:    34μs, meta:     5μs
clean_up_system                avg:     1μs, samples:   297, min:     1μs, max:    19μs, meta:     7μs