cspr-rad / kairos

Apache License 2.0
2 stars 0 forks source link

I profiled our risc0 circuit. #114

Closed Avi-D-coder closed 2 months ago

Avi-D-coder commented 2 months ago

Our circuit is already pretty optimized unfortunately.

60% of cycles are spent calculating the merkle root, 30% on deserializing the data into risc0. Maybe we can use the older risc0 custom sterilization instead of serde. I can align the data a bit better, maybe I can optimize calc_subtree_hash a bit, but not much.

Flat    Flat%   Sum%    Cum Cum%    Name    Inlined?
2229336 24.11%  24.11%  2229336 24.11%  sha2::sha256::compress256   
1405433 15.20%  39.30%  1405433 15.20%  memcpy  
803798  8.69%   48.00%  2954603 31.95%  <kairos_trie::stored::merkle::Snapshot<V> as kairos_trie::stored::Store<V>>::calc_subtree_hash  
788440  8.53%   56.52%  5509723 59.58%  kairos_trie::transaction::Transaction<S,V>::calc_root_hash_node 
149716  1.62%   58.14%  149716  1.62%   memset  
133000  1.44%   59.58%  443959  4.80%   kairos_trie::transaction::nodes::Leaf<V>::hash_leaf 
0   0.00%   59.58%  5509723 59.58%  main    
0   0.00%   59.58%  5509723 59.58%  __start
Avi-D-coder commented 2 months ago

Work will be added in larger pr