This is an archive of the discontinued LLVM Phabricator instance.

[lit] Add "early_tests" config option
ClosedPublic

Authored by davezarzycki on Feb 12 2021, 5:00 AM.

Details

Summary

With enough cores, the slowest tests can significantly change the total testing time if they happen to run late. With this change, a test suite can improve performance (for high-end systems) by listing just a few of the slowest tests up front.

Diff Detail

Event Timeline

davezarzycki requested review of this revision.Feb 12 2021, 5:00 AM
davezarzycki created this revision.

Seems useful.

For consistency with the existing option, shouldn't it be named early_tests?

Needs documentation and tests.

I can rename the variable if you want. That being said, this proposal is a mere refinement to the "run early" feature. And unless I'm missing something, the "run early" feature lacks documentation and tests. Are you asking me to fix that? I'd also like to point out that timing tests are surprisingly difficult to write if one cares about not being sensitive to the performance of the underlying hardware or how busy (or not) the machine is.

I can rename the variable if you want.

Thanks. I'm open to discussion, but I think consistency is important. Also, looking at the comments for isEarlyTest, it looks like the original feature was meant to be useful beyond just slow tests, so the name is more general.

That being said, this proposal is a mere refinement to the "run early" feature. And unless I'm missing something, the "run early" feature lacks documentation and tests.

That's unfortunate.

Are you asking me to fix that?

If you're willing, that would be great and probably not much more work. But I'm only asking you to document and test your changes.

I'd also like to point out that timing tests are surprisingly difficult to write if one cares about not being sensitive to the performance of the underlying hardware or how busy (or not) the machine is.

Many of lit's tests execute with -j1 for deterministic output. In this case, we'd need an example test suite whose tests run in a different order when some are configured as early tests. Does that seem reasonable?

Thanks for working on this feature. I have a downstream test suite that I think will benefit.

llvm/utils/lit/lit/Test.py
407

It looks like this requires the new config to use / as a path separator regardless of the platform. This decision should probably be consistent with however excludes works, but I haven't looked into that. In any case, please mention this decision in the user documentation.

I think I have addressed all of the feedback to date. Thank you @jdenny

Please note, the / separator is harmless and we need some kind of separator. It doesn't affect any filesystem APIs, just test sorting.

jdenny accepted this revision.Feb 13 2021, 11:31 AM

LGTM except please update the title for the new name.

This revision is now accepted and ready to land.Feb 13 2021, 11:31 AM
davezarzycki retitled this revision from [lit] Add "slowest_tests" config option to [lit] Add "early_tests" config option.Feb 14 2021, 3:42 AM

I'd like to take a look at this, but I have too many things on my plate today. I can probably make time tomorrow or Wednesday though, if you're happy to hold off until then?

I'd like to take a look at this, but I have too many things on my plate today. I can probably make time tomorrow or Wednesday though, if you're happy to hold off until then?

That's fine. No rush. I'll assume that unless someone wants a change by next weekend, then the commit is ready to land.

Essentially looks good, aside from a few small things.

It would be nice if this option could be configured within the test itself, perhaps in a similar manner to how REQUIRES etc works. This would allow the test properties (i.e. something like "I'm slow") to be encoded within the test itself. It would also be nice if there were a lit command-line option to achieve the same thing - in some cases, people might want to see specific tests run early (because for example they are more likely to fail, so want to be observed early) without wanting to modify the testsuite. I'm happy for these to be separate patches.

llvm/utils/lit/lit/TestingConfig.py
130

There might be other reasons to run specific tests first (e.g. ones that are more likely to fail), so make this comment less specific.

llvm/utils/lit/tests/Inputs/early-tests/lit.cfg
8

I think we need to exercise the '/' separator behaviour as part of this test somehow.

llvm/utils/lit/tests/early-tests.py
2

Something I've been encouraging in newer tests is to use ## for comments (or equivalent e.g. ;;) to make true comments stand out from lit and FileCheck directives.

I believe I have addressed all of the feedback to date.

As to having a "run early" hint within the test files, I did look into that. For better and for worse, lit parses the test files as a part of the execution path, which is long after lit has sorted the tests. Changing this would be a nontrivial redesign of lit and it would put the parsing of the test suite (as opposed to mere discovery and sorting) on the critical path before tests are run. This approach is simpler and far less controversial.

davezarzycki marked 3 inline comments as done.Feb 16 2021, 3:38 AM
jhenderson accepted this revision.Feb 16 2021, 4:03 AM

Looks good. The command-line option might still be nice, if it's viable, but it can be separate.

This revision was landed with ongoing or failed builds.Feb 17 2021, 3:33 AM
This revision was automatically updated to reflect the committed changes.