-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Performance issue Find with more than 500 records #609
Comments
This is interesting, could you verify that the items added to the store this way are still reactive ? |
I'm surprised that it's still doing mutations one at a time. I thought we addressed that. If not then we definitely need to get this in place. Thanks for the catch. |
@marshallswain I think we talked about it but never realy implemented it. It should stay reactive as the keyedById and ids properties are reassigned instead of adding properties on them. |
When I add a new record or update via Postman, I see it appearing on my frontend |
The only thing is that when adding or updating one record it is less optimal now , but is not noticable. |
When running a second find on the same table, the frontend also freezes. (it goes then in updateItems)
UPDATE -> not a good solution, because it kills reactivity |
Spread has been optimized in browser engines and should be at least as fast as Object.assign
A workaround could be to detect if there is only one item in the response and update the state accordingly.
This is a possibility, it depends if Vue is smart enough to detect that the items didn't change but if not, it might trigger components re-rendering.
I think we should apply the same logic for the Same logic can be applied to the |
In fact Object.assign is different than spread because it add the properties of the other object instead of destructuring the two and merging all the properties. In the
But I think that it would be much simpler, less error prone and more compatible with Vue 2/3 if we'd just merge them with a spread and then calling This probably means a loss in performance due to the class instantiation but it would be compensated by not looping manually over all the props in the |
We could also squeeze a bit more performance when checking for existing items. |
You are correct. That would be a good improvement, although I believe
chromium internally optimizes that code to use a map, I’ve not read
anything like that about other browsers.
On August 12, 2021, GitHub ***@***.***> wrote:
We could also squeeze a bit more performance when checking for
existing items.
We could check if the id has an item in the keyedByIds object instead
of using includes on the ids Array, unless there is a case where an
item it's in the ids array but not in keyedByIds @marshallswain
<https://github.com/marshallswain> ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/feathersjs-ecosystem/feathers-
vuex/issues/609#issuecomment-897677435>, or unsubscribe
<https://github.com/notifications/unsubscribe-
auth/AAA7OWPPXUON7SKDLFYELZDT4PJULANCNFSM5B6KMSBQ>.
|
I knew that Sets ans Maps used a hash map internally in V8 but I was not aware of this being the case for Arrays and I didn't find anything on that... |
So it might improve everywhere. Let’s do it
On August 12, 2021, GitHub ***@***.***> wrote:
> That would be a good improvement, although I believe
> chromium internally optimizes that code to use a map, I’ve not read
> anything like that about other browsers.
>
I knew that Sets ans Maps used a hash map internally in V8 but I was
not aware of this being the case for Arrays and I didn't find anything
on that...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/feathersjs-ecosystem/feathers-
vuex/issues/609#issuecomment-897700012>, or unsubscribe
<https://github.com/notifications/unsubscribe-
auth/AAA7OWJ5EIYHNREWY6PJTRDT4PM4BANCNFSM5B6KMSBQ>.
|
There is one problem, the tests But this is because the properties added has not been initialized. So there is 2 workaround for this:
I think we could propose a different behavior as it is due to how Vue 2 reactivity works. Iterating on all the properties of all the items added is hurting performance and is only needed in Vue 2 as Vue 3 Proxies handle property addition. But the one big disadvantage is when you don't know all the properties of the items you receive in advance, you can't predefine them and you loose reactivity on updates. So it could be an option, maybe off by default, in order to not introduce breaking change, that could be turned on globally or per service which would not use the Are you ok with that @marshallswain ? |
+1. I've also performance issues on slow machines. The solution sounds nice! Your code is for vue3, right?
I also wonder if that would make a difference for vue2:
We definitely should add performance tests for that with 1k items or something. We could also catch if it's just one item. |
Any idea when this can be solved? |
I've been on vacation in the mean time. |
Whatever we end up doing for the fix, let's remove |
@J3m5, related to your comment on Aug 13, for Vue 2, let's just expect the properties to have been predefined. Feeling this through more, it seems like the original reason for implementing the slower solution had something to do with form bindings. I can't remember exactly what it was, though. As long as a form stays bound after an update to an object that has been retrieved with a getter, the solution is perfect. |
Steps to reproduce
When calling find action with a resulting dataset of more than 500 records, it takes 15 seconds to update the store.
Expected behavior
Faster store update
Actual behavior
takes 15 sec.
System configuration
Tell us about the applicable parts of your setup.
Module versions (especially the part that's not working): "@feathersjs/vuex": "^4.0.1-pre.16",
NodeJS version: v14.16.1
Operating System: Ubuntu
Browser Version: chrome
I traced it to the addItems function in service-module-mutations
I think these statements are causing the performance issue.
state.ids.push(id);
state.keyedById[id] = item;
Somehow it takes a lot of time, maybe because of vue/vuex reactivity. Don't know exactly why.
A possible solution hereunder takes it to less then a second:
The text was updated successfully, but these errors were encountered: