Reduce plotting slider payload for faster figure load#2285
Open
Neal006 wants to merge 1 commit into
Open
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Slider steps re-sent the static rho-grid x-arrays for every spatial trace at every timestep, and timestamp vlines were traces whose x/y were restyled per step. x-arrays are now set once on the traces, and the vlines are layout shapes moved via the relayout part of the slider 'update' method. Figure JSON size: -31% on a 106-step basic_config run (4.2->2.9 MB), -28% on iterhybrid_rampup. No visual change. Addresses part of google-deepmind#553.
Neal006
force-pushed
the
perf/plotly-slider-payload
branch
from
July 14, 2026 05:33
2a96cdf to
e338445
Compare
Author
|
@jcitrin , just checking up on updates regarding the PR approval. If there are any changes that you need me to do, I'm happy to do it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes part of the slider payload bloat described in #553.
Problem
_get_slider_steps()re-sent the full (static) x-array for every spatialtrace on every slider step, and encoded the timestamp indicator as a
per-step trace update instead of a lightweight shape move. Neither the
x-grid nor the vline's y-extent changes between steps — only trace y-values
and the vline's x-position do.
Fix
layout.shape(moved viarelayout) insteadof a full trace re-sent on every step.
updatemethod with separate restyle (yonly)and relayout (
shapes[i].x0/x1) payloads —xarrays are no longerduplicated per step.
updatemenusmode-switch buttons now merge the relayout keys into theirexisting step-0 args instead of duplicating them.
Measured (rampup reference dataset, min of 5 runs)
to_json()time.ncload, not slider assembly — see note below)Build time is largely unaffected because it's dominated by data loading and
trace construction, not slider-step serialization. The measured win is in
payload size and serialize time, which is what actually affects load and
parse time client-side (browser fetch/parse/hold of the HTML figure).
This is one isolated speedup, per your request. A second, larger win is
still on the table: the
updatemenusbuttons currently embed a full copyof both slider-mode step lists (linear time vs. simulation steps), so the
step data is stored ~2x beyond what's in this PR. That's a design choice
(which mode's steps live in the button vs. get rebuilt) I'd like input on
before touching it — happy to open a follow-up issue/PR once we agree on
approach.
Tests
Added
SliderPayloadTestinplotruns_lib_test.py(4 cases): steps carryno
xpayload, timestamp indicator moves via shape relayout, timestampindicator is a shape not a trace, mode buttons still switch slider steps.
Full plotting suite: 236/236 passing.