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

Hyperstack hotloader is too slow #414

Open
lionelchauvin opened this issue Jun 1, 2021 · 2 comments
Open

Hyperstack hotloader is too slow #414

lionelchauvin opened this issue Jun 1, 2021 · 2 comments

Comments

@lionelchauvin
Copy link

The hotloader client is very slow when large js files are generated (hyperstack 1.0.0alpha1.8).
Chrome freezes just after page loading.

With chrome profiler, I can see it stays several seconds in ruby/hyperstack-config/lib/hyperstack/hotloader/stack-trace.js in _findFunctionName and _findSourceMappingURL

hotloader profiling

These methods create Regexps each time they are called.
If you keep these regexps in a cache the hotloader should be faster.

@lionelchauvin
Copy link
Author

lionelchauvin commented Jun 2, 2021

The hotloader was made for rails 5. In this version, sprockets created one .js per hyperstack/.rb file.
In rails 6 all files are merged in a single application.debug-.js file.
Every time a function name must be found at a specific line, application.debug-*.js is splitted on \n.
On my projet it does that >300 times.

@lionelchauvin
Copy link
Author

When a .rb file is changed on disk, it is sent to the browser via websocket and it is compiled by opal with Opal.compile.
Another performance issue is due to the parsing of strings by opal/parser. It is very slow. Some files of my project can take 20 seconds to be compiled. I patched the hotloader in order to compile it server side and send the javascript result to the browser. The same file can be hotloaded in 0.3 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant