Closed nebrelbug closed 4 years ago
Hello @nebrelbug , Can I take up this task ?
you can refer to https://developers.google.com/speed/pagespeed/insights/ for suggestions to improve sight
@kausha15 yes, that would be great! There's no limit to contributors for this issue, so if you have any ideas you can comment or make a pull request.
@bvishal8510 Pageseed Insights is great, but this issue is about improving the time it takes for the Compile() function to execute
@kausha15 do you have any ideas?
Not tested but common parsing problem with regex is that they take way more time than an LR/LL(1) generated parser (some multiple performance improvements) and same room of improvement for hand written lexer/parser (so in principle you can almost divide by 2 or more the parsing costs depending on is your regexes are already optimized) - but this will introduce more code and increase the size of your library ...
@ichiriac thanks for the comment! I've thought of using a parser, but here are some of my concerns:
I think it's still a valid suggestion though. Do you have any favorite JS parsers? Thank you!
Hi @nebrelbug,
A good starting point would be pegjs - https://pegjs.org/, but it comes with drawbacks, generated code is ugly, hard to debug, and the resulting code is long, in principle more rapid than regex but still slow.
Next you can write it by hand, all you need is a lexer to extract tokens, and then a grammar parser to expose the AST.
The simplest way to find out if you can improve the performance, and how much it's to try a POC and bench it ...
I'll try an implementation here : https://github.com/ichiriac/squirrelly but I need to change more than just the compile.js file ...
Thanks @ichiriac, that would be great if you could test that!
I've been toying with the idea (since my RegExp is so messy) but I'm not sure that it will end up being faster, since with RegExp I don't have to generate an AST or tokens.
On the other hand, maybe a parser will be much faster. I'm excited to find out!
Hi @ichiriac! I know it's been a while, but I recently published the first betas of Squirrelly v8, which implement many of your suggestions. Is it alright if I add you to the README as a contributor?
Hi @nebrelbug, it would be kind 😄, I wished to do more but didn't had time. Glad to see you released the v8, sounds like node's engine 😁
Sweet! @all-contributors please add @ichiriac for code and ideas!
@nebrelbug
I've put up a pull request to add @ichiriac! :tada:
If you can improve performance in any way (without sacrificing functionality) or have any ideas, comment here!