Repository navigation
Compare every variant of a multi-variant source, deterministically - #39
Open
anakanemison wants to merge 1 commit into
Open
anakanemison wants to merge 1 commit into
anakanemison wants to merge 1 commit into
Conversation
_union_tus pooled library TUs into one source-keyed map with dict.setdefault while iterating a set of target names. When one source is compiled into several libraries with different flags (a full and a lite build of the same file, a hardened variant), only one variant per side was compared, and which one depended on set iteration order, that is, on PYTHONHASHSEED. The verdict was not reproducible. Measured in any2bazel-lab: the same MySQL Server models gave 4,715 to 4,817 errors over 10 hash seeds, a different error set each time, and the final models of a Blender migration converged under 2 of 8 seeds. Projects without multi-variant sources were unaffected (50 recorded verdicts identical under 20 seeds). Pooling now keeps every distinct variant per source, visiting targets in sorted order. Each CMake variant is compared with its best-matching Bazel variant: fewest errors, then warnings, then the smallest symmetric difference of the two TUs' define, flag and include sets, then a stable text order. Every CMake variant must be matched by some Bazel variant and nothing is suppressed; an extra Bazel-only variant is tolerated, like an extra Bazel flag. The distance term keeps a tie from choosing a variant that only adds flags (-w, -Wno-error=...) over an exact one. A source with one variant per side takes exactly the old path, and on every single-variant verdict the lab has recorded, the result is unchanged. Executables and the opt-in test union use the same pairing, and the Java source union is visited in sorted order too. One consequence for source_map users: a token that collapses several CMake TUs (an AUTOMOC bundle, say) now yields one comparison, and so possibly one discrepancy, per distinct CMake TU, so the worklist can grow. The source_map comment in config.py says so. In the lab's later QGIS run with this change, the differ gave the same verdict under three seeds. Lab-Proposal: P14 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
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.
Part 4 of 23 of a stacked series (tracking issue: #35). Based on
U03-target-map-renames-one-place, the previous part: review and merge that first.Kind: fix. Lab proposal: P14.
What the migration runs showed
The verdict on qgis depended on
PYTHONHASHSEEDwhen a source compiles in several variants. The fixed differ gives one verdict under three seeds (run 089).The change
_union_tus pooled library TUs into one source-keyed map with
dict.setdefault while iterating a set of target names. When one source is
compiled into several libraries with different flags (a full and a lite
build of the same file, a hardened variant), only one variant per side was
compared, and which one depended on set iteration order, that is, on
PYTHONHASHSEED. The verdict was not reproducible.
Measured in any2bazel-lab: the same MySQL Server models gave 4,715 to 4,817
errors over 10 hash seeds, a different error set each time, and the final
models of a Blender migration converged under 2 of 8 seeds. Projects
without multi-variant sources were unaffected (50 recorded verdicts
identical under 20 seeds).
Pooling now keeps every distinct variant per source, visiting targets in
sorted order. Each CMake variant is compared with its best-matching Bazel
variant: fewest errors, then warnings, then the smallest symmetric
difference of the two TUs' define, flag and include sets, then a stable
text order. Every CMake variant must be matched by some Bazel variant and
nothing is suppressed; an extra Bazel-only variant is tolerated, like an
extra Bazel flag. The distance term keeps a tie from choosing a variant
that only adds flags (-w, -Wno-error=...) over an exact one. A source with
one variant per side takes exactly the old path, and on every
single-variant verdict the lab has recorded, the result is unchanged.
Executables and the opt-in test union use the same pairing, and the Java
source union is visited in sorted order too.
One consequence for source_map users: a token that collapses several CMake
TUs (an AUTOMOC bundle, say) now yields one comparison, and so possibly one
discrepancy, per distinct CMake TU, so the worklist can grow. The
source_map comment in config.py says so.
In the lab's later QGIS run with this change, the differ gave the same
verdict under three seeds.
Testing
pytest tests/at this commit: 144 passed (130 onmain).🤖 Generated with Claude Code