Skip to content

Cache resolved data in Manage Old Data page#26361

Open
subwaycookiecrunch wants to merge 1 commit intojenkinsci:masterfrom
subwaycookiecrunch:fix-old-data-monitor-performance
Open

Cache resolved data in Manage Old Data page#26361
subwaycookiecrunch wants to merge 1 commit intojenkinsci:masterfrom
subwaycookiecrunch:fix-old-data-monitor-performance

Conversation

@subwaycookiecrunch
Copy link

@subwaycookiecrunch subwaycookiecrunch commented Feb 24, 2026

Fixes #16843 (JENKINS-76278)

manage.jelly calls it.data three times — once to scan flags, once for the version table, once for the unreadable data table. getData() iterates every entry and resolves each RunSaveableReference through Run.fromExternalizableId(), which does a job lookup + build-by-number lookup. With 30k+ entries that's roughly 90k lookups for a single page load, enough to peg the CPU for 40+ minutes.

Stashed the result in a Jelly variable so resolution happens once. Also capped the table at 1000 rows since rendering 30k <tr> elements locks up the browser regardless of backend speed. The cap is display-only — upgrade and discard still work on the full data set.

Testing done

Added managePageRendering() to OldDataMonitorTest — registers old data on a build, confirms it shows up in getData(), then loads the manage page via WebClient and verifies it renders without error.

Existing tests (memory, slowDiscard, unlocatableRun) continue to pass since the Java side is unchanged.

Screenshots (UI changes only)

N/A, no visual design changes, just a display cap with a warning message when entry count exceeds 1000.

Before

After

Proposed changelog entries

  • Cache resolved data on the Manage Old Data page to avoid repeated expensive lookups with large entry counts

Proposed changelog category

/label bug

Proposed upgrade guidelines

N/A

Submitter checklist

  • The issue, if it exists, is well-described.
  • The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see examples). Fill in the Proposed upgrade guidelines section only if there are breaking changes or changes that may require extra steps from users during upgrade.
  • There is automated testing or an explanation as to why this change has no tests.
  • New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadocs, as appropriate.
  • New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO"), if applicable.
  • UI changes do not introduce regressions when enforcing the current default rules of Content Security Policy Plugin. In particular, new or substantially changed JavaScript is not defined inline and does not call eval to ease future introduction of Content Security Policy (CSP) directives (see documentation).
  • For dependency updates, there are links to external changelogs and, if possible, full differentials.
  • For new APIs and extension points, there is a link to at least one consumer.

Desired reviewers

@basil @MarkEWaite

@comment-ops-bot comment-ops-bot bot added the bug For changelog: Minor bug. Will be listed after features label Feb 24, 2026
Copy link

@andreahlert andreahlert left a comment

Choose a reason for hiding this comment

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

LGTM

@andreahlert
Copy link

@subwaycookiecrunch The description says "Fixes #16843" but the title references JENKINS-76278. Which issue does this actually fix? Please align the "Fixes" line with the correct issue.

@timja timja changed the title [JENKINS-76278] Cache resolved data in Manage Old Data page Cache resolved data in Manage Old Data page Mar 3, 2026
<j:if test="${item.value.extra!=null and item.value==''}">
<j:set var="count" value="${0}"/>
<j:forEach var="item" items="${allData.entrySet()}">
<j:if test="${item.value.extra!=null and item.value=='' and count &lt; maxDisplay}">
Copy link
Member

Choose a reason for hiding this comment

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

why do you need to encode this? you use a > elsewhere on the page?

Suggested change
<j:if test="${item.value.extra!=null and item.value=='' and count &lt; maxDisplay}">
<j:if test="${item.value.extra!=null and item.value=='' and count < maxDisplay}">

Choose a reason for hiding this comment

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

@timja, I think it might be because in XML, inside an attribute value, < is usually escaped as < so the parser doesn’t treat it as the start of a tag, while > typically doesn’t need escaping. So the < here might be intentional, and using > elsewhere on the page doesn’t necessarily contradict that. I could be wrong; if in Jelly it’s safe to use a raw < in the attribute, then simplifying makes sense.

Copy link
Member

Choose a reason for hiding this comment

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

I'd try it and if it doesn't work its fine but better to try first

Copy link
Author

Choose a reason for hiding this comment

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

@timja @andreahlert right, raw < does break the XML parser in attribute values so that won't work. I just flipped the comparison to maxDisplay > count instead , no entity needed and it's consistent with how I already wrote the check on line 52. Pushed.

@subwaycookiecrunch subwaycookiecrunch force-pushed the fix-old-data-monitor-performance branch from 948133c to cdd68c6 Compare March 4, 2026 12:43
@subwaycookiecrunch
Copy link
Author

@andreahlert yeah sorry about that, #16843 is the GitHub mirror of JENKINS-76278 , they're the same issue. I'll clean up the description so it's not confusing. Thanks for catching it.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JENKINS-76278] High amount of Manage Old Data causes high CPU

3 participants