Replies: 2 comments 2 replies
-
Thank you for looking into this. I did a similar profile a while back and optimized the prefix transformer a bit (because it was the slowest part back then), but apart from this, there is still a lot of potential! I should also clarify my "we do care about the startup speed" statement. What I mean is the following: I really like command line applications that feel snappy. To be honest, most people will probably not care if the Numbat CLI takes 50 ms or 5 ms. But there is a threshold. Startup times tend to be noticeable once you get closer to 100 ms or 200 ms. And 500 ms already feels slow. I can feel a difference between Also, since the startup time is dominated by the interpreter, speeding up startup time means optimizing the interpreter, which is also relevant for executing larger amounts of code.
👍
Okay. Here it's probably worth taking a closer look. This consists of two parts. The actual compilation step (AST => bytecode). And then running the bytecode VM.
Yeah. That's a special part of Numbat. Maybe it would be possible to integrate this into the parser, but I found it easier to implement as a separate stage. But that also comes at a cost (traversing and rewriting the full AST). The job of the prefix parser is to do name resolution. And in particular: to distinguish between variables and units. If we see an identifier like
The typechecker also does a full rewrite of the parse tree (currently:
Yes. Like pythons |
Beta Was this translation helpful? Give feedback.
-
Out of curiosity, what're you using for benchmarking in those screenshots? |
Beta Was this translation helpful? Give feedback.
-
Hey, in #210, you mentioned that « we do care about the startup speed ».
I thought about it a little bit. First of all, I profiled the prelude import here. You can see a quick overview here:
As expected, we pretty much spent on the interpreter and not on the importer or something else unrelated; that’s nice.
Now, let’s dive deep into the interpret method:
The interesting parts are:
prefix_transformer
. I have no idea what it is and don't know if it's expected (and I would love to know what it is 👀)One idea to optimize the startup time could be to pre-compile the prelude to bytecode and add the ability to import bytecode directly to a context.
That should halve the startup time straight away.
Beta Was this translation helpful? Give feedback.
All reactions