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

Improve performance of duplicate code detection #574

Open
Luro02 opened this issue Jul 14, 2024 · 0 comments
Open

Improve performance of duplicate code detection #574

Luro02 opened this issue Jul 14, 2024 · 0 comments
Labels
duplicate-code enhancement New feature or request high-priority Issues that should be solved as soon as possible perf 🏎️💨 performance

Comments

@Luro02
Copy link
Collaborator

Luro02 commented Jul 14, 2024

Description

The check is currently one of the slowest checks (it takes up 13.4% of execution time, second slowest check).

The problematic code sections are:

  1. countStatements (to decide if a code segment is long enough)
  2. Building the occurrences Map (that is related to the implementation of StructuralEqualsVisitor/StructuralHashCodeVisitor).

Here are some ideas to improve performance:

  1. Skip adding more kinds of statements in the occurrences map like CtComment
  2. Only add multiple statements to the occurrences map like CtStatementList, because a single statement would not be enough for a duplicate? What is with things like if (a) b;?
  3. Implement Improve performance of SpoonUtil.resolveConstant #573 which should speed up the isRefactorable method of StructuralEqualsVisitor. It might make sense to build up some cache like with UsesFinder for whether variables are constant/final (I think the whole project would benefit from this).
  4. For StructuralHashCodeVisitor the slowest code is the one that calls StructuralEqualsVisitor#shouldSkip, which should become faster with 3
@Luro02 Luro02 added enhancement New feature or request duplicate-code high-priority Issues that should be solved as soon as possible perf 🏎️💨 performance labels Jul 14, 2024
Luro02 added a commit to Luro02/autograder that referenced this issue Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate-code enhancement New feature or request high-priority Issues that should be solved as soon as possible perf 🏎️💨 performance
Projects
None yet
Development

No branches or pull requests

1 participant