Optimize issue lookup in UpgradeDependencies task#50966
Closed
lucasrmendonca7 wants to merge 2 commits into
Closed
Optimize issue lookup in UpgradeDependencies task#50966lucasrmendonca7 wants to merge 2 commits into
lucasrmendonca7 wants to merge 2 commits into
Conversation
Replace the nested loop linear search (O(N*M)) with a HashMap-based lookup (O(N+M)). This significantly reduces the execution time for the dependency upgrade process by caching library information and performing direct lookups. Signed-off-by: lucasrmendonca7 <lucas80002@gmail.com>
Signed-off-by: lucasrmendonca7 <lucas80002@gmail.com>
lucasrmendonca7
force-pushed
the
perf/update-dependencies-data-structure
branch
from
July 16, 2026 20:12
8415773 to
dea5cb9
Compare
Member
|
Thanks but we don't need to optimize this. The issue you described is impactful with a large number of issues and irrelevant for what this part of the code handles. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace linear search with HashMap lookup in
UpgradeDependencies.findExistingUpgradeIssueThis PR refactors the issue lookup logic in
UpgradeDependenciesto use aHashMapinstead of a linear search, reducing the algorithmic complexity from O(N * M) to O(N + M).Problem
The method
findExistingUpgradeIssueiterates through the entire list of existing issues for each upgrade, resulting in O(N * M) complexity where N is the number of upgrades and M is the number of existing issues. While functionally correct, this pattern doesn't scale well and doesn't clearly express the intent of finding an issue by its title.Solution
HashMap<String, Issue>keyed by normalized title, at a cost of O(M).findExistingUpgradeIssuewith a directMap.get()call, reducing the per-upgrade lookup from O(M) to O(1).Map<String, Issue>instead ofList<Issue>.Why this is better
Testing
All existing tests in
buildSrcpass successfully.