Skip to content

fix: avoid O(n^2) algorithm in cleanUpGlobalClassValue #898#910

Open
tometzky wants to merge 1 commit intojenkinsci:masterfrom
tometzky:private/tomost-898-fix-cleanUpGlobalClassValue
Open

fix: avoid O(n^2) algorithm in cleanUpGlobalClassValue #898#910
tometzky wants to merge 1 commit intojenkinsci:masterfrom
tometzky:private/tomost-898-fix-cleanUpGlobalClassValue

Conversation

@tometzky
Copy link

Fixes:

Instead of removing elements from toRemove array while traversing it, which forces rewrite of the whole array each time, create a separate array toRemoveReally with elements that need to be removed.

Testing done

We're running our Jenkins instance on a patched version since March 2025. The instance has more than 10k jobs, almost all created with Groovy code by Jenkins DSL plugin. There was a dramatic drop of Jenkins CPU usage when the plugin was updated with with this change. We rebased the change several times since.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

This is a performance change — it is not clear how to create a test case that demonstrates the change in a reasonable time.

@tometzky tometzky requested a review from a team as a code owner January 30, 2026 16:26
@t3hG04T
Copy link

t3hG04T commented Feb 2, 2026

Sorry to ping @jglick / @dwnusbaum but this seems to have been the way to go for the most recent merge :).

All the coverage warnings are caused by tests not testing the FINEST logger, so coverage is effectively the same as before the change.

As @tometzky mentioned this was "battle tested" on our instance for almost a year at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants