-
Notifications
You must be signed in to change notification settings - Fork 19
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
v3 performance #104
Comments
That is really unexpected. Are these tests in a format you can share with me? |
Sadly I can't share the code since it's a commercial product and reproducing it would be quite time-consuming.
In sync version you call Task.Run which means the code is not blocked by the call but in async version you await the call and the method is blocked until the JS interop is executed. I removed the await and I saw a performance boost immediately (since I render hundreds, if not thousands of classes at a time) - not saying that's a good solution - just proving the point. I think for such scenarios it would be ideal to send CSS updates to clients in batches, or have some producer-consumer in a separate thread calling the JS stuff (although I don't know if that's possible in Blazor). |
Would it be correct to assume that you are using the |
Yea, my only use case is this:
I'm not using any other features of BlazorStyled anywhere in the code (except for keyframes, but that basically falls under this pattern aswell). |
So I was going back and forth about whether Would adding a flag to |
You can use ContinueWith() where you can trigger an event to show the component when the task finishes or "subscribe" to task completion in some other way. |
Either way, I would prefer not to change the |
Hm, what I'm trying to say is that the current solution is not good and adding an attribute is not going to make it better. Making the methods async is good, but the fact that it makes the library slower is a big problem, since loading speed is an extremely important thing on web (if not the most important). |
Just to paint the picture of what's the difference in my case. I measured the time since I hit the refresh button in the browser until everyhing gets rendered correctly: |
Also, is it documented somewhere how to hide the component until all the styles are loaded? |
I will answer the documentation piece first, its not documentated yet because I there is an issue with the docs site (and V3.0.0 in general that I posted here: #102) In V3, the call is async because it calls out to Javscript. You mentioned that the version of |
What I'm thinking could work is not blocking with await on the call to JS, but using ContinueWith() or some other form of "task completion subscription" to send a signal that the styles are loaded. |
It's still a work on progress but I started working on this here: https://github.com/chanan/BlazorStyled/blob/master/src/SampleCore/Shared/MainLayout.razor#L176-L183 |
Just did some tests on existing code with v3.0.0 and it turns out that v3.0.0 is several times slower when loading than v2.2.0.
I'm trying this on long lists of components with lots of nested components (in standard cases when there are not many classes it's working ok).
I'm only using @bind-classname approach.
The components also load a lot of stuff from services and it seems like in v2.2.0 styles load first and then the stuff from services is fetched. In v v3.0.0 the stuff from services is already rendering while the styles are still not completely loaded.
The text was updated successfully, but these errors were encountered: