Skip to content
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

Keep track of parsed array changes when parsing===false #9525

Merged
merged 2 commits into from Aug 14, 2021

Conversation

etimberg
Copy link
Member

@etimberg etimberg commented Aug 7, 2021

Resolves #9511

@etimberg etimberg added this to the Version 3.5.1 milestone Aug 7, 2021
@etimberg etimberg requested a review from kurkle August 7, 2021 15:40
@kurkle
Copy link
Member

kurkle commented Aug 8, 2021

I think this would remove the performance gains from parsing: false
The parsed array should equal the data array In that case and a push should not need to update anything. So I think the real bug is somewhere else.

@etimberg
Copy link
Member Author

etimberg commented Aug 8, 2021

This would have a perf impact, though the items inside the array are not changed, just the outer array itself. We could drop the use of syncList when parsing is false and instead make the changes inline. It would mean all of the onData* functions would get a bit more complicated

@kurkle
Copy link
Member

kurkle commented Aug 8, 2021

Would putting that inside an if be enough?

for (const [method, arg1, arg2] of me._syncList) {
me[method](arg1, arg2);
}

@etimberg
Copy link
Member Author

etimberg commented Aug 8, 2021

I don't think that's right because then changes to the elements would never happen so a single push or pop would never change the number of elements. This specific case causes a problem because when applying syncList, the number of elements temporarily grows to 4 but it does so after the data array has shrunk back down to 3

@kurkle
Copy link
Member

kurkle commented Aug 11, 2021

I don't think that's right because then changes to the elements would never happen so a single push or pop would never change the number of elements.

The changes would be applied at the end of _resyncElements, but new elements would always be at end etc, so I don't think that would be an acceptable solution.

if (numData > numMeta) {
me._insertElements(numMeta, numData - numMeta, resetNewElements);
} else if (numData < numMeta) {
me._removeElements(numData, numMeta - numData);
}

I did not realize the actual issue is the delayed multiple syncs that are already applied to the _parsed before _syncList is processed. The performance preserving alternative could be something like (partial):

image

@etimberg
Copy link
Member Author

That solution looks good to me! I will implement that today

@kurkle
Copy link
Member

kurkle commented Aug 13, 2021

That solution looks good to me! I will implement that today

I think you forgot about this :)

@etimberg
Copy link
Member Author

haha I did, will definitely get to it today 😂

Copy link
Member

@kurkle kurkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of hoped you'd pick a better name for the helper, but I don't have any suggestions :)

@etimberg etimberg merged commit 7835973 into chartjs:master Aug 14, 2021
porst17 added a commit to IMAGINARY/climate-crisis-box-models that referenced this pull request Aug 30, 2021
porst17 added a commit to IMAGINARY/climate-crisis-box-models that referenced this pull request Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modifying data with push() and then splice() or shift() fails when parsing is disabled
2 participants