mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Previously, accessing any property of a token's kind required both a function call to an out-of-line method and loading the relevant data out of a table. These method calls were often roughly as expensive as the load out of the table -- they would push and pop registers, and so would touch a stack cache line not unlike the table cache line. We can inline them in a way that carefully leaves the table definitions in the single TU so we don't get tons of copies of data that have to be merged by the linker. But the access to the table can be in an inline function that allows the call overhead to evaporate and these to turn into just table loads in the callers as well. While in theory we could rely on forms of LTO to acheive this, it doesn't seem worth relying on that. This is an easy win with very little cost in reality. Several of the lexer benchmarks improve by 1% or 2% from removing the function call overhead. It's not a huge win, but it's nice. Even more nice is that the profile is cleaned up significantly, clearly focusing on the core functions where time is spent in lexing and parsing. This also pulls my big-picture benchmark of 10mloc file down to under 4.3s to lex and parse excitingly. Basically, we're above 2.3mloc/s lexing and parsing. Not *quite* the 10mloc/s that I'm hoping for, but still progress. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Toolchain
A design is currently maintained in Google Drive. It'll be migrated to markdown once we are confident in its stability.