Faster cache#1253
Conversation
There was a problem hiding this comment.
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
treeandallStepsendpoints 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. */ |
There was a problem hiding this comment.
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.
| /** 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. | |
| */ |
Signed-off-by: lewisbirks <22620804+lewisbirks@users.noreply.github.com>
There was a problem hiding this comment.
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.
…ineGraphViewCache.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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:
To fix it:
Testing done
Restarted Jenkins
Force cleared cache
Instantly loads now, previously 20 or so seconds.
Submitter checklist