run_program for `op_point_add` is slow. Even slower than Python's clvm
ChiaMineJP opened this issue · 4 comments
It is really strange, but I got the same results even I tried benchmark multiple times.
I am releasing production-ready version of clvm_tools-js and I am currently benchmarking to compare performance with:
- clvm_tools(js) with clvm(js)
- clvm_tools(python) with clvm(python)
- clvm_tools(python) with clvm(rust)
In summary, clvm in Rust implementation works great in run_program
.
It is around 30-100 times faster than other implementation in most cases.
(But be aware, to_sexp_f
benchmark is 5-10 times slower than other implementation. This is another story.)
When I got the benchmark result, I found that op_point_add
is slower than Python implementation of clvm
.
This is really strange. I haven't started investigation yet, but I'd like to share the current data with you.
The benchmark was done using benchmark files generated by costs/generate-benchmark.py
in clvm_tools
.
The benchmark parameters are:
- value size: 4bytes(32bit)
- operations count: 200
I modified generate-benchmrk.py
a bit to produce benchmark files with such parameters.
I thought value_size = 4bytes and operations count = 200 seems to be typical among most of chialisp programs.
run_program
to_sexp_f
If you are interested, here is the result of to_sexp_f
benchmark.
The reason for the difference in pubkey_for_exp
is because clvm
uses bls-signatures
(aka blspy
), and clvm_rs
uses https://github.com/zkcrypto/bls12_381
.
Note that clvm_rs
is now an npm package https://www.npmjs.com/package/clvm_rs containing wasm32. The api is not good yet, but PRs are most welcome. See also https://github.com/Chia-Network/clvm_rs/tree/main/src/wasm. With this code, you may be able to speed up clvm(js)
and clvm_tools(js)
In clvm_rs
, op_point_add
does from_compressed
instead of from_compressed_unchecked
, which is probably a lot slower. However, making this change would probably be a hard fork.
@richardkiss I'll try to import clvm_rs
into clvm_tools-js soon.
I already have an idea on how to integrate clvm_rs into clvm_tools-js.