rust non-determinism

Bernhard M. Wiedemann bernhardout at lsmod.de
Tue Aug 6 07:06:22 UTC 2024


On 05/08/2024 18.37, John Gilmore wrote:
> Bernhard M. Wiedemann <bernhardout at lsmod.de> wrote:
>> => https://github.com/rust-lang/rust/issues/128675
> 
> Two Rustc developers closed it within 8 hours as "already completed",
> even though it isn't.
> 
> They also said "CGU partitioning is very deliberately designed to be
> deterministic."  Implying that therefore there is no bug, because design
> and implementation are the same thing?
> 
> Rust has 36 open reproducibility bugs (not including this closed one).
> It'd be worth seeing what other ones they closed unfixed.

my workaround for openSUSE at
https://github.com/Firstyear/cargo-packaging/pull/11 was also rejected.

It is a complex ecosystem. pop-launcher pulls in 258 modules and many 
have their own build.rs that could break reproducibility. There is 
`crate` and `just` as build tools that can cause issues, too.
In the past there were also LLVM bugs that caused non-determinism.

So it is often hard to pin-point the source of non-determinism with 
precision and confidence.

And it does not help that rust HashMaps have non-deterministic order by 
default.


I'm getting closer to think that llvm's LTO and rust's codegen-units=16 
might be determistic by themselves, but (similar to PGO[1]) amplify 
other sources of non-determinism which makes it harder to debug.

If that is indeed the case, we can disable them during debugging r-b but 
leave them on when the package-specific issue is fixed.


Ciao
Bernhard M.

[1] https://github.com/bmwiedemann/theunreproduciblepackage/tree/master/pgo


More information about the rb-general mailing list