You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bevy_gizmos doc tests hang compute when run locally #12207
A-Build-SystemRelated to build systems or continuous integrationC-BugAn unexpected or incorrect behaviorS-BlockedThis cannot move forward until something else changes
Doc tests for initial crates pass, and then a dozen or so doc tests within bevy_gizmos get stuck, producing a warning that they've been running for more than 60 seconds.
My computer then runs out of RAM (over 12 GB!), freezes, and I have to hard reboot.
Additional information
Running with fewer threads via e.g. -j 4 improves responsiveness and slows down time-to-hang, but does not resolve the problem.
This issue is related to 'Microsoft® Incremental Linker' - the linker used by the rust compiler on some (most?) windows machines.
The linkers in the following image use 18.8 GB of RAM!
The one thing that sets bevy_gizmos apart from other crates like bevy_ecs is the increased "usage" of 'Microsoft® Incremental Linker'. Most other doc-tests also use 'Microsoft® Incremental Linker' but it does not use alot of memory there. Instead 'link.exe' uses more memory but remains within acceptable bounds (<1GB).
In addition, bevy_gizmos uses bevy_ecs::system::assert_is_system(system); alot in doc-tests. However, since other crates like bevy_ecs make excessive use of this assertion aswell and do not have this issue, I am not sure this is the cause of the problem.
No single doc-test in particular seems to be responsible for the increased memory usage, as removing any given set of doc-tests results in a decrease in memory usage more or less proportional to the amount of tests removed. Instead, running doc-tests for (very) large projects on windows machines seems to be the issue.
I was unable to find an "in code" fix for this, but there is a discussion on the rust forums that appears to suggest building for a different but compatible target or using rust-lld as the linker.
However, this problem does not seem to be limited to Windows only, as #11034 details a very similar (the same?) issue on a Linux machine.
For some reason --jobs 1 doesn't seem to actually limit the amount of tests being compiled, but -- --test-threads=1 does. It also seems that the linker is invoked for each test, and for bevy_gizmos tests it takes almost 2GB per invocation. By default cargo runs 16 of them (one per thread), making me quickly run out of RAM. I wonder why it doesn't happen with the earlier tests though
General conclusions seem to be the same as above, although it looks like rust-lang/rust#123974 should resolve this.
In addition to the previous observation, rustdoc doesn't respect the linker option in Cargo's config.toml, you need to explicitly set it in the rustdocflags:
This helps reduce the memory usage to 1/2 or 1/3, which is a huge improvement if it leads to avoiding swapping (depends on how much RAM your system has).
Same issue on Fedora 40. Running cargo ci creates many instances of ld which consume all available memory and cause a system crash. Setting rustdocflags to use lld fixed the problem. The nightly release also runs successfully since it uses rust-lld.
test result: ok. 45 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 17.96s
With cargo run -p ci -- doc there is an entirely different story. A whole bunch of crates pass and then...
Doc-tests bevy_gizmos
running 45 tests
test crates\bevy_gizmos\src\arcs.rs - arcs::Gizmos<'w,'s,Config,Clear>::arc_2d (line 34) has been running for over 60 seconds
test crates\bevy_gizmos\src\arcs.rs - arcs::Gizmos<'w,'s,Config,Clear>::arc_3d (line 154) has been running for over 60 seconds
test crates\bevy_gizmos\src\arcs.rs - arcs::Gizmos<'w,'s,Config,Clear>::long_arc_2d_between (line 386) has been running for over 60 seconds
test crates\bevy_gizmos\src\arcs.rs - arcs::Gizmos<'w,'s,Config,Clear>::long_arc_3d_between (line 253) has been running for over 60 seconds
test crates\bevy_gizmos\src\arcs.rs - arcs::Gizmos<'w,'s,Config,Clear>::short_arc_2d_between (line 340) has been running for over 60 seconds
test crates\bevy_gizmos\src\arcs.rs - arcs::Gizmos<'w,'s,Config,Clear>::short_arc_3d_between (line 207) has been running for over 60 seconds
test crates\bevy_gizmos\src\arrows.rs - arrows::ArrowBuilder<'_,'_,'_,Config,Clear>::with_tip_length (line 37) has been running for over 60 seconds
test crates\bevy_gizmos\src\arrows.rs - arrows::Gizmos<'w,'s,Config,Clear>::arrow (line 114) has been running for over 60 seconds
test crates\bevy_gizmos\src\arrows.rs - arrows::Gizmos<'w,'s,Config,Clear>::arrow_2d (line 145) has been running for over 60 seconds
test crates\bevy_gizmos\src\arrows.rs - arrows::Gizmos<'w,'s,Config,Clear>::axes (line 175) has been running for over 60 seconds
test crates\bevy_gizmos\src\arrows.rs - arrows::Gizmos<'w,'s,Config,Clear>::axes_2d (line 208) has been running for over 60 seconds
test crates\bevy_gizmos\src\circles.rs - circles::Gizmos<'w,'s,Config,Clear>::circle (line 116) has been running for over 60 seconds
test crates\bevy_gizmos\src\circles.rs - circles::Gizmos<'w,'s,Config,Clear>::circle_2d (line 157) has been running for over 60 seconds
test crates\bevy_gizmos\src\circles.rs - circles::Gizmos<'w,'s,Config,Clear>::ellipse (line 36) has been running for over 60 seconds
test crates\bevy_gizmos\src\circles.rs - circles::Gizmos<'w,'s,Config,Clear>::ellipse_2d (line 77) has been running for over 60 seconds
test crates\bevy_gizmos\src\circles.rs - circles::Gizmos<'w,'s,Config,Clear>::sphere (line 199) has been running for over 60 seconds
test crates\bevy_gizmos\src\cross.rs - cross::Gizmos<'_,'_,Config>::cross (line 24) has been running for over 60 seconds
test crates\bevy_gizmos\src\cross.rs - cross::Gizmos<'_,'_,Config>::cross_2d (line 59) has been running for over 60 seconds
test crates\bevy_gizmos\src\curves.rs - curves::Gizmos<'w,'s,Config,Clear>::curve_2d (line 30) has been running for over 60 seconds
test crates\bevy_gizmos\src\curves.rs - curves::Gizmos<'w,'s,Config,Clear>::curve_3d (line 64) has been running for over 60 seconds
It uses all 32 GB of RAM and causes the system to freeze up/soft crash after about 5-10 minutes.
This appears to be fixed in latest nightly. It's not fixed for me in stable or beta. Which is odd as the fix is supposed to be in stable and I can't see anything in the beta/nightly release notes.
With the fix my ci -- doc-test time goes from 354s to 101s 🚀
One tidbit I noticed while testing - bevy_ecs is an exception and falls back to compiling the tests separately. Probably not a big deal as it only costs 20s or so. But if anyone fancies investigating then take a look at rust/src/librustdoc/doctest.rs/run_test.
I suspect that the bevy_ecs doc tests are failing to merge for some reason. This causes a slowdown - maybe 20 seconds or so - but not a big memory spike.
A-Build-SystemRelated to build systems or continuous integrationC-BugAn unexpected or incorrect behaviorS-BlockedThis cannot move forward until something else changes
Activity
[-]bevy_gizmo doc tests hang compute when run locally[/-][+]bevy_gizmos doc tests hang compute when run locally[/+]lynn-lumen commentedon Apr 17, 2024
This issue is related to 'Microsoft® Incremental Linker' - the linker used by the rust compiler on some (most?) windows machines.

The linkers in the following image use 18.8 GB of RAM!
The one thing that sets
bevy_gizmosapart from other crates likebevy_ecsis the increased "usage" of 'Microsoft® Incremental Linker'. Most other doc-tests also use 'Microsoft® Incremental Linker' but it does not use alot of memory there. Instead 'link.exe' uses more memory but remains within acceptable bounds (<1GB).In addition,
bevy_gizmosusesbevy_ecs::system::assert_is_system(system);alot in doc-tests. However, since other crates likebevy_ecsmake excessive use of this assertion aswell and do not have this issue, I am not sure this is the cause of the problem.No single doc-test in particular seems to be responsible for the increased memory usage, as removing any given set of doc-tests results in a decrease in memory usage more or less proportional to the amount of tests removed. Instead, running doc-tests for (very) large projects on windows machines seems to be the issue.
I was unable to find an "in code" fix for this, but there is a discussion on the rust forums that appears to suggest building for a different but compatible target or using
rust-lldas the linker.However, this problem does not seem to be limited to Windows only, as #11034 details a very similar (the same?) issue on a Linux machine.
alice-i-cecile commentedon May 28, 2024
Further discussion on Discord.
General conclusions seem to be the same as above, although it looks like rust-lang/rust#123974 should resolve this.
SkiFire13 commentedon May 28, 2024
In addition to the previous observation,
rustdocdoesn't respect thelinkeroption in Cargo'sconfig.toml, you need to explicitly set it in therustdocflags:This helps reduce the memory usage to 1/2 or 1/3, which is a huge improvement if it leads to avoiding swapping (depends on how much RAM your system has).
Use rust-lld on windows rustdoc in config_fast_builds.toml (#13553)
SkiFire13 commentedon Aug 14, 2024
rust-lang/rust#126245 has been merged, though unfortunately it will be enabled only with the 2024 edition.
roblesch commentedon Aug 20, 2024
Same issue on Fedora 40. Running
cargo cicreates many instances ofldwhich consume all available memory and cause a system crash. Settingrustdocflagsto uselldfixed the problem. The nightly release also runs successfully since it uses rust-lld.Rust version info
config.toml
Use lld for rustdoc on Linux in config_fast_builds.toml (#14839)
BenjaminBrienen commentedon Oct 28, 2024
12th Gen Intel(R) Core(TM) i7-12700H
cargo test --doc
With
cargo run -p ci -- docthere is an entirely different story. A whole bunch of crates pass and then...It uses all 32 GB of RAM and causes the system to freeze up/soft crash after about 5-10 minutes.
greeble-dev commentedon Feb 28, 2025
This appears to be fixed in latest nightly. It's not fixed for me in stable or beta. Which is odd as the fix is supposed to be in stable and I can't see anything in the beta/nightly release notes.
With the fix my
ci -- doc-testtime goes from 354s to 101s 🚀One tidbit I noticed while testing -
bevy_ecsis an exception and falls back to compiling the tests separately. Probably not a big deal as it only costs 20s or so. But if anyone fancies investigating then take a look atrust/src/librustdoc/doctest.rs/run_test.Nightly:
1.87.0-nightly (2f581937e 2025-02-28)Beta:
1.86.0-beta.3 (42212a5c4 2025-02-27)Stable:
1.85.0 (4d91de4e4 2025-02-17)notriddle commentedon Mar 2, 2025
rust-lang/rust#137898
https://users.rust-lang.org/t/question-about-doctest-speedup-in-rust-2024-edition/126431
🤦 🤦 🤦
hukasu commentedon Mar 7, 2025
in 19ee692, with
RUST_TEST_THREADS=4to prevent OOM, so slower than usualcargo test --doc -p bevy_gizmoscargo test --doc -p bevy_gizmos --all-featurescargo test --doc -p bevy_gizmos --releasecargo test --doc -p bevy_gizmos --release --all-featurescargo test --doc -p bevy_gizmosbevy_ecs::system::assert_is_systemcommented outcargo test --doc -p bevy_gizmos --all-featuresbevy_ecs::system::assert_is_systemcommented outhukasu commentedon Mar 7, 2025
one thing to note is that
--jobsis for compiling, to limit testing you use--test-threadsi.e.
cargo test --doc --jobs 4 -- --test-threads 4--test-threadsis passed to the harness so it needs to be after--these envvars also work
greeble-dev commentedon Mar 19, 2025
Appears fixed in Rust 1.85.1: https://releases.rs/docs/1.85.1/. Doc tests for
bevy_gizmosnow take just a second or two and I couldn't see any big memory spikes.I suspect that the
bevy_ecsdoc tests are failing to merge for some reason. This causes a slowdown - maybe 20 seconds or so - but not a big memory spike.alice-i-cecile commentedon Mar 19, 2025
Marking as fixed!
Fix `bevy_ecs` doc tests with `--all-features` (#18424)
Fix `bevy_ecs` doc tests with `--all-features` (#18424)