Skip to content

add benchmark for state db#16

Open
arner wants to merge 1 commit intohyperledger:mainfrom
arner:benchmark-state
Open

add benchmark for state db#16
arner wants to merge 1 commit intohyperledger:mainfrom
arner:benchmark-state

Conversation

@arner
Copy link
Copy Markdown
Contributor

@arner arner commented Apr 24, 2026

Initial results:

go test -bench=. -benchtime=1x -count=1 ./state/ 2>&1
goos: darwin
goarch: arm64
pkg: github.com/hyperledger/fabric-x-sdk/state
cpu: Apple M1 Max
BenchmarkUpdateWorldState/sqlite:file/txs=10/w=5-10                    1            663209 ns/op             15110 tx/s      75548 writes/s        40352 B/op       1221 allocs/op
BenchmarkUpdateWorldState/sqlite:file/txs=50/w=5-10                    1           2185166 ns/op             22893 tx/s     114465 writes/s       193536 B/op       5991 allocs/op
BenchmarkUpdateWorldState/sqlite:file/txs=100/w=5-10                   1           4160583 ns/op             24042 tx/s     120209 writes/s       386048 B/op      11963 allocs/op
BenchmarkUpdateWorldState/sqlite:file/txs=100/w=20-10                  1          19306000 ns/op              5180 tx/s     103603 writes/s      1550880 B/op      47286 allocs/op
BenchmarkUpdateWorldState/sqlite:memory/txs=10/w=5-10                  1            399125 ns/op             25115 tx/s     125575 writes/s        39696 B/op       1218 allocs/op
BenchmarkUpdateWorldState/sqlite:memory/txs=50/w=5-10                  1           1983458 ns/op             25218 tx/s     126088 writes/s       193648 B/op       5992 allocs/op
BenchmarkUpdateWorldState/sqlite:memory/txs=100/w=5-10                 1           3893750 ns/op             25689 tx/s     128444 writes/s       385392 B/op      11959 allocs/op
BenchmarkUpdateWorldState/sqlite:memory/txs=100/w=20-10                1          17165666 ns/op              5826 tx/s     116522 writes/s      1549712 B/op      47283 allocs/op

── UpdateWorldState  (tx/s | writes/s) ─────────────────────────
backend         txs=10/w=5       txs=50/w=5       txs=100/w=5      txs=100/w=20    
sqlite:file     15.1K | 75.5K    22.9K | 114.5K   24.0K | 120.2K   5.2K | 103.6K   
sqlite:memory   25.1K | 125.6K   25.2K | 126.1K   25.7K | 128.4K   5.8K | 116.5K   

BenchmarkGetState/sqlite:file-10                                       1            120833 ns/op            1432 B/op         46 allocs/op
BenchmarkGetState/sqlite:memory-10                                     1             85084 ns/op            1432 B/op         46 allocs/op

── GetState  (ns/op | reads/s) ─────────────────────────────────
backend         ns/op       reads/s   
sqlite:file     120625 ns   8.3K      
sqlite:memory   84834 ns    11.8K     

BenchmarkSimulation/sqlite:file/reads=20-10                            1            789750 ns/op             25346 reads/s            1267 sim/s           35072 B/op        969 allocs/op
BenchmarkSimulation/sqlite:file/reads=50-10                            1           1620625 ns/op             30857 reads/s             617.1 sim/s         81424 B/op       2388 allocs/op
BenchmarkSimulation/sqlite:file/reads=100-10                           1           3085958 ns/op             32408 reads/s             324.1 sim/s        154720 B/op       4750 allocs/op
BenchmarkSimulation/sqlite:memory/reads=20-10                          1            866917 ns/op             23080 reads/s            1154 sim/s           35008 B/op        968 allocs/op
BenchmarkSimulation/sqlite:memory/reads=50-10                          1           1970125 ns/op             25382 reads/s             507.6 sim/s         81696 B/op       2390 allocs/op
BenchmarkSimulation/sqlite:memory/reads=100-10                         1           3900541 ns/op             25641 reads/s             256.4 sim/s        154768 B/op       4751 allocs/op

── Simulation  (sim/s | reads/s)  —  5 writes per simulation ─
backend         reads=20       reads=50      reads=100     
sqlite:file     1.3K | 25.3K   617 | 30.9K   324 | 32.4K   
sqlite:memory   1.2K | 23.1K   508 | 25.4K   256 | 25.6K   

BenchmarkMixed/sqlite:file/sim-10                                      1         363501792 ns/op               137.6 reads/s
BenchmarkMixed/sqlite:memory/sim-10                                    1         272314500 ns/op               183.6 reads/s

── Mixed  (reads/s under concurrent writes at ~1K tps) ─────────
backend         reads/s   
sqlite:file     138       
sqlite:memory   184       

PASS
ok      github.com/hyperledger/fabric-x-sdk/state       18.955s

Signed-off-by: Arne Rutjes <arne123@gmail.com>
@arner arner force-pushed the benchmark-state branch from 18bdb10 to 9cae2fc Compare May 1, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant