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-65308] Improve performance of Jenkins#trimLabels() #5402

Merged
merged 3 commits into from
Apr 11, 2021
Merged

[JENKINS-65308] Improve performance of Jenkins#trimLabels() #5402

merged 3 commits into from
Apr 11, 2021

Conversation

res0nance
Copy link
Contributor

@res0nance res0nance commented Apr 8, 2021

See JENKINS-65308.

Instead of checking every node, when possible simply return fast instead of calculating the cached value.

This does alter its behaviour somewhat but not to the point its contracts are changed.

Tested with a simple test

@Before
    public void bef() throws Exception {
        for (int i = 0; i < 5; ++i) {
            j.createOnlineSlave(new LabelAtom("node" + i));
        }
    }

    @Test
    public void testTrim() {
        final long start = System.currentTimeMillis();
        for (int i = 0; i < 100000; ++i) {
            j.jenkins.trimLabels();
        }
        System.out.println("Test took: " + (System.currentTimeMillis()-start));
    }

New code Vs old time in ms:

Test Number New Old
1 1561 2253
2 1474 1998
3 1240 2185

Proposed changelog entries

  • Entry 1: JENKINS-65308, Reduce queue-lock contention when creating or deleting nodes.

Proposed upgrade guidelines

N/A

Submitter checklist

  • (If applicable) Jira issue is well described
  • Changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developer, depending on the change). Examples
    • Fill-in the Proposed changelog entries section only if there are breaking changes or other changes which may require extra steps from users during the upgrade
  • Appropriate autotests or explanation to why this change has no tests
  • For dependency updates: links to external changelogs and, if possible, full diffs

Desired reviewers

@mention

Maintainer checklist

Before the changes are marked as ready-for-merge:

  • There are at least 2 approvals for the pull request and no outstanding requests for change
  • Conversations in the pull request are over OR it is explicit that a reviewer does not block the change
  • Changelog entries in the PR title and/or Proposed changelog entries are correct
  • Proper changelog labels are set so that the changelog can be generated automatically
  • If the change needs additional upgrade steps from users, upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the PR title. (example)
  • If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).

@res0nance res0nance added the rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted label Apr 8, 2021
core/src/main/java/hudson/model/Label.java Outdated Show resolved Hide resolved
@MarkEWaite
Copy link
Contributor

This PR is now ready for merge. We will merge it after approximately 24 hours if there is no negative feedback.

@MarkEWaite MarkEWaite added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Apr 10, 2021
@MarkEWaite MarkEWaite merged commit 901bf54 into jenkinsci:master Apr 11, 2021
@res0nance res0nance deleted the JENKINS-65308 branch April 12, 2021 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants