Skip to content

[5.9] Requestify ExportedSourceFile parsing #66057

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

hamishknight
Copy link
Contributor

5.9 cherry-pick of #66029

  • Explanation: Fixes a performance issue where we were parsing syntax trees even if we didn't need to evaluate a macro in that file.
  • Scope: Affects syntax tree parsing when evaluating a macro.
  • Issue: rdar://109283847
  • Risk: Low, the parsing of the syntax tree should be side-effect free, so changing when we parse it shouldn't affect anything.
  • Testing: Added tests to the test suite
  • Reviewer: Ben Barham, Doug Gregor

This matches the behavior of `printAlwaysOnStatsAndTimers`,
which we use in a release build. This fixes the
diverging behavior, and ensures process-stats-dir
can handle comparing deltas between runs where
one of the runs had a 0 counter.
Avoid parsing the syntax tree up-front, and instead
only parse it when required, which happens when either:

1. ASTGen parsing is enabled (currently disabled
   by default)
2. Round trip checking is enabled for a primary
   file (enabled by default in a debug build,
   except when dep scanning or doing an IDE
   operation)
3. We need to evaluate a macro in that file

This change therefore means that we now no longer
need to parse the syntax tree for secondary files
by default unless we specifically need to evaluate
a macro in them (e.g if we need to lookup a member
on a decl with an attached macro). And the same
for primaries in release builds.

rdar://109283847
@hamishknight hamishknight added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.9 labels May 22, 2023
@hamishknight hamishknight requested a review from DougGregor May 22, 2023 17:12
@hamishknight hamishknight requested a review from a team as a code owner May 22, 2023 17:12
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit 433a394 into swiftlang:release/5.9 May 22, 2023
@hamishknight hamishknight deleted the you-shall-not-parse-5.9 branch May 22, 2023 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants