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

[JENKINS-67344] Poor performance of UpdateSite.getData #30

Merged
merged 3 commits into from
Apr 25, 2024

Conversation

basil
Copy link
Member

@basil basil commented Apr 25, 2024

Profiling showed that while regex compilation was indeed a problem, it wasn't the bottleneck. The real bottleneck was repeatedly copying a massive string just to search a few characters in it. Fixed by copying just the portion of the string we need to search. See flame graphs before and after.

before

after

Next steps

If merged and deployed to Jenkins users successfully, I will try to propose this upstream at https://github.com/kordamp/json-lib.

Testing done

Tested against the real Jenkins Update Center JSON file; execution time went from about 8 seconds to about 0.4 seconds consistently. Tested interactively in Jenkins as well; the "Refresh" button on the plugin update page is now bounded by download time, not CPU time, and for me goes from about 12 seconds to about 5 seconds.

@basil basil requested a review from jglick April 25, 2024 19:38
@basil basil added the bug label Apr 25, 2024
@basil basil mentioned this pull request Apr 25, 2024
@basil basil merged commit 2fff67d into jenkinsci:master Apr 25, 2024
13 checks passed
@basil
Copy link
Member Author

basil commented Apr 25, 2024

Oops, I pushed this to master before I had intended. In any case, happy to respond to any review after the fact.

@basil
Copy link
Member Author

basil commented Apr 25, 2024

(The version I pushed to master has commit f5aa4ac, which is what I had intended to update this PR with, but pushed to the wrong branch)

@MarkEWaite
Copy link

Change looks good to me.

@jglick
Copy link
Member

jglick commented Apr 26, 2024

So 7a7f18e...f5aa4ac to avoid

public boolean matches(String pattern) {
String str = this.mySource.substring(this.myIndex);
return RegexpUtils.getMatcher(pattern).matches(str);
}
which is going to be inefficient (especially if the document is not strictly ISO-8859-1 as in the case of the UC). Thanks for fixing this long-standing problem!

@basil basil deleted the JENKINS-67344 branch April 30, 2024 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants