Skip to content

Slight performance improvements to Source Positions recipe - #2821

Merged
sambsnyd merged 1 commit into
openrewrite:mainfrom
BoykoAlex:perf-positions
Feb 10, 2023
Merged

sambsnyd merged 1 commit into
openrewrite:mainfrom
BoykoAlex:perf-positions

Conversation

@BoykoAlex

@BoykoAlex BoykoAlex commented Feb 9, 2023 •

Copy link
Copy Markdown
Contributor

Light performance improvements: ~15%

Was thinking about includeMarkers boolean option. If false won't attempt to visit Markers consequently no positions assigned to markers. Yields another 10%. However, compared to overall running time of the recipe felt like it is not worth it.

@BoykoAlex
BoykoAlex marked this pull request as draft February 9, 2023 17:00
@BoykoAlex
BoykoAlex marked this pull request as ready for review February 9, 2023 17:35

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks like it would result in nothing being added to the buffer. Have you tested that this change works as intended?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This subclass of PrintOutputCapture doesn't really care about proper printing. Content of the out StringBuilder is of no importance as far as I remember. The PositionPrintOutputCapture is only to track current offset, line and column of an AST node. I have sanity tested this stuff manually. Markers in the IDE show up and locations seem correct. However, I have just noticed that UpdateSourcePositionsTest is disabled. Perhaps, I'll see if can be enabled again.

@timtebeek timtebeek added the enhancement New feature or request label Feb 9, 2023
@BoykoAlex

Copy link
Copy Markdown
Contributor Author

@sambsnyd I have enabled the unit tests for positions recipe. I understand why it got disabled. Every time parsing of the white space changes or a new node introduce these tests start to fail. I've tried to simplify the tests in hope for them to be less annoying in the future: only test positions of identifier nodes.
I ran tests with previous version of the positions recipe and the current both passed.

@sambsnyd

sambsnyd commented Feb 10, 2023 •

Copy link
Copy Markdown
Member

Thanks @BoykoAlex , appreciate that you got the test working as well

@sambsnyd sambsnyd added this to the 7.36.0 milestone Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants