swift-syntax
swift-syntax copied to clipboard
Improve SyntaxRewriter performance for operator folding
Running operator folding on MovieSwiftUI takes as long as parsing. That really shouldn’t be the case. Running with Instruments shows that we spend the majority of time in memory-related operations.
The first steps to take would be:
- Add an
arena
parameter to all the syntax node initializers - Add an
arena
parameter toSyntaxRewriter
- Construct all nodes in
SyntaxRewriter
and operator folding in that arena - Investigate where else
SyntaxRewriter
is causing memory allocations and try to eliminate them
Attached is a WIP diff where I started to eliminate some of the memory allocations by SyntaxRewriter
but I stopped once I realized that we’d need to modify the initializers of all syntax nodes.