forked from higherkindness/rules_scala
-
Notifications
You must be signed in to change notification settings - Fork 5
Fix tasty file non-determinism with sourceroot
argument in multiplex worker and analysis_store.gz
changes
#98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
blainefreestone
merged 2 commits into
lucid-master
from
bfreestone-fixes-source-filepath-determinism-issue
Jul 29, 2025
Merged
Fix tasty file non-determinism with sourceroot
argument in multiplex worker and analysis_store.gz
changes
#98
blainefreestone
merged 2 commits into
lucid-master
from
bfreestone-fixes-source-filepath-determinism-issue
Jul 29, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sourceroot
argument in multiplex workersourceroot
argument in multiplex worker and analysis_store.gz
changes
0e5232a
to
df73027
Compare
jadenPete
requested changes
Jul 25, 2025
src/main/scala/higherkindness/rules_scala/workers/zinc/compile/ZincRunner.scala
Show resolved
Hide resolved
src/main/scala/higherkindness/rules_scala/workers/zinc/compile/ZincRunner.scala
Show resolved
Hide resolved
…order to make the filepath relative in the tasty file this should not invalidate the bazel cache every time because of the path mapping set in the bazel rule config remove sourceroot flag from analysis_store file content (it's not deterministic) add -sourceroot conditionally (it was introduced in Scala 3); change from --sourceroot to -sourceroot !fixup add -sourceroot !fixup add -sourceroot !fixup add -sourceroot add comment explaining change
df73027
to
1c8d0e1
Compare
jadenPete
requested changes
Jul 29, 2025
!fixup add automated
3e7609b
to
0fb2ec3
Compare
jadenPete
approved these changes
Jul 29, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
The content of the
.tasty
file differed between Bazel builds makingclasses.jar
files non-deterministic. Example diff:As you can see, Scala compiler is embedding the source file path. In the first build it was
__sandbox/6/_main/src/jvm...
and in the second it was__sandbox/9/_main/....
.We want this to be machine independent in order for it to be deterministic.
What
Added the
sourceroot
flag to the compilation command with the absolute path of theworkDir
variable. This flag makes the source path outputted in the.tasty
file relative to this. Moreover, this option is filtered out from the analysis_store file before being written as it makes that file non-deterministic.Testing
I pointed Bazel at my local repository with these changes and then built
//src/jvm/com/lucidchart/admin/service/util/config:config
a couple of times. Before the change, the difference, as shown in the example above, was present. After the change, the.tasty
file recorded a relative source filepath and there was no difference between runs.I also tested that this doesn't invalidate the Bazel cache by running it multiple times and getting cache hits. I also investigated the commands with aquery and they were not changing between runs (despite different sandbox worker directories involved).
This determinism build showed a decrease in Scala output mismatches of 294 (from 424 to 130). Almost every single
classes.jar
andanalysis_store.gz
(and text) have been eliminated. There are dozens that still remain, but in quick analysis of a couple of them, they seem to be unrelated to this fix and based on other specific factors. These will have to be fixed individually.Automated Test
The
tests/determinism
directory contains an automated test which builds a dummy target 5 times and compares the TASTy files between runs to ensure determinism. When this test was run locally before the change, it failed. After, it succeeded. The test does take about 5-10 minutes to run because the output base is cleaned between runs and the cache disabled to ensure accurate results.