-
Notifications
You must be signed in to change notification settings - Fork 202
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
[BUG] Performance issue with large site. #193
Comments
This is a very interested problem with no easy fix. There are a few things we have inconclusively discussed so we are open to suggestions. The things we have thought about:
Neither solution seems straightforward to implement. They will both be time consuming. Thoughts? @ekil1100 @asieduernest12 |
I like the WASM approach. It should bring better UX. |
I don't know about the wasm simply because we are not parsing the entire page at one go. We walk through the dom node by mode in kind of a depth first approach to find text nodes then activate ReadAssist(bionic reading) for the given text. If we Can make wasm part of the entire processing from finding nodes that have text and processing them then it might work. I've not dealt with wasm so I have to look into it. The other approach @ansh mentioned is possible with intersection observer which is the cousin of the current mutation observer we are using to update new text nodes for dynamic websites. But I have a sense it might not work well. Because we still have to find all nodes and text nodes and attach the intersection observer to it. Honestly it is probably not worth the effort but I don't know much. Finally I checked out the link with the trouble and used An alternate approach might using web workers to implement a parallel processing mechanism while also creating a map of parses entries do that they are not recomputed but just retrieved from the map if a word string has been processed before. The map approach is probably the easiest thing we can try snd should take just about 5 to 10 mins to implement I wrote something about it on another project. I'll find it and link it here later if someone wants to give it a shot. Otherwise I could take a look at the map approach over the weekend. The web worker approach looks promising but I have to consult some documentation. Cos I used it to build some dynamic programing problem awhile ago. OH boy so my thoughts are running on. The mutation observer approach on the other hand could be very expensive. Back to @ansh approach about watching the dom. I don't know if there is a Css selector that can return nodes in the viewing area outside the clipped window. But if there is then we can use something like a scroll over ser to watch the text for scroll changes then process new viewable nodes that have not been parsed already |
@asieduernest12 PartyTown (https://partytown.builder.io) provides a very simple API to run code on a different thread using web workers. It should be super fast to implement. As for my virtualization idea, I am not sure where to begin with implementing that. I would look into the React Native Web documentation since they have virtualized list components. |
@ansh i totally forgot party town is a thing. I've seen videos on it but have not used it yet. One thing to remember is any changes to the parsing logic affect the bookmarklet. Party town sure could do the trick when attempted . |
@ansh https://youtu.be/eP6Mti85HeQ Technically if we get 100k workers to run in ever 3 seconds per workers. It would be fast since they would all theoretically start at the same time and finish 3 seconds later. I've not thought this through though just typing out loud. Lol |
@ansh @ekil1100 i tried out the cache map approach i suggested but it did not yield any positive result from simple benchmarking. Sorry I did not save the figures also but you can test using the code in this branch The result for using the cache were all over the place and sometimes performed worse than running the parser without any map/cache implementation. the filecoin site has about 100k+ words and roughly takes 4k to 5k milliseconds to parse then it takes about another 4 to 6 seconds for the browser render the css updates. |
One alternative solution, while not the same, can be with a feature to select the text you want to apply the effect. Right now is doing it to the whole page but most probably the user has a fixation to an specific part of it. This will not solve the issue but give an alternative way to handle the situation. |
Describe the bug
There is a performance issue with a large site. For example, https://spec.filecoin.io/. Enable reading mode will cause the site to hang and crash.
Reproduce on a website
Expected behavior
Should render immediately.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: