Skip to content
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

Rename performance improvements #525

Merged
merged 5 commits into from
Nov 19, 2024

Conversation

toinehartman
Copy link
Contributor

@toinehartman toinehartman commented Nov 18, 2024

After testing with large Rascal projects (rascal-core, typepal), some low-hanging performance improvements to the rename refactoring presented themselves. Otherwise, the rename refactoring now mainly spends time in the type checker, which has some performance improvements under development.

This code prevents a stack overflow when renaming names in rascal-core and vastly reduces the time needed to determine overflows of a given definition.

@toinehartman toinehartman added the enhancement New feature or request label Nov 18, 2024
@toinehartman toinehartman self-assigned this Nov 18, 2024
Copy link
Member

@DavyLandman DavyLandman left a comment

Choose a reason for hiding this comment

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

Good that you tackled a few of the causes of slowdown 👍🏼

As a general performance tip:

if (x <- [0..9999], x % 33 == 0) { return x; }

is correct, but written as a loop doesn't lean on the backtracker to do the iteration.

for (x <- [0..9999], x % 33 == 0) { return x; }

will often be faster, or even this (which is slighly slower, but sometimes leads to better readable code):

for (x <- [0..9999]) { if (x % 33 == 0) return x; }

@toinehartman
Copy link
Contributor Author

a loop doesn't lean on the backtracker to do the iteration

@DavyLandman Thanks, will keep that in mind and apply it when refactoring the renaming code later on.

Copy link

sonarcloud bot commented Nov 18, 2024

@toinehartman toinehartman merged commit 1a95f6c into main Nov 19, 2024
13 checks passed
@toinehartman toinehartman deleted the fix/rename-refactoring/low-hanging-performance branch November 19, 2024 10:24
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
None yet
Development

Successfully merging this pull request may close these issues.

2 participants