[JENKINS-67344] Poor performance of UpdateSite.getData
#30
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.
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.
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.