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
Script compilation time #153
Comments
You mean while constructing Merklised Syntax Tree of assembly program, is it ? |
Right. Overall, even for 3K instructions, building the MAST shouldn't require more than 100 or so invocations of the hash function - so, there must be some inefficiency somewhere. |
And we're using rescue prime as hash function, is it ? |
correct. |
I would love to work in this issue if no one is. |
Awesome! I'll assign this to you. Thank you! |
@bobbinth - Debugging the code trying to understand where is the most expensive part of it, I found somethings and I've some questions: The most expensive part of the executions seems to be in the first loop of
|
@willyrgf - thank you so much for looking into this! To answer your questions:
Linear cost is to be expected:
Do you mean 200 or 300 ops in a span? or spans in a block? If the latter, then it is rather surprising, but if the former, it is OK. Some spans could have hundreds (or even thousands) of ops in them.
I think we should create a benchmark (e.g., using Criterion) for script compilation time on an example of a moderately complex program (e.g. sha256) and see how it performs. My expectation is that compiling such programs shouldn't take more than a few milliseconds in release mode (benchmarks are usually run in release mode). So, if we see results which are very different from this, we can try to see what can be optimized. In terms of potential places to optimize, I think we'll get the biggest result by trying to minimize the number of times we need to call |
These are in debug mode.
I mean, spans in the
I didn't know Criterion, this looks interesting. I'll work on it.
Yeah it looked the same to me. Seems to be acceptable to me (and easy to test): group all spans that are in sequence and only call |
Oh interesting! I haven't anticipated this happening - would be curious what's generating such a large number of blocks to be merged.
Thank you! If you are interested, you can check out a couple of benchmark examples here. |
If I understood correctly, it's the |
Hi @bobbinth - sorry for that, but I will need to focus my time on other new things. Can you unassign me here? If somehow I found time and it's still available I'll send a PR. |
No worries! Thank you @willyrgf |
@bobbinth: I'd love to pick it up from here. |
@bobbinth: On my machine with AMD Ryzen 5 3550H running Pop!_OS 22.04 LTS, the sha256 compilation benchmark is taking |
@bobbinth - The benchmark of the new PR #250 running using the same configuration is as follows: My findings are consistent with @willyrgf. Earlier, we were iteratively applying the In debug mode, |
Closed by #250 |
It seems like compiling large scripts (e.g., sha256 in the standard library) takes quite a bit of time. This is especially apparent when running tests in debug mode (which is the default). For example, sha256 tests takes over 40 seconds to complete, and this is likely driven by the assembler. When running tests in release mode, the situation is better - i.e., under 1 second - but still.
We should investigate what is the bottleneck in the assembler and figure out how to address this. My guess is that a big part of this is driven by computing program hash, but would be good to confirm this.
The text was updated successfully, but these errors were encountered: