Skip to content
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

Allow to prefetch debug info to mitigate spurious failures in the CI #3517

Conversation

WojciechMazur
Copy link
Contributor

Loading debug info can take almost 1s on MacOS M1 for a simple tests (1 test in sandbox) or even 3s for our current unit tests. This can influence the assertions that expect code to finish withing some time interval, especially in multithreading builds.
Mitigate this issue by introducing env var PREFETCH_DEBUG_INFO=1 to ensure that debug info would be parsed before starting to execute tests

// Prefetch the debug metadata before the actual tests do start
if (LinktimeInfo.hasDebugMetadata) {
val shouldPrefetch =
sys.env.get("PREFETCH_DEBUG_INFO").exists(v => v.isEmpty() || v == "1")
Copy link
Member

Choose a reason for hiding this comment

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

Should env be prefixed with e.g. SN_TEST or SCALA_NATIVE_TEST ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could be prefixed, but don't you think it is too verbose? When it's added in CI it's fine, but when testing locally it gives a lot of opportunities for typos. On the other hand the short version breaks naming consistency. What's your opinion on that?

Copy link
Member

Choose a reason for hiding this comment

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

If this was private to this repo, then it would be okay, but since this is a public API feature it should follow existing convention. Verbosity is annoying but hopefully we choose the right default and most user should never need to configure it.

Copy link
Member

Choose a reason for hiding this comment

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

I know Denys always wanted it spelled out SCALA_NATIVE_ perhaps because so many C libs use a 2 character namespacing like tf_ for Tensorflow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added the SCALANATIVE_TEST_ prefix to allign it with other env variables (eg. SCALANATIVE_GC) and added TEST to point out it's only applied when testing

Copy link
Member

@tanishiking tanishiking left a comment

Choose a reason for hiding this comment

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

Loading debug info can take almost 1s on MacOS M1 for a simple tests (1 test in sandbox) or even 3s for our current unit tests. This can influence the assertions that expect code to finish withing some time interval, especially in multithreading builds.

Nice catch! I thought it was acceptable to take 1s to load debug info when throwing an exception, but I hadn't thought about the test cases where exceptions are expected.

Regarding the env var prefix, I personally prefer ScalaNative having some kind of prefix so that the env var name doesn't crash with others, but not a strong opinion

@WojciechMazur WojciechMazur merged commit 3154483 into scala-native:main Oct 3, 2023
76 checks passed
@WojciechMazur WojciechMazur deleted the testing-infra/allow-to-prefetch-debuginfo branch October 3, 2023 16:26
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.

None yet

4 participants