-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Optimize size of Concerto parser #55
Comments
I've tried to modify the script that creates the parser, with optimize option set to size the size of parser.js is 132kb instead of 558kb
|
@j4m3sb0mb Nice! Does that optimize version pass the tests? |
@jeromesimeon yes it does |
Thanks @j4m3sb0mb It's a relatively significant improvement. I don't see why we wouldn't do this for the time being. @dselman is traveling, but I can review a PR if you make one. I would still leave this issue open for the other reasons listed (clean up of parser itself, investigate other parser generator technologies). Would you like me to assign this issue to you for now? |
yes |
I have just seen this in the
Do you have any experience with performance related to this? I haven't done much testing with |
@jeromesimeon no experience, sorry |
@jeromesimeon
|
Thanks @j4m3sb0mb, the speed vs size tradeoffs aren't well understood for this library as far as I know. The last time that I looked at this, I saw a similar improvement in compile-time for the Perhaps this question helps?
My previous assumption was that speed is more important. Unless there is a clear consensus on this question, I suggest instead focussing on the removal of unused rules from this file (there are a lot of them!), https://github.com/accordproject/concerto/blob/master/packages/concerto-core/lib/introspect/parser.pegjs That way we get a size reduction but still optimize for speed. 🏆 |
I'll add two cents since @mttrbrts 's review really helped me understand what the questions are. I think I agree that speed during use matters more, even if that means the page initially loads a little slower (not sure how much slower really it's not that bad in Template Studio for instance). This is a one-time cost compared to the constant run-time cost when parsing. |
To be a little more specific about However, most of the original rules are still there unused (for example more of sections So refactoring will require some incremental changes and lots of testing to remove unused code. |
@mttrbrts |
Excellent! That's a nice surprise. I suspect that there are lots of other rules that aren't used too. For example:
Have some fun! |
Did a bit more in #154 The current parser looks pretty clean now. Tokens and Keywords have been cleaned up. I'm unclear on the definition of what "more advanced than we need" is for URIs. Shouldn't we comply with some kind of URI spec? What would we remove? Another area that might be simplified are Unicode character sets, but that's the same questions what do we believe the behaviour should be? |
@dselman @jeromesimeon It appears that pegjs is no-longer maintained pegjs/pegjs#667 There is a fork (https://github.com/peggyjs/peggy), however it is fairly nascent. It this the opportunity to switch to a new technology entirely, perhaps standardise with a parser lib that we use in |
Markdown transform uses: https://github.com/jneen/parsimmon Ergo uses: http://gallium.inria.fr/~fpottier/menhir/ |
This issue is partially address by the introduction of the new |
The JS for the CTO parser is currently very large and should be optimised to make the web packed version of Concerto much smaller. The parser currently includes many pegjs rules inherited from JS that could be removed.
[74] ./lib/introspect/parser.js 545 KiB {0} [depth 3] [built]
This is also an opportunity to take a step back and evaluate other parser generators. I am particularly interested in being able to generate a CTO parser for other languages. E.g. Canopy supports Java, JS, Ruby and Python. ANLR4 (while written in Java) can also generate JS amongst many other languages: https://github.com/antlr/antlr4
http://canopy.jcoglan.com/
References:
https://tomassetti.me/parsing-in-javascript/
https://en.wikipedia.org/wiki/Comparison_of_parser_generators
The text was updated successfully, but these errors were encountered: