Skip to content

Make libraryClassName relation deterministic under concurrency#1638

Merged
eed3si9n merged 4 commits intosbt:developfrom
lihaoyi:codex/deterministic-libraryclassname
Feb 6, 2026
Merged

Make libraryClassName relation deterministic under concurrency#1638
eed3si9n merged 4 commits intosbt:developfrom
lihaoyi:codex/deterministic-libraryclassname

Conversation

@lihaoyi
Copy link
Copy Markdown
Contributor

@lihaoyi lihaoyi commented Feb 6, 2026

Previously, Zinc could produce nondeterministic analysis output because binaryClassName used put(binary, className) from concurrent externalLibraryDependency callbacks. The final value depended on callback scheduling, so binaryClassName stores one representative class per binary JAR in a concurrent map, but representative selection was non-deterministic.

This PR replaces put with deterministic merge using updateWith, choosing the lexicographically smallest class name for each binary. libraryClassName only needs a stable representative class per binary for lookup/stamp checks; selecting a deterministic representative preserves behavior while removing scheduler dependence. This removes one source of nondeterminism in Zinc analysis serialization and downstream build cache hashes, which was blocking attempts at reproducible builds in Mill (e.g. com-lihaoyi/mill#4642)

Copy link
Copy Markdown
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@lihaoyi
Copy link
Copy Markdown
Contributor Author

lihaoyi commented Feb 6, 2026

@eed3si9n FYI CI looks green

@sideeffffect
Copy link
Copy Markdown

sideeffffect commented Feb 6, 2026

@lihaoyi
Copy link
Copy Markdown
Contributor Author

lihaoyi commented Feb 6, 2026

@sideeffffect it unblocks it, but more work is necessary to get that PR green and mergeable

I think it actually does close it

@eed3si9n eed3si9n merged commit f58b743 into sbt:develop Feb 6, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants