perf: reduce per-figure Bokeh model overhead in .json.gz files#29
Merged
perf: reduce per-figure Bokeh model overhead in .json.gz files#29
.json.gz files#29Conversation
Two independent optimizations that together cut each per-collection .json.gz file by ~21% on top of the options-list fix: 1. Remove BoxZoomTool per figure (tools='pan,wheel_zoom,reset,save') Each figure previously received the default Bokeh toolbar, which includes a BoxZoomTool together with a BoxAnnotation, BoxInteractionHandles, and AreaVisuals. These are serialized once per figure (~1,800 bytes each). With gridplot merge_tools=True those objects are replicated for every histogram in the collection. Wheel zoom covers the same use-case for 1D histograms. 2. Share nonselection_glyph with glyph on each renderer Bokeh auto-creates a separate nonselection_glyph for every GlyphRenderer (the dim version shown when another element is selected). Since no selection tools are present in the toolbar, this state is never reached. Setting renderer.nonselection_glyph = renderer.glyph makes both attributes reference the same object; Bokeh then serializes it once and emits a short id-reference (~30 bytes) for the second occurrence instead of a full duplicate (~280 bytes on average). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
After #28 this is not quite as impactful. The |
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.
Briefly, what does this PR introduce?
Two independent optimizations that together cut each per-collection
.json.gzfile by ~21% on top of the options-list fix:Remove BoxZoomTool per figure (
tools='pan,wheel_zoom,reset,save) Each figure previously received the default Bokeh toolbar, which includes a BoxZoomTool together with a BoxAnnotation, BoxInteractionHandles, and AreaVisuals. These are serialized once per figure (~1,800 bytes each). With gridplotmerge_tools=Truethose objects are replicated for every histogram in the collection. Wheel zoom covers the same use-case for 1D histograms.Share nonselection_glyph with glyph on each renderer Bokeh auto-creates a separate nonselection_glyph for every GlyphRenderer (the dim version shown when another element is selected). Since no selection tools are present in the toolbar, this state is never reached. Setting
renderer.nonselection_glyph = renderer.glyphmakes both attributes reference the same object; Bokeh then serializes it once and emits a short id-reference (~30 bytes) for the second occurrence instead of a full duplicate (~280 bytes on average).What kind of change does this PR introduce?
Please check if this PR fulfills the following:
Does this PR introduce breaking changes? What changes might users need to make to their code?
No.
Does this PR change default behavior?
No.