Skip to content

[libSyntax] Restructure to more closely resemble the SwiftSyntax data structure #35517

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
merged 4 commits into from
Feb 1, 2021

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jan 20, 2021

After trying to use the libSyntax tree in the compiler pipeline, I uncovered several performance bottlenecks in the way libSyntax trees are represented. As a first step towards a more efficient representation of the syntax tree in C++, this PR refactors the current libSyntax tree to more closely resemble the way the tree is represented in SwiftSyntax, which has received more performance-related attention in the recent past.

@ahoppen ahoppen requested review from akyrtzi and rintaro January 20, 2021 18:20
@ahoppen
Copy link
Member Author

ahoppen commented Jan 20, 2021

@swift-ci Please test

@ahoppen ahoppen force-pushed the libsyntax-restructuring branch from 537dce9 to 24fb68e Compare January 20, 2021 18:21
@ahoppen
Copy link
Member Author

ahoppen commented Jan 20, 2021

@swift-ci Please test

@ahoppen ahoppen force-pushed the libsyntax-restructuring branch from 24fb68e to 6ee1c8e Compare January 20, 2021 18:25
@ahoppen
Copy link
Member Author

ahoppen commented Jan 20, 2021

Discovered another clean-up commit that wanted to make it into this PR. Everything should be in now

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 6ee1c8e27d01e466301e092fb1c1bc86dff4447b

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 6ee1c8e27d01e466301e092fb1c1bc86dff4447b

@ahoppen
Copy link
Member Author

ahoppen commented Jan 21, 2021

Failure seems unrelated.

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 6ee1c8e27d01e466301e092fb1c1bc86dff4447b

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 6ee1c8e27d01e466301e092fb1c1bc86dff4447b

@ahoppen
Copy link
Member Author

ahoppen commented Jan 21, 2021

@swift-ci Please test

@rintaro
Copy link
Member

rintaro commented Jan 22, 2021

@swift-ci Please ASAN test

@ahoppen
Copy link
Member Author

ahoppen commented Jan 22, 2021

ASAN test timed out (https://ci.swift.org/job/swift-PR-macos-ASAN-test/192/). Let’s start it again

@swift-ci Please ASAN test

@ahoppen
Copy link
Member Author

ahoppen commented Jan 26, 2021

ASAN build timed out again…

@ahoppen
Copy link
Member Author

ahoppen commented Jan 26, 2021

Giving the ASAN bot a third chance since it seems to be passing lately on other PRs but the point where it stalls doesn’t seem to be directly related to my changes. If it times out again, I’ll need to look into it.

@swift-ci Please ASAN test

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

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

I haven't been able to look into the implementation line by line, but this looks good in general.

@@ -0,0 +1,67 @@
//===--- AbsoluteRawSyntax.h ------------------------------------*- C++ -*-===//
Copy link
Member

Choose a reason for hiding this comment

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

Nit pick:

Suggested change
//===--- AbsoluteRawSyntax.h ------------------------------------*- C++ -*-===//
//===--- AbsoluteRawSyntax.cpp ----------------------------------*- C++ -*-===//

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops. Fixed it.

Instead, reference count the SyntaxData's parent. This has a couple of
advantages:
1. We eliminate a const_cast that was potentially unsafe
2. It more closely resembles the architecture on the Swift side
3. It has the potential to be optimised further if the parent can be
   accessed in an unsafe, non-reference-counted way
@ahoppen ahoppen force-pushed the libsyntax-restructuring branch from aa48999 to 8a6b8b8 Compare January 29, 2021 12:09
@ahoppen
Copy link
Member Author

ahoppen commented Jan 29, 2021

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 8a6b8b8

@ahoppen
Copy link
Member Author

ahoppen commented Jan 29, 2021

@swift-ci Please smoke test linux platform

@ahoppen
Copy link
Member Author

ahoppen commented Jan 29, 2021

@swift-ci Please smoke test linux platform

@ahoppen ahoppen merged commit ce587f0 into swiftlang:main Feb 1, 2021
@ahoppen ahoppen deleted the libsyntax-restructuring branch April 5, 2022 14:47
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.

3 participants