Skip to content

[5.10][Macros] Cache SourceLocationConverter in ExportedSourceFile #70416

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

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Dec 12, 2023

  • Explanation: We need a SourceLocationConverter every time we create a PluginMessage.Syntax to know the source location of that syntax node within the source file. This means that we needed to re-build the line table of the entire source file multiple times for every macro that we expand. Cache it to improve performance.
  • Scope: Macro expansions
  • Risk: Low
  • Testing: Verified manually that this improves performance of files with many macros
  • Issue: rdar://119047550
  • Reviewer: @bnbarham on [Macros] Cache SourceLocationConverter in ExportedSourceFile #70415

@ahoppen ahoppen requested a review from a team as a code owner December 12, 2023 23:17
@ahoppen
Copy link
Member Author

ahoppen commented Dec 12, 2023

@swift-ci Please test

We need a `SourceLocationConverter` every time we create a `PluginMessage.Syntax` to know the source location of that syntax node within the source file. This means that we needed to re-build the line table of the entire source file multiple times for every macro that we expand. Cache it to improve performance.

rdar://119047550

# Conflicts:
#	lib/ASTGen/Sources/ASTGen/SourceFile.swift
@ahoppen ahoppen force-pushed the ahoppen/5.10/cache-source-loc-converter branch from e5c021e to 3e3b714 Compare December 13, 2023 22:05
@bnbarham
Copy link
Contributor

bnbarham commented Jan 5, 2024

@swift-ci please test

@bnbarham bnbarham merged commit 5b17976 into swiftlang:release/5.10 Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants