Repository navigation
Fix O(n)^2 bar draw from per-bar getZeroBarDir - #8171
Open
short-int-ali wants to merge 3 commits into
Open
short-int-ali wants to merge 3 commits into
short-int-ali wants to merge 3 commits into
Conversation
Per-bar scans of same-sign calcdata made bar draw quadratic. One call per trace keeps outside zero-label direction and drops that cost to linear. Co-authored-by: i242576 <i242576@isb.nu.edu.pk>
Pick up v4.3.0 so the pull request targets current plotly/plotly.js main. Co-authored-by: i242576 <i242576@isb.nu.edu.pk>
Rename this file and the PR link after the change opens against plotly/plotly.js. Co-authored-by: i242576 <i242576@isb.nu.edu.pk>
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.
Compute
getZeroBarDironce per bar trace instead of once per bar.Closes https://github.com//issues/8157 once this change lands on
plotly/plotly.js(this PR is on the fork; the agent token cannot open a cross-repo PR against upstream).Same-sign traces scanned all calcdata for every bar. That made draw time quadratic. The cached value keeps the same outside-label side for zero-extent bars (#7872).
Tests
test/jasmine/tests/bar_test.jsshould keep zero-value outside labels on the same side as negative barsxvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" npm run test-jasmine -- bar --nowatch --report-specChrome 157.0.0.0 (Linux 0.0.0): Executed 151 of 151 SUCCESS(1.939 s)Also passed locally:
npm run lint,npm run typecheck,npm run test-syntax.Perf
Headless Chromium on this agent host. One warm-up
bars | before (ms) | after (ms) -- | -- | -- 10,000 | 267 | 132 30,000 | 1,604 | 415 60,000 | 5,707 | 702newPlot, then one timednewPlotfor a single all-positive bar trace (same data shape as #8157). Parent tip without the fix vs this branch:Before: 30k→60k grows about 3.6× (quadratic). After: about 1.7× (near linear). At 60k bars, draw time drops from 5,707 ms to 702 ms.
Upstream open
Compare URL for a maintainer or the branch owner:
https://github.com/plotly/plotly.js/compare/main...short-int-ali:plotly.js:cursor/bar-zero-bar-dir-once-da7b?expand=1
After that PR opens, rename
draftlogs/1_fix.mdtodraftlogs/<upstream#>_fix.mdand fix the PR link.No API, schema, mock, or baseline change.
Compute getZeroBarDir once per bar trace instead of once per bar.Closes https://github.com//issues/8157 once this change lands on plotly/plotly.js (this PR is on the fork; the agent token cannot open a cross-repo PR against upstream).
Same-sign traces scanned all calcdata for every bar. That made draw time quadratic. The cached value keeps the same outside-label side for zero-extent bars (#7872).
Tests
Jasmine file: test/jasmine/tests/bar_test.js
Focus: should keep zero-value outside labels on the same side as negative bars
Command: xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" npm run test-jasmine -- bar --nowatch --report-spec
Result: Chrome 157.0.0.0 (Linux 0.0.0): Executed 151 of 151 SUCCESS (1.939 s)
Also passed locally: npm run lint, npm run typecheck, npm run test-syntax.
Perf
Headless Chromium on this agent host. One warm-up newPlot, then one timed newPlot for a single all-positive bar trace (same data shape as #8157). Parent tip without the fix vs this branch:
bars before (ms) after (ms)
10,000 267 132
30,000 1,604 415
60,000 5,707 702
Before: 30k→60k grows about 3.6× (quadratic). After: about 1.7× (near linear). At 60k bars, draw time drops from 5,707 ms to 702 ms.
Upstream open
Compare URL for a maintainer or the branch owner:
https://github.com/plotly/plotly.js/compare/main...short-int-ali:plotly.js:cursor/bar-zero-bar-dir-once-da7b?expand=1
After that PR opens, rename draftlogs/1_fix.md to draftlogs/<upstream#>_fix.md and fix the PR link.
No API, schema, mock, or baseline change.