-
Notifications
You must be signed in to change notification settings - Fork 974
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: Improve how MB handles local cache #4305
Comments
@pikurasa We can use APIs like IndexedDB or Dexie. js |
Please tell us more about those options. |
I am researching on this. Till now what I have learned is that localStorage can't handle large amounts of data. This could be the reason for being slow. |
@pikurasa we can also use origin private file system (OPFS) which is a highly optimal solution to this |
Hey @Commanderk3 , I think we already ARE using indexedDB. I think the issue here is that the website is currently loading every single one of my projects fully from the database into memory, even if it only shows one project on the screen. AND as mentioned by @pikurasa sir: A solution to this is implementing lazy loading into ProjectStorage.js . By doing this we ONLY allow meta data, like Name, data, image of project saved and NOT the entire DATA OF PROJECT itself.I might actually be wrong with this, can you review this comment? I'm looking into it's implementation. |
@FirePheonix, what you said is correct. It loads more than one project. All these projects are shown in "My Projects" on the planet page. |
@pikurasa @walterbender I guess combining project suppression for larger projects with lazy loading and archiving older projects in localStorage would make it comparatively faster. Additionally, moving from localStorage to IndexedDB would require us to estimate how much storage is typically needed to run Music Blocks in the browser. I am working on it. will share more details on this. |
@apsinghdev We are not using IndexedDB right? But dev tools show MB is using IndexedDB. |
@Commanderk3 At some places we use indexedDB but in most instances, we use local storage. |
@apsinghdev why cant we totally switch to IndexedDB in place of local storage? |
First we have to know how much storage we need for faster experience in MB. If localstorage provides enough of that, we don't need to switch. If localstorage is not enough, we should. |
One observation I have is that it seems to take (considerably) longer to run MB from the web than it does to run it locally. Of course, it takes some time to download all the files from the web. However, I suspect that something else is compounding the issue. It may be worth also looking into the order that things are loaded to see if there is some sort of race condition or other sort of inefficiency. |
@pikurasa, I ran a bunch of tests using some tools to check the performance and learned that the real culprit is not the project storage but the way we make HTTP requests and fetch initial CSS and JavaScript. ![]() ![]() The current fully loaded time of Music Blocks is |
@apsinghdev That might be true. Because when I consoled out the time taken for retrieving data from local storage it only showed a few seconds (less than 3 s). I didn't give much thought to this because my device is powerful. |
IMO, console statements aren't very effective when calculating the time. I tried it too but didn't get accurate results. |
Description
Every time a user creates a new project, it -- a JSON string -- is stored into the browser's cache.
We've had performance issues upon loading Music Blocks (MB) for a while, and finally determined that loading takes longer the more projects a user has stored to their local browser cache.
In order to solve this problem, we need to look into how we handle local data, so that loading time can be improved.
Expected Behavior
We want MB to load as fast as possible. Preferably as fast as it does from a private tab.
How to Reproduce
One way you can test this is:
Console log Errors:
I'm not really sure what logs may be related to this issue. It would be helpful if someone with experience in performance could look into this.
Environment:
Note: Faster computers, especially ones with decent GPUs, in my testing, are less noticeably effected by this issue because the overall loading time is faster in either case. If you test on a faster computer, you should also try on a slower machine as well. And, in any case, always make sure to compare against a session that has many projects loaded (see above).
Checklist
Thank you for contributing to our project! We appreciate your help in improving it.
📚 See contributing instructions.
🙋🏾🙋🏼 Questions: Community Matrix Server.
The text was updated successfully, but these errors were encountered: