Skip to content

[BatchMode] Fix non-portable test that relies on std::shuffle implementation. #15191

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

Conversation

graydon
Copy link
Contributor

@graydon graydon commented Mar 12, 2018

A sad little saga of random shuffles: in #15091 I changed the algorithm that the test-only -driver-batch-seed mode uses to randomly assign files to batches, to make that algorithm preserve the invariant that batches are a subsequence of the top-level input sequence.

The change made the driver shuffle the batch-selection order and not-shuffle (as it previously did) the file-assignment order. In so doing, I broke one of the existing tests that was supposed to be insensitive to randomization. The test tried to be randomization-insensitive by being insensitive to file-assignment order, but it accidentally remained sensitive to batch-selection order.

As it happens, this didn't break on my workstation because the sequence of batches wired-in to the test was a subsequence of the sequence of batches assigned by std::shuffle when running on libcxx. But only on a libcxx implementation. It turns out that std::shuffle isn't especially strictly specified, and libstdc++ doesn't use the same shuffling algorithm, so the test breaks on Fedora.

@graydon graydon requested a review from davezarzycki March 12, 2018 22:09
@graydon
Copy link
Contributor Author

graydon commented Mar 12, 2018

@swift-ci please smoke test

@graydon
Copy link
Contributor Author

graydon commented Mar 12, 2018

@davezarzycki I'd appreciate if you would be willing run this variant through to confirm that it works for you; I think it's not got any order-dependence in it anymore!

@davezarzycki
Copy link
Contributor

I've downloaded the new test file and it appears to fix the test suite.

@graydon
Copy link
Contributor Author

graydon commented Mar 13, 2018

Great, thanks!

@graydon graydon merged commit 23d6588 into swiftlang:master Mar 13, 2018
@jrose-apple
Copy link
Contributor

Hm, I guess we no longer test that it's actually shuffling, but since the shuffling itself is only for testing purposes maybe that's okay?

@graydon
Copy link
Contributor Author

graydon commented Mar 13, 2018

@jrose-apple yeah, we're still testing the same sign-of-shuffle: the SEED1-NOT: and SEED2-NOT: lines check that the files aren't added in 1, 2, 3 order.

The thing it accidentally got coupled to was actually a part of the exactly-matched input that didn't look shuffled, it just happened to have batches 0, 1, 2, and 3 in order as a subsequence of the batches added-to on libcxx. The shuffled-parts were already regexp wildcard'ed out.

@davidungar
Copy link
Contributor

davidungar commented Mar 13, 2018 via email

@davidungar
Copy link
Contributor

davidungar commented Mar 13, 2018 via email

@graydon
Copy link
Contributor Author

graydon commented Mar 13, 2018

@davidungar not sure what you mean by a combinatorial test. The test that broke here is one that runs the compiler 3 times, shuffling the partition in the latter 2 executions with different seeds.

The test contains checks (intentionally) that the latter two runs do shuffle the partition: that the resulting shuffled batches do not contain the unshuffled 0-seed partition "file-1.swift, file-2.swift, file-3.swift".

The test also contained checks (accidentally) that the resulting shuffled batches added files to their batches in a specific order (or, well, an order that had a specific subsequence). This was a mistake, over-specifying behaviour to that of a specific implementation of std::shuffle, which I have now removed.

@davidungar
Copy link
Contributor

davidungar commented Mar 13, 2018 via email

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.

4 participants