Closed eternal-flame-AD closed 2 months ago
You can use .boxed()
to switch to dynamic dispatch, which avoids large types. See here. Note that this doesn't always come with a performance hit: LLVM is often able to devirtualise the parsers and still statically knit them together. Sometimes, performance can even improve!
I only boxed expressions, statements and primitives like ifs, I will try boxing them all tomorrow and report back. Thanks
I boxed everything that is longer than 3 levels that doesn't require Send (lexer part) and got down to about 25 kb and the next largest is 14 kb. My build time got noticeably slower actually (I suppose LTO is trying to see through the box?) but it's still acceptable. I attached the new longest symbol here if there is anything to see but thanks for the help! If there is no more thing to do feel free to close this, thanks! symbol.txt
I think that's about all there is, sadly (at least: until rustc gets a bit smarter about symbol generation for nested types). The same thing happens with complex Iterator
chains, although of course chumsky's pervasive use of the combinator pattern makes it much more common here.
Thanks for the help, and the project overall of course!
Would appreciate some advice! I read the advice section in the docs and used boxing in each function and used choice for any >=3 or's. My compile time was okay (~10 seconds on an LTO'ed build, excl. dependencies) but I get giant symbol names which feels wasteful, for example this 29 byte function get a 30kb+ name, is the only option here stripping the binary?
Some naive grepping give me this histogram, I attached the full name of the longest symbol. symbol.txt
Example of my code: