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

Stream/Spliterator support for RunList #5942

Merged
merged 4 commits into from
Nov 26, 2021
Merged

Conversation

basil
Copy link
Member

@basil basil commented Nov 22, 2021

RunList, despite its name, is best used as an Iterable rather than a Collection, because operations like Collection#size trigger eager loading of all build records. Despite this, RunList#stream triggers eager loading of all builds, not only because it does not plumb through the corresponding stream() and spliterator() calls to the underlying AbstractLazyLoadRunMap, but also because AbstractLazyLoadRunMap's own entrySet(), keySet(), and values() methods return objects whose Spliterators are sized and therefore incompatible with lazy-loading. This change updates those methods to return Spliterators of unknown size, which do not trigger eager loading. As a bonus, we also update AbstractLazyLoadRunMap#keySet so that its return value's Spliterator has the Spliterator.SORTED characteristic and a corresponding Comparator (which is appropriate because AbstractLazyLoadRunMap implements SortedMap). I have added new tests covering all of this functionality, including verifying lazy-loading behavior with RunLoadCounter. The tests fail without the changes to core/src/main and pass with them.

Proposed changelog entries

  • Improve performance by lazy loading build records from the run list.

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).

@basil basil added the developer Changes which impact plugin developers label Nov 22, 2021
@basil basil added the squash-merge-me Unclean or useless commit history, should be merged only with squash-merge label Nov 22, 2021
@timja timja requested a review from jglick November 22, 2021 19:33
@jglick
Copy link
Member

jglick commented Nov 22, 2021

verifying lazy-loading behavior with RunLoadCounter. The tests fail without the changes to core/src/main and pass with them

These are the magic words!

Co-authored-by: Jesse Glick <jglick@cloudbees.com>
@timja timja added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Nov 25, 2021
Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Looking forward to see how it behaves on performance metrics

@oleg-nenashev oleg-nenashev merged commit 6020f38 into jenkinsci:master Nov 26, 2021
@MarkEWaite MarkEWaite added bug For changelog: Minor bug. Will be listed after features and removed developer Changes which impact plugin developers labels Nov 30, 2021
@basil basil mentioned this pull request May 26, 2022
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For changelog: Minor bug. Will be listed after features ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback squash-merge-me Unclean or useless commit history, should be merged only with squash-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants