Skip to content

Commit 1434a80

Browse files
authored
dlog validator service: benchmark #1284 (#1285)
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
1 parent 32f9f86 commit 1434a80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3559
-1887
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ clean-fabric-peer-images:
135135
tokengen:
136136
@go install ./cmd/tokengen
137137

138+
.PHONY: traceinspector
139+
traceinspector:
140+
@go install ./token/services/benchmark/cmd/traceinspector
141+
142+
.PHONY: memcheck
143+
memcheck:
144+
@go install ./token/services/benchmark/cmd/memcheck
145+
138146
.PHONY: idemixgen
139147
txgen:
140148
@go install github.com/IBM/idemix/tools/idemixgen

cmd/tokengen/cobra/pp/common/common_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0
77
package common
88

99
import (
10+
"bytes"
1011
"os"
1112
"path/filepath"
1213
"testing"
@@ -45,11 +46,11 @@ func TestLoadExtras(t *testing.T) {
4546
t.Errorf("expected 2 entries, got %d", len(result))
4647
}
4748

48-
if string(result["foo"]) != string(file1Content) {
49+
if !bytes.Equal(result["foo"], file1Content) {
4950
t.Errorf("expected %q for foo, got %q", string(file1Content), string(result["foo"]))
5051
}
5152

52-
if string(result["bar"]) != string(file2Content) {
53+
if !bytes.Equal(result["bar"], file2Content) {
5354
t.Errorf("expected %q for bar, got %q", string(file2Content), string(result["bar"]))
5455
}
5556
})
@@ -144,7 +145,7 @@ func TestLoadExtras(t *testing.T) {
144145
t.Fatalf("expected no error, got: %v", err)
145146
}
146147

147-
if string(result["mykey"]) != string(fileContent) {
148+
if !bytes.Equal(result["mykey"], fileContent) {
148149
t.Errorf("expected %q, got %q", string(fileContent), string(result["mykey"]))
149150
}
150151
})

docs/benchmark/benchmark.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
# Benchmark
1+
# Benchmarks
2+
3+
## Tools
24

35
- [Go Tools for Benchmarks](./tools.md)
4-
- [ZKAT DLog No Graph-Hiding](dlognogh/dlognogh.md)
6+
- Custom Analysis Tools:
7+
- [`memcheck`](./../../token/services/benchmark/cmd/memcheck/README.md): Go Pprof Memory Analyzer
8+
- [`traceinspector`](./../../token/services/benchmark/cmd/memcheck/README.md): Go Pprof Trace Analyzer
9+
10+
## Benchmark
11+
12+
- [ZKAT DLog No Graph-Hiding Benchmarks](core/dlognogh/dlognogh.md)
13+
- [Identity Service - Idemix](services/identity/idemix.md)
Lines changed: 69 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
# ZKAT DLog No Graph Hiding Benchmark
1+
# ZKAT DLog No Graph Hiding Benchmarks
22

33
Packages with benchmark tests:
44

55
- `token/core/zkatdlog/nogh/v1/transfer`:
6-
- `BenchmarkSender`, `BenchmarkVerificationSenderProof`, `TestParallelBenchmarkSender`, and `TestParallelBenchmarkVerificationSenderProof` are used to benchmark the generation of a transfer action. This includes also the generation of ZK proof for a transfer operation.
7-
- `BenchmarkTransferProofGeneration`, `TestParallelBenchmarkTransferProofGeneration` are used to benchmark the generation of ZK proof alone.
6+
- `BenchmarkSender`, `BenchmarkVerificationSenderProof`, `TestParallelBenchmarkSender`, and `TestParallelBenchmarkVerificationSenderProof` are used to benchmark the generation of a transfer action, serialization included. This includes also the generation of ZK proof for a transfer operation.
7+
- `BenchmarkTransferProofGeneration`, `TestParallelBenchmarkTransferProofGeneration` are used to benchmark the generation of ZK proof alone. This includes proof serialization.
88
- `token/core/zkatdlog/nogh/v1/issue`: `BenchmarkIssuer` and `BenchmarkProofVerificationIssuer`
9-
- `token/core/zkatdlog/nogh/v1`: `BenchmarkTransfer`
9+
- `token/core/zkatdlog/nogh/v1/validator`: `TestParallelBenchmarkValidatorTransfer`.
10+
- `token/core/zkatdlog/nogh/v1`: `BenchmarkTransferServiceTransfer` and `TestParallelBenchmarkTransferServiceTransfer`.
1011

1112
The steps necessary to run the benchmarks are very similar.
1213
We give two examples here:
@@ -109,17 +110,17 @@ You can then aggregate/parse the output (e.g., benchstat) to compute averages ac
109110

110111
### Results
111112

112-
Example results have been produced on an Apple M1 Max and can be consulted [here](./transfer_BenchmarkSender_results.md).
113+
Example results have been produced on an Apple M1 Max and can be consulted [here](transfer_BenchmarkSender_results.md).
113114

114115
## Benchmark: `token/core/zkatdlog/nogh/v1/transfer#TestParallelBenchmarkSender`
115116

116117
This is a test that runs multiple instances of the above benchmark in parallel.
117118
This allows the analyst to understand if shared data structures are actual bottlenecks.
118119

119-
It uses a custom-made runner whose documentation can be found [here](../../../token/core/common/benchmark/runner.md).
120+
It uses a custom-made runner whose documentation can be found [here](../../../../token/services/benchmark/runner.md).
120121

121122
```shell
122-
go test ./token/core/zkatdlog/nogh/v1/transfer -test.run=TestParallelBenchmarkSender -test.v -test.benchmem -test.timeout 0 -bits="32" -curves="BN254" -num_inputs="2" -num_outputs="2" -workers="1,10" -duration="10s" | tee bench.txt
123+
go test ./token/core/zkatdlog/nogh/v1/transfer -test.run=TestParallelBenchmarkSender -test.v -test.timeout 0 -bits="32" -curves="BN254" -num_inputs="2" -num_outputs="2" -workers="NumCPU" -duration="10s" -setup_samples=128 | tee bench.txt
123124
```
124125

125126
The test supports the following flags:
@@ -136,120 +137,82 @@ The test supports the following flags:
136137
a comma-separate list of number of outputs (1,2,3,...)
137138
-workers string
138139
a comma-separate list of workers (1,2,3,...,NumCPU), where NumCPU is converted to the number of available CPUs
140+
-profile bool
141+
write pprof profiles to file
142+
-setup_samples uint
143+
number of setup samples, 0 disables it
139144
```
140145

141146
### Results
142147

143-
```go
148+
```shell
144149
=== RUN TestParallelBenchmarkSender
145-
=== RUN TestParallelBenchmarkSender/Setup(bits_32,_curve_BN254,_#i_2,_#o_2)_with_1_workers
146-
Metric Value Description
147-
------ ----- -----------
148-
Workers 1
149-
Total Ops 168 (Low Sample Size)
150-
Duration 10.023390959s (Good Duration)
151-
Real Throughput 16.76/s Observed Ops/sec (Wall Clock)
152-
Pure Throughput 17.77/s Theoretical Max (Low Overhead)
153-
154-
Latency Distribution:
155-
Min 55.180375ms
156-
P50 (Median) 55.945812ms
157-
Average 56.290356ms
158-
P95 58.108814ms
159-
P99 58.758087ms
160-
Max 59.089958ms (Stable Tail)
161-
162-
Stability Metrics:
163-
Std Dev 898.087µs
164-
IQR 1.383083ms Interquartile Range
165-
Jitter 590.076µs Avg delta per worker
166-
CV 1.60% Excellent Stability (<5%)
167-
168-
Memory 1301420 B/op Allocated bytes per operation
169-
Allocs 18817 allocs/op Allocations per operation
170-
171-
Latency Heatmap (Dynamic Range):
172-
Range Freq Distribution Graph
173-
55.180375ms-55.369563ms 17 █████████████████████████ (10.1%)
174-
55.369563ms-55.5594ms 18 ██████████████████████████ (10.7%)
175-
55.5594ms-55.749887ms 27 ████████████████████████████████████████ (16.1%)
176-
55.749887ms-55.941028ms 20 █████████████████████████████ (11.9%)
177-
55.941028ms-56.132824ms 13 ███████████████████ (7.7%)
178-
56.132824ms-56.325277ms 9 █████████████ (5.4%)
179-
56.325277ms-56.51839ms 4 █████ (2.4%)
180-
56.51839ms-56.712165ms 6 ████████ (3.6%)
181-
56.712165ms-56.906605ms 9 █████████████ (5.4%)
182-
56.906605ms-57.101711ms 13 ███████████████████ (7.7%)
183-
57.101711ms-57.297486ms 10 ██████████████ (6.0%)
184-
57.297486ms-57.493933ms 3 ████ (1.8%)
185-
57.493933ms-57.691053ms 3 ████ (1.8%)
186-
57.691053ms-57.888849ms 4 █████ (2.4%)
187-
57.888849ms-58.087323ms 3 ████ (1.8%)
188-
58.087323ms-58.286478ms 2 ██ (1.2%)
189-
58.286478ms-58.486315ms 2 ██ (1.2%)
190-
58.486315ms-58.686837ms 2 ██ (1.2%)
191-
58.686837ms-58.888047ms 2 ██ (1.2%)
192-
58.888047ms-59.089958ms 1 █ (0.6%)
193-
194-
--- Analysis & Recommendations ---
195-
[WARN] Low sample size (168). Results may not be statistically significant. Run for longer.
196-
[INFO] High Allocations (18817/op). This will trigger frequent GC cycles and increase Max Latency.
197-
----------------------------------
198150
=== RUN TestParallelBenchmarkSender/Setup(bits_32,_curve_BN254,_#i_2,_#o_2)_with_10_workers
199-
Metric Value Description
200-
------ ----- -----------
201-
Workers 10
202-
Total Ops 1232 (Low Sample Size)
203-
Duration 10.070877291s (Good Duration)
204-
Real Throughput 122.33/s Observed Ops/sec (Wall Clock)
205-
Pure Throughput 130.12/s Theoretical Max (Low Overhead)
151+
Metric Value Description
152+
------ ----- -----------
153+
Workers 10
154+
Total Ops 1230 (Low Sample Size)
155+
Duration 10.068s (Good Duration)
156+
Real Throughput 122.17/s Observed Ops/sec (Wall Clock)
157+
Pure Throughput 123.04/s Theoretical Max (Low Overhead)
206158

207159
Latency Distribution:
208-
Min 61.2545ms
209-
P50 (Median) 75.461375ms
210-
Average 76.852256ms
211-
P95 93.50851ms
212-
P99 106.198982ms
213-
Max 144.872375ms (Stable Tail)
160+
Min 59.895916ms
161+
P50 (Median) 77.717333ms
162+
Average 81.27214ms
163+
P95 112.28194ms
164+
P99 137.126207ms
165+
P99.9 189.117473ms
166+
Max 215.981417ms (Stable Tail)
214167

215168
Stability Metrics:
216-
Std Dev 9.28799ms
217-
IQR 10.909229ms Interquartile Range
218-
Jitter 9.755984ms Avg delta per worker
219-
CV 12.09% Moderate Variance (10-20%)
220-
221-
Memory 1282384 B/op Allocated bytes per operation
222-
Allocs 18668 allocs/op Allocations per operation
169+
Std Dev 16.96192ms
170+
IQR 19.050834ms Interquartile Range
171+
Jitter 15.937043ms Avg delta per worker
172+
CV 20.87% Unstable (>20%) - Result is Noisy
173+
174+
System Health & Reliability:
175+
Error Rate 0.0000% (100% Success) (0 errors)
176+
Memory 1159374 B/op Allocated bytes per operation
177+
Allocs 17213 allocs/op Allocations per operation
178+
Alloc Rate 133.20 MB/s Memory pressure on system
179+
GC Overhead 1.27% (High GC Pressure)
180+
GC Pause 127.435871ms Total Stop-The-World time
181+
GC Cycles 264 Full garbage collection cycles
223182

224183
Latency Heatmap (Dynamic Range):
225184
Range Freq Distribution Graph
226-
61.2545ms-63.948502ms 36 ███████ (2.9%)
227-
63.948502ms-66.760987ms 86 █████████████████ (7.0%)
228-
66.760987ms-69.697167ms 152 ███████████████████████████████ (12.3%)
229-
69.697167ms-72.762481ms 181 █████████████████████████████████████ (14.7%)
230-
72.762481ms-75.962609ms 195 ████████████████████████████████████████ (15.8%)
231-
75.962609ms-79.303481ms 179 ████████████████████████████████████ (14.5%)
232-
79.303481ms-82.791286ms 152 ███████████████████████████████ (12.3%)
233-
82.791286ms-86.432486ms 94 ███████████████████ (7.6%)
234-
86.432486ms-90.233828ms 59 ████████████ (4.8%)
235-
90.233828ms-94.202355ms 40 ████████ (3.2%)
236-
94.202355ms-98.345419ms 29 █████ (2.4%)
237-
98.345419ms-102.670697ms 9 █ (0.7%)
238-
102.670697ms-107.186203ms 8 █ (0.6%)
239-
107.186203ms-111.900303ms 4 (0.3%)
240-
111.900303ms-116.821732ms 2 (0.2%)
241-
116.821732ms-121.959608ms 3 (0.2%)
242-
121.959608ms-127.32345ms 1 (0.1%)
243-
127.32345ms-132.923196ms 1 (0.1%)
244-
138.769222ms-144.872375ms 1 (0.1%)
185+
59.895916ms-63.862831ms 98 ██████████████████████ (8.0%)
186+
63.862831ms-68.092476ms 163 ████████████████████████████████████ (13.3%)
187+
68.092476ms-72.602251ms 170 ██████████████████████████████████████ (13.8%)
188+
72.602251ms-77.410709ms 172 █████████████████████████████████████ (14.0%)
189+
77.410709ms-82.537631ms 177 ████████████████████████████████████████ (14.4%)
190+
82.537631ms-88.004111ms 128 ████████████████████████████ (10.4%)
191+
88.004111ms-93.832637ms 119 ██████████████████████████ (9.7%)
192+
93.832637ms-100.047186ms 73 ████████████████ (5.9%)
193+
100.047186ms-106.673326ms 40 █████████ (3.3%)
194+
106.673326ms-113.738317ms 32 ███████ (2.6%)
195+
113.738317ms-121.271222ms 20 ████ (1.6%)
196+
121.271222ms-129.303034ms 14 ███ (1.1%)
197+
129.303034ms-137.866793ms 12 ██ (1.0%)
198+
137.866793ms-146.997731ms 3 (0.2%)
199+
146.997731ms-156.733413ms 4 (0.3%)
200+
167.11389ms-178.181868ms 2 (0.2%)
201+
178.181868ms-189.98288ms 1 (0.1%)
202+
189.98288ms-202.565475ms 1 (0.1%)
203+
202.565475ms-215.981417ms 1 (0.1%)
245204

246205
--- Analysis & Recommendations ---
247-
[WARN] Low sample size (1232). Results may not be statistically significant. Run for longer.
248-
[INFO] High Allocations (18668/op). This will trigger frequent GC cycles and increase Max Latency.
206+
[WARN] Low sample size (1230). Results may not be statistically significant. Run for longer.
207+
[FAIL] High Variance (CV 20.87%). System noise is affecting results. Isolate the machine or increase duration.
208+
[INFO] High Allocations (17213/op). This will trigger frequent GC cycles and increase Max Latency.
249209
----------------------------------
250-
--- PASS: TestParallelBenchmarkSender (20.83s)
251-
--- PASS: TestParallelBenchmarkSender/Setup(bits_32,_curve_BN254,_#i_2,_#o_2)_with_1_workers (10.39s)
252-
--- PASS: TestParallelBenchmarkSender/Setup(bits_32,_curve_BN254,_#i_2,_#o_2)_with_10_workers (10.44s)
210+
211+
--- Throughput Timeline ---
212+
Timeline: [▇▇▇█▇▇▇▇▆▇] (Max: 131 ops/s)
213+
214+
--- PASS: TestParallelBenchmarkSender (13.97s)
215+
--- PASS: TestParallelBenchmarkSender/Setup(bits_32,_curve_BN254,_#i_2,_#o_2)_with_10_workers (13.96s)
253216
PASS
254-
ok github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/v1/transfer 21.409s
217+
ok github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/v1/transfer 14.566s
255218
```

docs/benchmark/dlognogh/transfer_BenchmarkSender_results.md renamed to docs/benchmark/core/dlognogh/transfer_BenchmarkSender_results.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Benchmark Results: `token/core/zkatdlog/nogh/v1/transfer#BenchmarkSender`
22

3-
The output of `go test` can be found [here](./transfer_results.txt).
3+
The output of `go test` can be found [here](transfer_results.txt).
44

55
Here is the summary produced by `benchstat`.
66

File renamed without changes.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Identity Service - Idemix Benchmarks
2+
3+
Packages with benchmark tests:
4+
5+
- `token/services/identity/idemix`:
6+
- `TestParallelBenchmarkIdemixKMIdentity`: Generation of a pseudonym.
7+
- `TestParallelBenchmarkIdemixSign`: Generation of a signature given a pseudonym.
8+
- `TestParallelBenchmarkIdemixVerify`: Verification of a signature.
9+
- `TestParallelBenchmarkIdemixDeserializeSigner`: Deserialization of a Signer given a pseudonym.
10+
11+
Here is an execution example:
12+
13+
```shell
14+
➜ fabric-token-sdk git:(1284-dlog-validator-service-benchmark) ✗ go test ./token/services/identity/idemix -test.run=TestParallelBenchmarkIdemixDeserializeSigner -test.v -test.timeout 0 -workers="NumCPU" -duration="10s" -setup_samples=128
15+
=== RUN TestParallelBenchmarkIdemixDeserializeSigner
16+
Metric Value Description
17+
------ ----- -----------
18+
Workers 10
19+
Total Ops 18494 (Robust Sample)
20+
Duration 10.026s (Good Duration)
21+
Real Throughput 1844.65/s Observed Ops/sec (Wall Clock)
22+
Pure Throughput 1845.74/s Theoretical Max (Low Overhead)
23+
24+
Latency Distribution:
25+
Min 4.326583ms
26+
P50 (Median) 4.409667ms
27+
Average 5.417878ms
28+
P95 11.517116ms
29+
P99 16.813871ms
30+
P99.9 26.423944ms
31+
Max 98.053292ms (Stable Tail)
32+
33+
Stability Metrics:
34+
Std Dev 2.798676ms
35+
IQR 259.906µs Interquartile Range
36+
Jitter 1.502269ms Avg delta per worker
37+
CV 51.66% Unstable (>20%) - Result is Noisy
38+
39+
System Health & Reliability:
40+
Error Rate 0.0000% (100% Success) (0 errors)
41+
Memory 60665 B/op Allocated bytes per operation
42+
Allocs 694 allocs/op Allocations per operation
43+
Alloc Rate 103.69 MB/s Memory pressure on system
44+
GC Overhead 0.40% (Healthy)
45+
GC Pause 39.798795ms Total Stop-The-World time
46+
GC Cycles 92 Full garbage collection cycles
47+
48+
Latency Heatmap (Dynamic Range):
49+
Range Freq Distribution Graph
50+
4.326583ms-5.057208ms 14749 ████████████████████████████████████████ (79.8%)
51+
5.057208ms-5.911214ms 889 ██ (4.8%)
52+
5.911214ms-6.909436ms 535 █ (2.9%)
53+
6.909436ms-8.076226ms 444 █ (2.4%)
54+
8.076226ms-9.44005ms 434 █ (2.3%)
55+
9.44005ms-11.034182ms 435 █ (2.4%)
56+
11.034182ms-12.897514ms 302 (1.6%)
57+
12.897514ms-15.075505ms 373 █ (2.0%)
58+
15.075505ms-17.621292ms 196 (1.1%)
59+
17.621292ms-20.596982ms 78 (0.4%)
60+
20.596982ms-24.075175ms 32 (0.2%)
61+
24.075175ms-28.140727ms 15 (0.1%)
62+
28.140727ms-32.892825ms 5 (0.0%)
63+
32.892825ms-38.447405ms 2 (0.0%)
64+
38.447405ms-44.939982ms 1 (0.0%)
65+
44.939982ms-52.528953ms 2 (0.0%)
66+
52.528953ms-61.399467ms 1 (0.0%)
67+
83.88732ms-98.053292ms 1 (0.0%)
68+
69+
--- Analysis & Recommendations ---
70+
[FAIL] High Variance (CV 51.66%). System noise is affecting results. Isolate the machine or increase duration.
71+
[INFO] High Allocations (694/op). This will trigger frequent GC cycles and increase Max Latency.
72+
----------------------------------
73+
74+
--- Throughput Timeline ---
75+
Timeline: [▇▇▇▇▇▇▇█▇▇] (Max: 1906 ops/s)
76+
77+
--- PASS: TestParallelBenchmarkIdemixDeserializeSigner (13.82s)
78+
PASS
79+
ok github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/idemix 14.365s
80+
81+
```

0 commit comments

Comments
 (0)