Skip to content

Commit

Permalink
feat: replace stats gob format with csv for easier diffs (#1276)
Browse files Browse the repository at this point in the history
* feat: replace stats gob format with csv for easier diffs

* feat: add latest_stats.csv

* fix: sort circuitNames to have deterministic output of stats

* build: make linter happier
  • Loading branch information
gbotrel authored Sep 13, 2024
1 parent 4b4cec2 commit b2b2ddd
Show file tree
Hide file tree
Showing 7 changed files with 356 additions and 52 deletions.
12 changes: 12 additions & 0 deletions backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ func (id ID) String() string {
}
}

// IDFromString returns the ID of a proof system from its string representation
func IDFromString(s string) ID {
switch s {
case "groth16":
return GROTH16
case "plonk":
return PLONK
default:
return UNKNOWN
}
}

// ProverOption defines option for altering the behavior of the prover in
// Prove, ReadAndProve and IsSolved methods. See the descriptions of functions
// returning instances of this type for implemented options.
Expand Down
10 changes: 9 additions & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,13 @@ var Version = semver.MustParse("0.11.0")

// Curves return the curves supported by gnark
func Curves() []ecc.ID {
return []ecc.ID{ecc.BN254, ecc.BLS12_377, ecc.BLS12_381, ecc.BW6_761, ecc.BLS24_315, ecc.BW6_633, ecc.BLS24_317}
return []ecc.ID{
ecc.BN254,
ecc.BLS12_377,
ecc.BLS12_381,
ecc.BLS24_315,
ecc.BLS24_317,
ecc.BW6_761,
ecc.BW6_633,
}
}
28 changes: 14 additions & 14 deletions internal/stats/generate/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package main

import (
"bytes"
"flag"
"fmt"
"log"
"os"
"regexp"
"sync"

Expand Down Expand Up @@ -51,25 +53,23 @@ func main() {
}
wg.Wait()

fmt.Println("id,curve,backend,nbConstraints,nbWires")
for name, c := range snippets {
if r != nil && !r.MatchString(name) {
continue
}
ss := s.Stats[name]
for _, curve := range c.Curves {
for _, backendID := range backend.Implemented() {
cs := ss[backendID][stats.CurveIdx(curve)]
fmt.Printf("%s,%s,%s,%d,%d\n", name, curve, backendID, cs.NbConstraints, cs.NbInternalWires)
}
}
// write csv to buffer
var buf bytes.Buffer
if _, err := s.WriteTo(&buf); err != nil {
log.Fatal(err)
}

// print csv
fmt.Println(buf.String())

if *fSave {
const refPath = "../latest.stats"
if err := s.Save(refPath); err != nil {
const refPath = "../latest_stats.csv"
// write buffer to file

if err := os.WriteFile(refPath, buf.Bytes(), 0600); err != nil {
log.Fatal(err)
}

log.Println("successfully saved new reference stats file", refPath)
}

Expand Down
Binary file removed internal/stats/latest.stats
Binary file not shown.
253 changes: 253 additions & 0 deletions internal/stats/latest_stats.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
circuit,curve,backend,nbConstraints,nbWires
api/AssertIsLessOrEqual,bn254,groth16,1523,1367
api/AssertIsLessOrEqual,bls12_377,groth16,1517,1349
api/AssertIsLessOrEqual,bls12_381,groth16,1529,1405
api/AssertIsLessOrEqual,bls24_315,groth16,1517,1375
api/AssertIsLessOrEqual,bls24_317,groth16,1529,1376
api/AssertIsLessOrEqual,bw6_761,groth16,2265,2020
api/AssertIsLessOrEqual,bw6_633,groth16,1893,1722
api/AssertIsLessOrEqual,bn254,plonk,3199,3043
api/AssertIsLessOrEqual,bls12_377,plonk,3199,3031
api/AssertIsLessOrEqual,bls12_381,plonk,3179,3055
api/AssertIsLessOrEqual,bls24_315,plonk,3173,3031
api/AssertIsLessOrEqual,bls24_317,plonk,3208,3055
api/AssertIsLessOrEqual,bw6_761,plonk,4764,4519
api/AssertIsLessOrEqual,bw6_633,plonk,3946,3775
api/AssertIsLessOrEqual/constant_bound_64_bits,bn254,groth16,587,353
api/AssertIsLessOrEqual/constant_bound_64_bits,bls12_377,groth16,588,339
api/AssertIsLessOrEqual/constant_bound_64_bits,bls12_381,groth16,611,387
api/AssertIsLessOrEqual/constant_bound_64_bits,bls24_315,groth16,600,365
api/AssertIsLessOrEqual/constant_bound_64_bits,bls24_317,groth16,610,358
api/AssertIsLessOrEqual/constant_bound_64_bits,bw6_761,groth16,883,511
api/AssertIsLessOrEqual/constant_bound_64_bits,bw6_633,groth16,755,461
api/AssertIsLessOrEqual/constant_bound_64_bits,bn254,plonk,994,760
api/AssertIsLessOrEqual/constant_bound_64_bits,bls12_377,plonk,1006,757
api/AssertIsLessOrEqual/constant_bound_64_bits,bls12_381,plonk,987,763
api/AssertIsLessOrEqual/constant_bound_64_bits,bls24_315,plonk,992,757
api/AssertIsLessOrEqual/constant_bound_64_bits,bls24_317,plonk,1015,763
api/AssertIsLessOrEqual/constant_bound_64_bits,bw6_761,plonk,1501,1129
api/AssertIsLessOrEqual/constant_bound_64_bits,bw6_633,plonk,1237,943
api/IsZero,bn254,groth16,2,2
api/IsZero,bls12_377,groth16,2,2
api/IsZero,bls12_381,groth16,2,2
api/IsZero,bls24_315,groth16,2,2
api/IsZero,bls24_317,groth16,2,2
api/IsZero,bw6_761,groth16,2,2
api/IsZero,bw6_633,groth16,2,2
api/IsZero,bn254,plonk,2,2
api/IsZero,bls12_377,plonk,2,2
api/IsZero,bls12_381,plonk,2,2
api/IsZero,bls24_315,plonk,2,2
api/IsZero,bls24_317,plonk,2,2
api/IsZero,bw6_761,plonk,2,2
api/IsZero,bw6_633,plonk,2,2
api/Lookup2,bn254,groth16,5,3
api/Lookup2,bls12_377,groth16,5,3
api/Lookup2,bls12_381,groth16,5,3
api/Lookup2,bls24_315,groth16,5,3
api/Lookup2,bls24_317,groth16,5,3
api/Lookup2,bw6_761,groth16,5,3
api/Lookup2,bw6_633,groth16,5,3
api/Lookup2,bn254,plonk,12,10
api/Lookup2,bls12_377,plonk,12,10
api/Lookup2,bls12_381,plonk,12,10
api/Lookup2,bls24_315,plonk,12,10
api/Lookup2,bls24_317,plonk,12,10
api/Lookup2,bw6_761,plonk,12,10
api/Lookup2,bw6_633,plonk,12,10
hash/mimc,bn254,groth16,330,330
hash/mimc,bls12_377,groth16,310,310
hash/mimc,bls12_381,groth16,333,333
hash/mimc,bls24_315,groth16,327,327
hash/mimc,bls24_317,groth16,364,364
hash/mimc,bw6_761,groth16,489,489
hash/mimc,bw6_633,groth16,408,408
hash/mimc,bn254,plonk,441,441
hash/mimc,bls12_377,plonk,373,373
hash/mimc,bls12_381,plonk,445,445
hash/mimc,bls24_315,plonk,437,437
hash/mimc,bls24_317,plonk,456,456
hash/mimc,bw6_761,plonk,653,653
hash/mimc,bw6_633,plonk,545,545
math/bits.ToBinary,bn254,groth16,508,353
math/bits.ToBinary,bls12_377,groth16,506,339
math/bits.ToBinary,bls12_381,groth16,510,387
math/bits.ToBinary,bls24_315,groth16,506,365
math/bits.ToBinary,bls24_317,groth16,510,358
math/bits.ToBinary,bw6_761,groth16,755,511
math/bits.ToBinary,bw6_633,groth16,631,461
math/bits.ToBinary,bn254,plonk,915,760
math/bits.ToBinary,bls12_377,plonk,924,757
math/bits.ToBinary,bls12_381,plonk,886,763
math/bits.ToBinary,bls24_315,plonk,898,757
math/bits.ToBinary,bls24_317,plonk,915,763
math/bits.ToBinary,bw6_761,plonk,1373,1129
math/bits.ToBinary,bw6_633,plonk,1113,943
math/bits.ToBinary/unconstrained,bn254,groth16,354,353
math/bits.ToBinary/unconstrained,bls12_377,groth16,340,339
math/bits.ToBinary/unconstrained,bls12_381,groth16,388,387
math/bits.ToBinary/unconstrained,bls24_315,groth16,366,365
math/bits.ToBinary/unconstrained,bls24_317,groth16,359,358
math/bits.ToBinary/unconstrained,bw6_761,groth16,512,511
math/bits.ToBinary/unconstrained,bw6_633,groth16,462,461
math/bits.ToBinary/unconstrained,bn254,plonk,761,760
math/bits.ToBinary/unconstrained,bls12_377,plonk,758,757
math/bits.ToBinary/unconstrained,bls12_381,plonk,764,763
math/bits.ToBinary/unconstrained,bls24_315,plonk,758,757
math/bits.ToBinary/unconstrained,bls24_317,plonk,764,763
math/bits.ToBinary/unconstrained,bw6_761,plonk,1130,1129
math/bits.ToBinary/unconstrained,bw6_633,plonk,944,943
math/bits.ToTernary,bn254,groth16,484,483
math/bits.ToTernary,bls12_377,groth16,481,480
math/bits.ToTernary,bls12_381,groth16,484,483
math/bits.ToTernary,bls24_315,groth16,481,480
math/bits.ToTernary,bls24_317,groth16,484,483
math/bits.ToTernary,bw6_761,groth16,715,714
math/bits.ToTernary,bw6_633,groth16,598,597
math/bits.ToTernary,bn254,plonk,966,965
math/bits.ToTernary,bls12_377,plonk,960,959
math/bits.ToTernary,bls12_381,plonk,966,965
math/bits.ToTernary,bls24_315,plonk,960,959
math/bits.ToTernary,bls24_317,plonk,966,965
math/bits.ToTernary,bw6_761,plonk,1428,1427
math/bits.ToTernary,bw6_633,plonk,1194,1193
math/bits.ToTernary/unconstrained,bn254,groth16,1,161
math/bits.ToTernary/unconstrained,bls12_377,groth16,1,160
math/bits.ToTernary/unconstrained,bls12_381,groth16,1,161
math/bits.ToTernary/unconstrained,bls24_315,groth16,1,160
math/bits.ToTernary/unconstrained,bls24_317,groth16,1,161
math/bits.ToTernary/unconstrained,bw6_761,groth16,1,238
math/bits.ToTernary/unconstrained,bw6_633,groth16,1,199
math/bits.ToTernary/unconstrained,bn254,plonk,161,321
math/bits.ToTernary/unconstrained,bls12_377,plonk,160,319
math/bits.ToTernary/unconstrained,bls12_381,plonk,161,321
math/bits.ToTernary/unconstrained,bls24_315,plonk,160,319
math/bits.ToTernary/unconstrained,bls24_317,plonk,161,321
math/bits.ToTernary/unconstrained,bw6_761,plonk,238,475
math/bits.ToTernary/unconstrained,bw6_633,plonk,199,397
math/emulated/secp256k1_64,bn254,groth16,1070,1950
math/emulated/secp256k1_64,bls12_377,groth16,1070,1950
math/emulated/secp256k1_64,bls12_381,groth16,1070,1950
math/emulated/secp256k1_64,bls24_315,groth16,1070,1950
math/emulated/secp256k1_64,bls24_317,groth16,1070,1950
math/emulated/secp256k1_64,bw6_761,groth16,1070,1950
math/emulated/secp256k1_64,bw6_633,groth16,1070,1950
math/emulated/secp256k1_64,bn254,plonk,4497,4388
math/emulated/secp256k1_64,bls12_377,plonk,4497,4388
math/emulated/secp256k1_64,bls12_381,plonk,4497,4388
math/emulated/secp256k1_64,bls24_315,plonk,4497,4388
math/emulated/secp256k1_64,bls24_317,plonk,4497,4388
math/emulated/secp256k1_64,bw6_761,plonk,4497,4388
math/emulated/secp256k1_64,bw6_633,plonk,4497,4388
pairing_bls12377,bn254,groth16,0,0
pairing_bls12377,bls12_377,groth16,0,0
pairing_bls12377,bls12_381,groth16,0,0
pairing_bls12377,bls24_315,groth16,0,0
pairing_bls12377,bls24_317,groth16,0,0
pairing_bls12377,bw6_761,groth16,11236,11236
pairing_bls12377,bw6_633,groth16,0,0
pairing_bls12377,bn254,plonk,0,0
pairing_bls12377,bls12_377,plonk,0,0
pairing_bls12377,bls12_381,plonk,0,0
pairing_bls12377,bls24_315,plonk,0,0
pairing_bls12377,bls24_317,plonk,0,0
pairing_bls12377,bw6_761,plonk,51280,51280
pairing_bls12377,bw6_633,plonk,0,0
pairing_bls12381,bn254,groth16,1429070,2382640
pairing_bls12381,bls12_377,groth16,0,0
pairing_bls12381,bls12_381,groth16,0,0
pairing_bls12381,bls24_315,groth16,0,0
pairing_bls12381,bls24_317,groth16,0,0
pairing_bls12381,bw6_761,groth16,0,0
pairing_bls12381,bw6_633,groth16,0,0
pairing_bls12381,bn254,plonk,5629807,5285448
pairing_bls12381,bls12_377,plonk,0,0
pairing_bls12381,bls12_381,plonk,0,0
pairing_bls12381,bls24_315,plonk,0,0
pairing_bls12381,bls24_317,plonk,0,0
pairing_bls12381,bw6_761,plonk,0,0
pairing_bls12381,bw6_633,plonk,0,0
pairing_bls24315,bn254,groth16,0,0
pairing_bls24315,bls12_377,groth16,0,0
pairing_bls24315,bls12_381,groth16,0,0
pairing_bls24315,bls24_315,groth16,0,0
pairing_bls24315,bls24_317,groth16,0,0
pairing_bls24315,bw6_761,groth16,0,0
pairing_bls24315,bw6_633,groth16,28928,28928
pairing_bls24315,bn254,plonk,0,0
pairing_bls24315,bls12_377,plonk,0,0
pairing_bls24315,bls12_381,plonk,0,0
pairing_bls24315,bls24_315,plonk,0,0
pairing_bls24315,bls24_317,plonk,0,0
pairing_bls24315,bw6_761,plonk,0,0
pairing_bls24315,bw6_633,plonk,141249,141249
pairing_bn254,bn254,groth16,969638,1614382
pairing_bn254,bls12_377,groth16,0,0
pairing_bn254,bls12_381,groth16,0,0
pairing_bn254,bls24_315,groth16,0,0
pairing_bn254,bls24_317,groth16,0,0
pairing_bn254,bw6_761,groth16,0,0
pairing_bn254,bw6_633,groth16,0,0
pairing_bn254,bn254,plonk,3798583,3560759
pairing_bn254,bls12_377,plonk,0,0
pairing_bn254,bls12_381,plonk,0,0
pairing_bn254,bls24_315,plonk,0,0
pairing_bn254,bls24_317,plonk,0,0
pairing_bn254,bw6_761,plonk,0,0
pairing_bn254,bw6_633,plonk,0,0
pairing_bw6761,bn254,groth16,3014749,4979960
pairing_bw6761,bls12_377,groth16,0,0
pairing_bw6761,bls12_381,groth16,0,0
pairing_bw6761,bls24_315,groth16,0,0
pairing_bw6761,bls24_317,groth16,0,0
pairing_bw6761,bw6_761,groth16,0,0
pairing_bw6761,bw6_633,groth16,0,0
pairing_bw6761,bn254,plonk,11486969,10777222
pairing_bw6761,bls12_377,plonk,0,0
pairing_bw6761,bls12_381,plonk,0,0
pairing_bw6761,bls24_315,plonk,0,0
pairing_bw6761,bls24_317,plonk,0,0
pairing_bw6761,bw6_761,plonk,0,0
pairing_bw6761,bw6_633,plonk,0,0
scalar_mul_G1_bn254,bn254,groth16,99938,159576
scalar_mul_G1_bn254,bls12_377,groth16,0,0
scalar_mul_G1_bn254,bls12_381,groth16,0,0
scalar_mul_G1_bn254,bls24_315,groth16,0,0
scalar_mul_G1_bn254,bls24_317,groth16,0,0
scalar_mul_G1_bn254,bw6_761,groth16,0,0
scalar_mul_G1_bn254,bw6_633,groth16,0,0
scalar_mul_G1_bn254,bn254,plonk,381115,356144
scalar_mul_G1_bn254,bls12_377,plonk,0,0
scalar_mul_G1_bn254,bls12_381,plonk,0,0
scalar_mul_G1_bn254,bls24_315,plonk,0,0
scalar_mul_G1_bn254,bls24_317,plonk,0,0
scalar_mul_G1_bn254,bw6_761,plonk,0,0
scalar_mul_G1_bn254,bw6_633,plonk,0,0
scalar_mul_P256,bn254,groth16,186380,301997
scalar_mul_P256,bls12_377,groth16,0,0
scalar_mul_P256,bls12_381,groth16,0,0
scalar_mul_P256,bls24_315,groth16,0,0
scalar_mul_P256,bls24_317,groth16,0,0
scalar_mul_P256,bw6_761,groth16,0,0
scalar_mul_P256,bw6_633,groth16,0,0
scalar_mul_P256,bn254,plonk,737681,687661
scalar_mul_P256,bls12_377,plonk,0,0
scalar_mul_P256,bls12_381,plonk,0,0
scalar_mul_P256,bls24_315,plonk,0,0
scalar_mul_P256,bls24_317,plonk,0,0
scalar_mul_P256,bw6_761,plonk,0,0
scalar_mul_P256,bw6_633,plonk,0,0
scalar_mul_secp256k1,bn254,groth16,100948,161209
scalar_mul_secp256k1,bls12_377,groth16,0,0
scalar_mul_secp256k1,bls12_381,groth16,0,0
scalar_mul_secp256k1,bls24_315,groth16,0,0
scalar_mul_secp256k1,bls24_317,groth16,0,0
scalar_mul_secp256k1,bw6_761,groth16,0,0
scalar_mul_secp256k1,bw6_633,groth16,0,0
scalar_mul_secp256k1,bn254,plonk,385109,359843
scalar_mul_secp256k1,bls12_377,plonk,0,0
scalar_mul_secp256k1,bls12_381,plonk,0,0
scalar_mul_secp256k1,bls24_315,plonk,0,0
scalar_mul_secp256k1,bls24_317,plonk,0,0
scalar_mul_secp256k1,bw6_761,plonk,0,0
scalar_mul_secp256k1,bw6_633,plonk,0,0
Loading

0 comments on commit b2b2ddd

Please sign in to comment.