Skip to content

perf(bls12-381-gurvy): Optimize BLS12-381-GURVY Zr using fr.Element (reduce allocations)#45

Merged
adecaro merged 3 commits into
IBM:mainfrom
neetance:perf/bls12-381-gurvy-fr-element-zr
Apr 24, 2026
Merged

perf(bls12-381-gurvy): Optimize BLS12-381-GURVY Zr using fr.Element (reduce allocations)#45
adecaro merged 3 commits into
IBM:mainfrom
neetance:perf/bls12-381-gurvy-fr-element-zr

Conversation

@neetance

Copy link
Copy Markdown
Contributor

Summary

This PR optimizes the BLS12-381 GURVY driver by replacing the big.Int-based scalar (Zr) representation with fr.Element.

The goal is to eliminate repeated big.Int <-> fr.Element conversions in scalar arithmetic and reduce allocation overhead in cryptographic operations.


Key Changes

  • Replace:

    type Zr struct {
        big.Int
        Modulus big.Int
    }

    with:

    type Zr struct {
        val       fr.Element
        rawBigInt *big.Int
    }
  • Use fr.Element for all scalar arithmetic

  • Eliminate repeated SetBigInt / BigInt conversions

  • Introduce rawBigInt only for special cases (e.g. GroupOrder)

  • Optimize ModMul / ModAddMul / ModAddMul2 / ModAddMul3 using stack variables

  • Optimize MultiScalarMul to avoid per-scalar conversions

  • Use sync.Pool for big.Int only where required


Benchmark results

I ran the benchmark for the token-sdk csp proofs for the current mathlib library and the for the modified library locally and here are the results:

Before mathlib changes:

go test ./token/core/zkatdlog/nogh/v1/validator     -test.run=TestParallelBenchmarkValidatorTransfer     -test.v -test.timeout 0     -bits="32" -curves="BLS12_381_BBS_GURVY"     -num_inputs="2" -num_outputs="2"     -workers="10" -duration="30s" -setup_samples=128     -executor="pool" -proof_type="csp"
=== RUN   TestParallelBenchmarkValidatorTransfer
=== RUN   TestParallelBenchmarkValidatorTransfer/Setup(bits_32,_curve_BLS12_381_BBS_GURVY,_#i_2,_#o_2)_with_10_workers
Metric           Value     Description
------           -----     -----------
Workers          10        
Total Ops        12517     (Robust Sample)
Duration         30.02s    (Good Duration)
Real Throughput  416.96/s  Observed Ops/sec (Wall Clock)
Pure Throughput  417.23/s  Theoretical Max (Low Overhead)

Latency Distribution:
 Min           16.139812ms  
 P50 (Median)  23.68153ms   
 Average       23.967572ms  
 P95           28.548673ms  
 P99           31.792143ms  
 P99.9         40.186691ms  
 Max           48.299609ms  (Stable Tail)

Stability Metrics:
 Std Dev  2.646878ms  
 IQR      3.145871ms  Interquartile Range
 Jitter   2.450194ms  Avg delta per worker
 CV       11.04%      Moderate Variance (10-20%)

System Health & Reliability:
 Error Rate          0.0000%         (100% Success) (0 errors)
 Memory              755715 B/op     Allocated bytes per operation
 Allocs              7582 allocs/op  Allocations per operation
 Alloc Rate          297.99 MB/s     Memory pressure on system
 GC Overhead         5.68%           (Severe GC Thrashing)
 GC Pause            1.706533097s    Total Stop-The-World time
 GC Cycles           3807            Full garbage collection cycles
 Goroutines Created  229             Net goroutines above baseline during recording

Latency Heatmap (Dynamic Range):
Range                     Freq  Distribution Graph
 16.139812ms-17.049071ms  7      (0.1%)
 17.049071ms-18.009555ms  20     (0.2%)
 18.009555ms-19.024149ms  119   █ (1.0%)
 19.024149ms-20.095901ms  359   █████ (2.9%)
 20.095901ms-21.228033ms  1051  ███████████████ (8.4%)
 21.228033ms-22.423944ms  1986  █████████████████████████████ (15.9%)
 22.423944ms-23.687229ms  2733  ████████████████████████████████████████ (21.8%)
 23.687229ms-25.021683ms  2563  █████████████████████████████████████ (20.5%)
 25.021683ms-26.431315ms  1805  ██████████████████████████ (14.4%)
 26.431315ms-27.920361ms  996   ██████████████ (8.0%)
 27.920361ms-29.493295ms  496   ███████ (4.0%)
 29.493295ms-31.154842ms  217   ███ (1.7%)
 31.154842ms-32.909994ms  83    █ (0.7%)
 32.909994ms-34.764026ms  37     (0.3%)
 34.764026ms-36.722507ms  21     (0.2%)
 36.722507ms-38.791322ms  7      (0.1%)
 38.791322ms-40.976687ms  5      (0.0%)
 40.976687ms-43.285167ms  6      (0.0%)
 43.285167ms-45.723699ms  4      (0.0%)
 45.723699ms-48.299609ms  2      (0.0%)

--- Analysis & Recommendations ---
[INFO] High Allocations (7582/op). This will trigger frequent GC cycles and increase Max Latency.
----------------------------------

--- Throughput Timeline ---
Timeline: [▇▇▇▇▆▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇█▇▇▇▇▇▇▆] (Max: 445 ops/s)

--- PASS: TestParallelBenchmarkValidatorTransfer (51.25s)
    --- PASS: TestParallelBenchmarkValidatorTransfer/Setup(bits_32,_curve_BLS12_381_BBS_GURVY,_#i_2,_#o_2)_with_10_workers (51.22s)
PASS
ok      github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/v1/validator      51.275s

After the changes:

go test ./token/core/zkatdlog/nogh/v1/validator     -test.run=TestParallelBenchmarkValidatorTransfer     -test.v -test.timeout 0     -bits="32" -curves="BLS12_381_BBS_GURVY"     -num_inputs="2" -num_outputs="2"     -workers="10" -duration="30s" -setup_samples=128     -executor="pool" -proof_type="csp"
=== RUN   TestParallelBenchmarkValidatorTransfer
=== RUN   TestParallelBenchmarkValidatorTransfer/Setup(bits_32,_curve_BLS12_381_BBS_GURVY,_#i_2,_#o_2)_with_10_workers
Metric           Value     Description
------           -----     -----------
Workers          10        
Total Ops        12501     (Robust Sample)
Duration         30.017s   (Good Duration)
Real Throughput  416.47/s  Observed Ops/sec (Wall Clock)
Pure Throughput  416.72/s  Theoretical Max (Low Overhead)

Latency Distribution:
 Min           15.951133ms  
 P50 (Median)  23.535358ms  
 Average       23.996765ms  
 P95           29.357612ms  
 P99           33.466011ms  
 P99.9         39.624403ms  
 Max           50.168388ms  (Stable Tail)

Stability Metrics:
 Std Dev  2.961585ms  
 IQR      3.513779ms  Interquartile Range
 Jitter   2.650695ms  Avg delta per worker
 CV       12.34%      Moderate Variance (10-20%)

System Health & Reliability:
 Error Rate          0.0000%         (100% Success) (0 errors)
 Memory              684304 B/op     Allocated bytes per operation
 Allocs              6604 allocs/op  Allocations per operation
 Alloc Rate          269.98 MB/s     Memory pressure on system
 GC Overhead         5.42%           (Severe GC Thrashing)
 GC Pause            1.627135177s    Total Stop-The-World time
 GC Cycles           3608            Full garbage collection cycles
 Goroutines Created  188             Net goroutines above baseline during recording

Latency Heatmap (Dynamic Range):
Range                     Freq  Distribution Graph
 15.951133ms-16.891704ms  4      (0.0%)
 16.891704ms-17.887736ms  21     (0.2%)
 17.887736ms-18.942501ms  116   █ (0.9%)
 18.942501ms-20.05946ms   451   ██████ (3.6%)
 20.05946ms-21.242282ms   1224  ██████████████████ (9.8%)
 21.242282ms-22.49485ms   2294  █████████████████████████████████ (18.4%)
 22.49485ms-23.821277ms   2704  ████████████████████████████████████████ (21.6%)
 23.821277ms-25.225918ms  2223  ████████████████████████████████ (17.8%)
 25.225918ms-26.713384ms  1588  ███████████████████████ (12.7%)
 26.713384ms-28.28856ms   915   █████████████ (7.3%)
 28.28856ms-29.956617ms   466   ██████ (3.7%)
 29.956617ms-31.723032ms  245   ███ (2.0%)
 31.723032ms-33.593606ms  132   █ (1.1%)
 33.593606ms-35.57448ms   54     (0.4%)
 35.57448ms-37.672157ms   35     (0.3%)
 37.672157ms-39.893526ms  18     (0.1%)
 39.893526ms-42.245879ms  5      (0.0%)
 42.245879ms-44.736941ms  2      (0.0%)
 44.736941ms-47.37489ms   2      (0.0%)
 47.37489ms-50.168388ms   2      (0.0%)

--- Analysis & Recommendations ---
[INFO] High Allocations (6604/op). This will trigger frequent GC cycles and increase Max Latency.
----------------------------------

--- Throughput Timeline ---
Timeline: [▇▇█▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇] (Max: 442 ops/s)

--- PASS: TestParallelBenchmarkValidatorTransfer (50.86s)
    --- PASS: TestParallelBenchmarkValidatorTransfer/Setup(bits_32,_curve_BLS12_381_BBS_GURVY,_#i_2,_#o_2)_with_10_workers (50.83s)
PASS
ok      github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/v1/validator      50.889s

We can see that:

allocs/op: 7582 -> 6604  (~13% reduction)

This is a considerable reduction in allocs/op as well as in B/op that we were aiming for

Observations

  • Significant reduction in temporary allocations
  • Execution time remains stable (no regressions)

Testing

  • All tests pass:

    go test -count=1 ./...
    
  • Benchmarks run successfully

  • No functional changes

Let me know if this is good 🙏

…duce allocations

Signed-off-by: Ankit Basu <ankitbasu14@gmail.com>
@neetance

neetance commented Apr 23, 2026

Copy link
Copy Markdown
Contributor Author

Hi @adecaro I submitted a pr here as you instructed. Following its merge, I will submit a pr in the token-sdk repo with appropriate changes in the csp library 🙏

Comment thread driver/gurvy/bls12381/frpool.go Outdated
Comment thread driver/gurvy/bls12381/bls12-381.go Outdated
@adecaro

adecaro commented Apr 24, 2026

Copy link
Copy Markdown
Member

Hi @neetance , great effort 🙏

I have left comments on the PR and the issues raised by the linter need to be fixed.
Please, open already a PR on the token-sdk that uses this commit so to make sure all the tests are passing there as well. Thanks much 🙏

@adecaro adecaro self-assigned this Apr 24, 2026
Signed-off-by: Ankit Basu <ankitbasu14@gmail.com>
@neetance

Copy link
Copy Markdown
Contributor Author

Hi @adecaro, thanks for the review 🙏
As requested, I have moved bigIntPool into a new file, bipool.go, and updated it to ensure that values are properly reset (v.SetInt64(0)) before being put back into the underlying sync.Pool. Also removed frpool.go since it was not used anymore.
Also introduced a bigIntOne = big.NewInt(1) package-level variable in bls12-381.go to prevent allocating a new big int on every call.
I replaced the inline big.NewInt(1) call inside IsOne() to reference this new variable.

@adecaro

adecaro commented Apr 24, 2026

Copy link
Copy Markdown
Member

@neetance , if you run make fmt it should fix the issues reported by the CI. Thanks 🙏

Signed-off-by: Ankit Basu <ankitbasu14@gmail.com>
@adecaro

adecaro commented Apr 24, 2026

Copy link
Copy Markdown
Member

HI @neetance , great the PR passed here. Please, let's test this commit on the token-sdk. If everything goes well, we merge everything 🙏

@adecaro

adecaro commented Apr 24, 2026

Copy link
Copy Markdown
Member

@neetance , can you run the tests without the pool? Just to make sure we don't loose in performance.

@neetance

Copy link
Copy Markdown
Contributor Author

@adecaro sure

I ran the tests in the other 2 executor modes and the results are fine, with improvements in allocs/op, and the rest of the metrics remaining same.

Here are results:

Serial:

go test ./token/core/zkatdlog/nogh/v1/validator     -test.run=TestParallelBenchmarkValidatorTransfer     -test.v -test.timeout 0     -bits="32" -curves="BLS12_381_BBS_GURVY"     -num_inputs="2" -num_outputs="2"     -workers="10" -duration="30s" -setup_samples=128     -executor="serial" -proof_type="csp"
=== RUN   TestParallelBenchmarkValidatorTransfer
=== RUN   TestParallelBenchmarkValidatorTransfer/Setup(bits_32,_curve_BLS12_381_BBS_GURVY,_#i_2,_#o_2)_with_10_workers
Metric           Value     Description
------           -----     -----------
Workers          10        
Total Ops        13050     (Robust Sample)
Duration         30.015s   (Good Duration)
Real Throughput  434.78/s  Observed Ops/sec (Wall Clock)
Pure Throughput  435.09/s  Theoretical Max (Low Overhead)

Latency Distribution:
 Min           16.867337ms  
 P50 (Median)  22.726983ms  
 Average       22.98394ms   
 P95           26.501278ms  
 P99           29.078973ms  
 P99.9         34.412237ms  
 Max           46.373636ms  (Stable Tail)

Stability Metrics:
 Std Dev  2.033969ms  
 IQR      2.401885ms  Interquartile Range
 Jitter   1.975919ms  Avg delta per worker
 CV       8.85%       (Acceptable 5-10%)

System Health & Reliability:
 Error Rate          0.0000%         (100% Success) (0 errors)
 Memory              683315 B/op     Allocated bytes per operation
 Allocs              6583 allocs/op  Allocations per operation
 Alloc Rate          281.71 MB/s     Memory pressure on system
 GC Overhead         5.31%           (Severe GC Thrashing)
 GC Pause            1.592491719s    Total Stop-The-World time
 GC Cycles           4273            Full garbage collection cycles
 Goroutines Created  20              Net goroutines above baseline during recording

Latency Heatmap (Dynamic Range):
Range                     Freq  Distribution Graph
 16.867337ms-17.742211ms  3      (0.0%)
 17.742211ms-18.662464ms  33     (0.3%)
 18.662464ms-19.630448ms  188   ██ (1.4%)
 19.630448ms-20.648639ms  956   ███████████ (7.3%)
 20.648639ms-21.719642ms  2347  ████████████████████████████ (18.0%)
 21.719642ms-22.846196ms  3335  ████████████████████████████████████████ (25.6%)
 22.846196ms-24.031182ms  2900  ██████████████████████████████████ (22.2%)
 24.031182ms-25.277631ms  1785  █████████████████████ (13.7%)
 25.277631ms-26.58873ms   889   ██████████ (6.8%)
 26.58873ms-27.967834ms   370   ████ (2.8%)
 27.967834ms-29.418468ms  127   █ (1.0%)
 29.418468ms-30.944345ms  58     (0.4%)
 30.944345ms-32.549365ms  27     (0.2%)
 32.549365ms-34.237635ms  15     (0.1%)
 34.237635ms-36.013471ms  7      (0.1%)
 36.013471ms-37.881417ms  1      (0.0%)
 37.881417ms-39.846249ms  6      (0.0%)
 41.912994ms-44.086936ms  2      (0.0%)
 44.086936ms-46.373636ms  1      (0.0%)

--- Analysis & Recommendations ---
[INFO] High Allocations (6583/op). This will trigger frequent GC cycles and increase Max Latency.
[PASS] RunBenchmark looks healthy and statistically sound.
----------------------------------

--- Throughput Timeline ---
Timeline: [▇█▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇] (Max: 455 ops/s)

--- PASS: TestParallelBenchmarkValidatorTransfer (60.11s)
    --- PASS: TestParallelBenchmarkValidatorTransfer/Setup(bits_32,_curve_BLS12_381_BBS_GURVY,_#i_2,_#o_2)_with_10_workers (60.09s)
PASS
ok      github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/v1/validator      60.131s

Unbounded:

go test ./token/core/zkatdlog/nogh/v1/validator     -test.run=TestParallelBenchmarkValidatorTransfer     -test.v -test.timeout 0     -bits="32" -curves="BLS12_381_BBS_GURVY"     -num_inputs="2" -num_outputs="2"     -workers="10" -duration="30s" -setup_samples=128     -executor="unbounded" -proof_type="csp"
=== RUN   TestParallelBenchmarkValidatorTransfer
=== RUN   TestParallelBenchmarkValidatorTransfer/Setup(bits_32,_curve_BLS12_381_BBS_GURVY,_#i_2,_#o_2)_with_10_workers
Metric           Value     Description
------           -----     -----------
Workers          10        
Total Ops        12957     (Robust Sample)
Duration         30.017s   (Good Duration)
Real Throughput  431.65/s  Observed Ops/sec (Wall Clock)
Pure Throughput  431.93/s  Theoretical Max (Low Overhead)

Latency Distribution:
 Min           15.509242ms  
 P50 (Median)  22.737774ms  
 Average       23.151724ms  
 P95           28.321918ms  
 P99           32.485906ms  
 P99.9         45.26043ms   
 Max           59.608668ms  (Stable Tail)

Stability Metrics:
 Std Dev  3.04341ms   
 IQR      3.49258ms   Interquartile Range
 Jitter   2.649418ms  Avg delta per worker
 CV       13.15%      Moderate Variance (10-20%)

System Health & Reliability:
 Error Rate          0.0000%         (100% Success) (0 errors)
 Memory              680968 B/op     Allocated bytes per operation
 Allocs              6594 allocs/op  Allocations per operation
 Alloc Rate          279.44 MB/s     Memory pressure on system
 GC Overhead         5.27%           (Severe GC Thrashing)
 GC Pause            1.583359022s    Total Stop-The-World time
 GC Cycles           3674            Full garbage collection cycles
 Goroutines Created  301             Net goroutines above baseline during recording

Latency Heatmap (Dynamic Range):
Range                     Freq  Distribution Graph
 15.509242ms-16.58924ms   8      (0.1%)
 16.58924ms-17.744446ms   68     (0.5%)
 17.744446ms-18.980095ms  411   █████ (3.2%)
 18.980095ms-20.30179ms   1332  █████████████████ (10.3%)
 20.30179ms-21.715522ms   2553  █████████████████████████████████ (19.7%)
 21.715522ms-23.2277ms    3063  ████████████████████████████████████████ (23.6%)
 23.2277ms-24.845181ms    2543  █████████████████████████████████ (19.6%)
 24.845181ms-26.575296ms  1577  ████████████████████ (12.2%)
 26.575296ms-28.425888ms  788   ██████████ (6.1%)
 28.425888ms-30.405349ms  338   ████ (2.6%)
 30.405349ms-32.52265ms   147   █ (1.1%)
 32.52265ms-34.787392ms   58     (0.4%)
 34.787392ms-37.209841ms  29     (0.2%)
 37.209841ms-39.800979ms  16     (0.1%)
 39.800979ms-42.572554ms  9      (0.1%)
 42.572554ms-45.537129ms  4      (0.0%)
 45.537129ms-48.708145ms  5      (0.0%)
 48.708145ms-52.099977ms  3      (0.0%)
 52.099977ms-55.728002ms  2      (0.0%)
 55.728002ms-59.608668ms  3      (0.0%)

--- Analysis & Recommendations ---
[INFO] High Allocations (6594/op). This will trigger frequent GC cycles and increase Max Latency.
----------------------------------

--- Throughput Timeline ---
Timeline: [▇▇▇▆▇▇▇█▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▆▇] (Max: 469 ops/s)

--- PASS: TestParallelBenchmarkValidatorTransfer (50.35s)
    --- PASS: TestParallelBenchmarkValidatorTransfer/Setup(bits_32,_curve_BLS12_381_BBS_GURVY,_#i_2,_#o_2)_with_10_workers (50.33s)
PASS
ok      github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/v1/validator      50.373s

To make sure, I undid the changes using git stash and ran the benchmarks again with results:

Serial:

go test ./token/core/zkatdlog/nogh/v1/validator     -test.run=TestParallelBenchmarkValidatorTransfer     -test.v -test.timeout 0     -bits="32" -curves="BLS12_381_BBS_GURVY"     -num_inputs="2" -num_outputs="2"     -workers="10" -duration="30s" -setup_samples=128     -executor="serial" -proof_type="csp"
=== RUN   TestParallelBenchmarkValidatorTransfer
=== RUN   TestParallelBenchmarkValidatorTransfer/Setup(bits_32,_curve_BLS12_381_BBS_GURVY,_#i_2,_#o_2)_with_10_workers
Metric           Value     Description
------           -----     -----------
Workers          10        
Total Ops        12821     (Robust Sample)
Duration         30.022s   (Good Duration)
Real Throughput  427.05/s  Observed Ops/sec (Wall Clock)
Pure Throughput  427.40/s  Theoretical Max (Low Overhead)

Latency Distribution:
 Min           17.378919ms  
 P50 (Median)  23.076963ms  
 Average       23.39737ms   
 P95           27.447994ms  
 P99           30.764982ms  
 P99.9         40.168017ms  
 Max           52.48992ms   (Stable Tail)

Stability Metrics:
 Std Dev  2.385817ms  
 IQR      2.823504ms  Interquartile Range
 Jitter   2.01968ms   Avg delta per worker
 CV       10.20%      Moderate Variance (10-20%)

System Health & Reliability:
 Error Rate          0.0000%         (100% Success) (0 errors)
 Memory              757236 B/op     Allocated bytes per operation
 Allocs              7562 allocs/op  Allocations per operation
 Alloc Rate          305.05 MB/s     Memory pressure on system
 GC Overhead         5.27%           (Severe GC Thrashing)
 GC Pause            1.581181332s    Total Stop-The-World time
 GC Cycles           4179            Full garbage collection cycles
 Goroutines Created  91              Net goroutines above baseline during recording

Latency Heatmap (Dynamic Range):
Range                     Freq  Distribution Graph
 17.378919ms-18.366458ms  17     (0.1%)
 18.366458ms-19.410113ms  132   █ (1.0%)
 19.410113ms-20.513073ms  707   █████████ (5.5%)
 20.513073ms-21.678707ms  2088  ███████████████████████████ (16.3%)
 21.678707ms-22.910578ms  3044  ████████████████████████████████████████ (23.7%)
 22.910578ms-24.212448ms  2966  ██████████████████████████████████████ (23.1%)
 24.212448ms-25.588295ms  1957  █████████████████████████ (15.3%)
 25.588295ms-27.042324ms  1117  ██████████████ (8.7%)
 27.042324ms-28.578976ms  451   █████ (3.5%)
 28.578976ms-30.202948ms  175   ██ (1.4%)
 30.202948ms-31.919199ms  80    █ (0.6%)
 31.919199ms-33.732975ms  38     (0.3%)
 33.732975ms-35.649817ms  24     (0.2%)
 35.649817ms-37.675581ms  6      (0.0%)
 37.675581ms-39.816457ms  4      (0.0%)
 39.816457ms-42.078987ms  10     (0.1%)
 42.078987ms-44.470082ms  1      (0.0%)
 44.470082ms-46.997049ms  1      (0.0%)
 46.997049ms-49.667608ms  1      (0.0%)
 49.667608ms-52.48992ms   2      (0.0%)

--- Analysis & Recommendations ---
[INFO] High Allocations (7562/op). This will trigger frequent GC cycles and increase Max Latency.
----------------------------------

--- Throughput Timeline ---
Timeline: [▇▇▇▇▇▇▇▇▇▆▆▇▇▇▇▇█▇▇▇█▇▇▇▇▇▇▇▇▇] (Max: 454 ops/s)

--- PASS: TestParallelBenchmarkValidatorTransfer (59.98s)
    --- PASS: TestParallelBenchmarkValidatorTransfer/Setup(bits_32,_curve_BLS12_381_BBS_GURVY,_#i_2,_#o_2)_with_10_workers (59.96s)
PASS
ok      github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/v1/validator      60.010s

Unbounded:

go test ./token/core/zkatdlog/nogh/v1/validator     -test.run=TestParallelBenchmarkValidatorTransfer     -test.v -test.timeout 0     -bits="32" -curves="BLS12_381_BBS_GURVY"     -num_inputs="2" -num_outputs="2"     -workers="10" -duration="30s" -setup_samples=128     -executor="unbounded" -proof_type="csp"
=== RUN   TestParallelBenchmarkValidatorTransfer
=== RUN   TestParallelBenchmarkValidatorTransfer/Setup(bits_32,_curve_BLS12_381_BBS_GURVY,_#i_2,_#o_2)_with_10_workers
Metric           Value     Description
------           -----     -----------
Workers          10        
Total Ops        13213     (Robust Sample)
Duration         30.016s   (Good Duration)
Real Throughput  440.20/s  Observed Ops/sec (Wall Clock)
Pure Throughput  440.52/s  Theoretical Max (Low Overhead)

Latency Distribution:
 Min           15.420865ms  
 P50 (Median)  22.41976ms   
 Average       22.700538ms  
 P95           26.879256ms  
 P99           29.806946ms  
 P99.9         34.529563ms  
 Max           38.906705ms  (Stable Tail)

Stability Metrics:
 Std Dev  2.376259ms  
 IQR      2.92677ms   Interquartile Range
 Jitter   2.418084ms  Avg delta per worker
 CV       10.47%      Moderate Variance (10-20%)

System Health & Reliability:
 Error Rate          0.0000%         (100% Success) (0 errors)
 Memory              757243 B/op     Allocated bytes per operation
 Allocs              7558 allocs/op  Allocations per operation
 Alloc Rate          314.27 MB/s     Memory pressure on system
 GC Overhead         5.46%           (Severe GC Thrashing)
 GC Pause            1.639767436s    Total Stop-The-World time
 GC Cycles           3997            Full garbage collection cycles
 Goroutines Created  321             Net goroutines above baseline during recording

Latency Heatmap (Dynamic Range):
Range                     Freq  Distribution Graph
 15.420865ms-16.151189ms  3      (0.0%)
 16.151189ms-16.916102ms  11     (0.1%)
 16.916102ms-17.717241ms  49     (0.4%)
 17.717241ms-18.556321ms  165   ██ (1.2%)
 18.556321ms-19.435139ms  505   ███████ (3.8%)
 19.435139ms-20.355578ms  1125  █████████████████ (8.5%)
 20.355578ms-21.319609ms  1970  ██████████████████████████████ (14.9%)
 21.319609ms-22.329295ms  2545  ████████████████████████████████████████ (19.3%)
 22.329295ms-23.3868ms    2412  █████████████████████████████████████ (18.3%)
 23.3868ms-24.494388ms    1856  █████████████████████████████ (14.0%)
 24.494388ms-25.65443ms   1174  ██████████████████ (8.9%)
 25.65443ms-26.869412ms   734   ███████████ (5.6%)
 26.869412ms-28.141934ms  344   █████ (2.6%)
 28.141934ms-29.474723ms  160   ██ (1.2%)
 29.474723ms-30.870632ms  77    █ (0.6%)
 30.870632ms-32.33265ms   48     (0.4%)
 32.33265ms-33.863909ms   16     (0.1%)
 33.863909ms-35.467688ms  12     (0.1%)
 35.467688ms-37.14742ms   3      (0.0%)
 37.14742ms-38.906705ms   4      (0.0%)

--- Analysis & Recommendations ---
[INFO] High Allocations (7558/op). This will trigger frequent GC cycles and increase Max Latency.
----------------------------------

--- Throughput Timeline ---
Timeline: [▇▇▇▇▇▇▇█▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇] (Max: 457 ops/s)

--- PASS: TestParallelBenchmarkValidatorTransfer (50.13s)
    --- PASS: TestParallelBenchmarkValidatorTransfer/Setup(bits_32,_curve_BLS12_381_BBS_GURVY,_#i_2,_#o_2)_with_10_workers (50.11s)
PASS
ok      github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/v1/validator      50.156s

As we can see, the allocs/op is considerably higher for the second results that ran without the changes in the current mathlib library.

Let me know if this is good 😄
Then I can push these changes to the token-sdk repository with this commit in the mathlib library 🙏

@adecaro

adecaro commented Apr 24, 2026

Copy link
Copy Markdown
Member

hey, great effort @neetance , thanks for taking the time to run the experiments. Please, go ahead with a PR on the token-sdk 🙏

@adecaro adecaro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adecaro adecaro merged commit c031379 into IBM:main Apr 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants