-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Here is a flamegraph for a contract setup with the taker of itchysats at the time of writing this issue:
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 with secp256k1_zkp::Publickey. Here is the flamegraph of that:
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 and Contract 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#405
c) The patches are hacky