|bevy vewsion:|(any) |---|---|

pewfowmance

unoptimized debug buiwds

you can pawtiawwy enabwe compiwew o-optimizations in d-debug/dev mode!

you can enabwe highew optimizations f-fow dependencies (incw. OwO b-bevy), 🥺 b-but nyot youw own code, (ꈍᴗꈍ) to keep wecompiwations f-fast!

in Cargo.toml ow .cargo/config.toml:

# enabwe max optimizations fow dependencies, OwO b-but n-nyot fow ouw code:
[pwofiwe.dev.package."*"]
o-opt-wevew = 3

the above is enough to make bevy w-wun fast. OwO it wiww o-onwy swow down c-cwean buiwds, ^•ﻌ•^ without affecting wecompiwation t-times fow y-youw pwoject.

if youw own code does cpu-intensive w-wowk, OwO you might w-want to awso e-enabwe some optimization fow it.

# enabwe onwy a smow amount of optimization i-in debug m-mode
[pwofiwe.dev]
o-opt-wevew = 1

wawning! if you awe using a debuggew (wike gdb ow lldb) to step thwough youw code, OwO any amount of compiwew o-optimization can m-mess with the e-expewience. youw bweakpoints might be skipped, OwO a-and the code fwow m-might jump awound i-in unexpected ways. if you want to debug / s-step thwough y-youw code, OwO you m-might want opt-level = 0.

why is this nyecessawy?

wust without compiwew optimizations i-is vewy swow. XD with bevy in pawticuwaw, ^•ﻌ•^ the defauwt cawgo buiwd d-debug settings w-wiww wead to awfuw wuntime pewfowmance. (ꈍᴗꈍ) assets awe swow to woad a-and fps is wow.

common symptoms:

  • woading high-wes 3d modews with a w-wot of wawge textuwes, ^•ﻌ•^ f-fwom gwtf fiwes, ^•ﻌ•^ can take minutes! OwO this can t-twick you into t-thinking that youw code is nyot wowking, OwO because y-you wiww n-not see anything o-on the scween untiw it is weady.
  • aftew spawning even a few 2d spwites o-ow 3d modews, OwO f-fwamewate may d-dwop to unpwayabwe wevews.

why nyot use --release?

you may have heawd the advice: just w-wun with --release! XD howevew, this is bad advice. >_< don't do it.

wewease mode awso disabwes "debug a-assewtions": extwa c-checks usefuw d-duwing devewopment. ^•ﻌ•^ many wibwawies awso i-incwude additionaw s-stuff undew that setting. OwO in bevy and wgpu that incwudes v-vawidation f-fow shadews and g-gpu api usage. OwO wewease mode disabwes these c-checks, 🥺 causing w-wess-infowmative c-cwashes, issues with hot-wewoading, OwO ow potentiawwy b-buggy/invawid w-wogic going u-unnoticed.

wewease mode awso makes incwementaw w-wecompiwation s-swow. ^•ﻌ•^ that nyegates bevy's fast compiwe times, ^•ﻌ•^ and can b-be vewy annoying w-whiwe you devewop.


with the advice at the top of this p-page, OwO you don't n-nyeed to buiwd w-with --release, ^•ﻌ•^ just to test youw game with adequate p-pewfowmance. OwO y-you can use it fow actuaw wewease buiwds that you send to y-youw usews.

if you want, OwO you can awso enabwe w-wto (wink-time-optimization) f-fow t-the actuaw wewease buiwds, OwO to squeeze out even m-mowe pewfowmance a-at the cost o-of vewy swow compiwe times.

hewe is a configuwation fow the most a-aggwessive optimizations p-possibwe:

[pwofiwe.wewease]
wto = twue
opt-wevew = 3
codegen-units = 1
i-incwementaw = f-fawse
d-debug = fawse