Optimise attestation_pk
to not re-construct public keys so many times
#24
Labels
attestation_pk
to not re-construct public keys so many times
#24
Here is a flamegraph for a contract setup with the taker of
itchysats
at the time of writing this issue:flamegraph.zip
From that flamegraph, we can see that we spend a whopping 12% of our CPU time in the
attestation_pk
function. 2/3 of that (8% in total) are spent with parsing public keys.I made a dirty patch of maia and itchysats where I replaced all usages of
schnorrsig::Publickey
withsecp256k1_zkp::Publickey
. Here is the flamegraph of that:flamegraph.zip
In that flamegraph,
attestation_pk
takes only 4.5% of the entire CPU time but all of that is spent in combining keys (which is that actual job of that function).In a nutshell, this means we can easily knock off 8% of CPU cycles for each contract-setup / rollover. From skimming the logs, the gain is about 2 seconds in execution time: From 11s to 9s between the logs
Exchanged setup parameters
andContract setup was completed
.I didn't submit the patches because:
a) I think using x-only is more correct because that is what olivia is returning
b) Unfortunately, it is unlikely that
secp256k1
will support the required arithmetic to not convert the keys: rust-bitcoin/rust-secp256k1#405c) The patches are hacky
The text was updated successfully, but these errors were encountered: