[BUG]: Color Translation is Costly
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- data-visualization, performance
Research direction
Start with the scatter trace rendering path that calls rgb(color_string) and parse(color_string); compare it with the memoization PR mentioned in the report. Reproduce the 100,000-mark benchmark from the issue, then confirm the optimized run retains rendering behavior and improves median timing.
Written by the indexing model from the issue text.
Description
Description
When rendering a scatter trace, we run rgb(color_string) and parse(color_string) four times for every mark. For the vast majority of scatter charts, this is wasteful re-computation.
Surprisingly, this string parsing appears to be a serious bottleneck. Removing it seems to provide a 2x speed improvement for charts with large numbers of marks.
Screenshots/Video
Steps to reproduce
Run npm start.
In the the console run:
const gd = document.getElementById('graph');
const n = 1e5, x = new Float64Array(n), y = new Float64Array(n);
for (let i = 0; i < n; i++) { x[i] = i; y[i] = Math.sin(i / 500); }
const runs = [];
for (let k = 0; k < 5; k++) {
await Plotly.purge(gd);
const t = performance.now();
await Plotly.newPlot(gd, [{type: 'scatter', mode: 'markers', x, y}],
{width: 900, height: 600}, {displayModeBar: false});
runs.push(+(performance.now() - t).toFixed(1));
}
runs.sort((a, b) => a - b);
console.log('median', runs[2], runs);
See the numbers. Then test with the memoization PR I've put up and notice the lower numbers.
- Dominant language
- JavaScript
- Stars
- 18.3k
- Forks
- 2k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 21
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from plotly/plotly.js
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
chore P3 plotly-internal size: 3 task
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
-
chore P1 plotly-internal size: 1 task
Difficulty 1/5 Under an hour Newbie friendliness 82/100
-
chore P3 plotly-internal size: 1 task
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
All issues in plotly/plotly.js
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
TheOdinProject/curriculum#31423 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
WGBH-MLA/dream-aapb#69 ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
Mintplex-Labs/anything-llm#6490 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
openlayers/ol-cesium#1364 ·