Skip to content

Faster cache#1253

Merged
timja merged 5 commits into
jenkinsci:mainfrom
timja:make-reading-from-cache-faster
Apr 27, 2026
Merged

Faster cache#1253
timja merged 5 commits into
jenkinsci:mainfrom
timja:make-reading-from-cache-faster

Conversation

@timja
Copy link
Copy Markdown
Member

@timja timja commented Apr 27, 2026

Noticed that if the cached build wasn't in memory it was still slow unexpectedly.
Also the XML cache was quite large.

For the 300k node pipeline:

  • 1.8gb project.dat pipeline file
  • 180mb graph cache

To fix it:

  • Switch to JSON, file size is now 53mb
  • Cached version per endpoint, 52mb for all steps, 1mb for tree
  • Serve JSON directly and don't deserialise in Jenkins as no need...

Testing done

Restarted Jenkins
Force cleared cache
Instantly loads now, previously 20 or so seconds.

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

@timja timja requested a review from a team as a code owner April 27, 2026 15:29
@timja timja added the enhancement New feature or request label Apr 27, 2026
@timja timja requested a review from Copilot April 27, 2026 15:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves Pipeline Graph View performance by replacing the legacy XStream/XML disk cache with a smaller JSON cache and enabling direct streaming of cached JSON to HTTP responses (avoiding deserialization on cache hits).

Changes:

  • Replace the on-disk cache format from a single XML file to versioned JSON files split per endpoint (tree vs allSteps).
  • Add “serve from disk” fast paths for tree and allSteps endpoints that stream cached JSON directly.
  • Update DTOs and tests to support Jackson-based JSON round-tripping and verify legacy cache cleanup.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main/java/io/jenkins/plugins/pipelinegraphview/utils/PipelineGraphViewCache.java Switch disk cache to versioned JSON files, add streaming serve methods, and remove legacy XStream persistence.
src/main/java/io/jenkins/plugins/pipelinegraphview/consoleview/PipelineConsoleViewAction.java Serve cached tree/allSteps payloads directly from disk when available.
src/main/java/io/jenkins/plugins/pipelinegraphview/utils/AbstractPipelineNode.java Add a read-back constructor to rebuild TimingInfo from the wire JSON shape.
src/main/java/io/jenkins/plugins/pipelinegraphview/utils/PipelineGraph.java Add Jackson creator support for cached JSON deserialization.
src/main/java/io/jenkins/plugins/pipelinegraphview/utils/PipelineStage.java Add Jackson creator constructor for cached JSON read-back.
src/main/java/io/jenkins/plugins/pipelinegraphview/utils/PipelineStep.java Add Jackson creator constructor matching cached wire JSON timing fields.
src/main/java/io/jenkins/plugins/pipelinegraphview/utils/PipelineStepList.java Add Jackson creator constructor for cached JSON deserialization.
src/main/java/io/jenkins/plugins/pipelinegraphview/utils/PipelineState.java Add @JsonCreator mapping from wire string values to enum constants.
src/test/java/io/jenkins/plugins/pipelinegraphview/utils/PipelineGraphViewCacheTest.java Update tests for JSON cache, streaming serve, disk round-trip, and legacy XML cleanup.
src/test/java/io/jenkins/plugins/pipelinegraphview/livestate/LiveGraphLifecycleTest.java Update completion test to assert the new JSON cache file is written.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return new File(run.getRootDir(), ALL_STEPS_FILE_NAME);
}

/** Test hook: drop in-memory entries so the next call re-runs the supplier. */
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

The comment on invalidateMemory is now misleading: invalidating the in-memory cache causes the next call to re-read from disk first (and only re-run the supplier if the disk file is missing/unreadable). Consider updating the comment to reflect the actual behavior so future tests/debugging don’t assume recomputation.

Suggested change
/** Test hook: drop in-memory entries so the next call re-runs the supplier. */
/**
* Test hook: drop in-memory entries so the next call reloads from disk first.
* The supplier is only re-run if the on-disk cache is missing or unreadable.
*/

Copilot uses AI. Check for mistakes.
lewisbirks and others added 2 commits April 27, 2026 17:49
Signed-off-by: lewisbirks <22620804+lewisbirks@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

timja and others added 2 commits April 27, 2026 21:16
…ineGraphViewCache.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@timja timja enabled auto-merge (squash) April 27, 2026 20:52
@timja timja merged commit d450b6e into jenkinsci:main Apr 27, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants