-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address scattergl performance issue with TypeArrays #5632
Conversation
Address an unavoidable loop phase inside color clean function where it iterates all over the graph points if data used is an ArrayBuffer. This causes graph to have way less performance relative to Array types.
src/components/color/index.js
Outdated
@@ -116,7 +116,7 @@ color.clean = function(container) { | |||
if(!Array.isArray(el0) && el0 && typeof el0 === 'object') { | |||
for(j = 0; j < val.length; j++) color.clean(val[j]); | |||
} | |||
} else if(val && typeof val === 'object') color.clean(val); | |||
} else if(val && typeof val === 'object' && !ArrayBuffer.isView(val)) color.clean(val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's only allow typed arrays here by using the isTypedArray
function.
Lines 8 to 11 in 65f739d
function isTypedArray(a) { | |
return ab.isView(a) && !(a instanceof dv); | |
} | |
exports.isTypedArray = isTypedArray; |
To use that you could require it like this:
var isTypedArray = require('../../lib/array').isTypedArray;
Thanks very much for the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃
Does this PR fully resolve #4401 i.e. the part about line-decimation or just the part about Arrays? |
No. I reopened the issue. |
Address: #4401
Overview of the Pull Request:
Address an unavoidable loop phase inside color clean function where
it iterates all over the graph points if data used is a derivative of a ArrayBuffer.
This causes graph to have way less performance relative to Array types.
Also added a little performance enhancement to calc function. Tell if this is out of scope :)
Simple Demo: here (adapted from @archmoj)
Function performance checkup: