🧑🏫 Make rust-i18n builds deterministic #115
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #103
Sits on top of #114
Notice that non-determinism was already partially addressed by #104 which focused primarily on generating deterministic build outputs & reproducible binaries.
This PR goes one step further and also eliminates sources of non-determinism that happen during runtime. Our application entirely disallows HashMap and HashSet because it uses the system time to seed the random number generator that it uses for hashing and for us this often leads to non-reproducibility problems at runtime and are a frequent source of issues.
We ran into this situation because the
i18n!macro expands to use aHashMap.This PR makes it so that we change every HashMap into a
DeterministicHashMapwhich usessiphashas it's hashing function instead (I chosesiphashso that I didn't have to introduce another dependency to this crate as it's already in use).Notice that this PR doesn't undo the BTreeMap conversion from #104 since I had a hard time generating a deterministic build output on my Windows machine; but with the new
DeterministicHashMapone should be able to convert it into that an potentially regain any (probably minor) performance regressions introduced with the BTreeMap switch.