Skip to content

feat(profiler): implement generic PerfProfiler for MPC protocols#22

Open
theroguevigilante wants to merge 1 commit intoLFDT-Lockness:mfrom
theroguevigilante:feat/generic-profiler
Open

feat(profiler): implement generic PerfProfiler for MPC protocols#22
theroguevigilante wants to merge 1 commit intoLFDT-Lockness:mfrom
theroguevigilante:feat/generic-profiler

Conversation

@theroguevigilante
Copy link
Copy Markdown

Description

Implements a generic PerfProfiler for MPC protocols by wrapping the MpcExecution trait. This allows for automated, round-by-round benchmarking of computation vs. I/O time without
protocol-specific instrumentation.

Key Features

  • PerfProfiler Wrapper: Intercepts send and complete calls to measure execution timing.
  • ProfilerExt Trait: Provides an easy .profile() method to opt-in to profiling.
  • Statistical Analysis: Built-in support for calculating Mean, StdDev, and Percentiles (p50, p75, p90) across multiple runs.
  • Formatted Output: Display implementation for clean terminal reporting.

@ZiaCheemaGit
Copy link
Copy Markdown

@theroguevigilante please give a heads up when starting on something.
However I was also looking into the issue and was curious how you implemented this so I cloned your patch and tested in my workspace.
You can keep nostd by importing from alloc and core e.t.c.
Also I dont know if its a good idea, I used the profiler directly in random_generation_protocol. It looked to work fine.


running 3 tests
RUST_TESTS_SEED=7a657b93375110ed36e944bb03c18388e83fe805f864e38543f325c8c64ded3a
RUST_TESTS_SEED=9805ea2ab1203315369a24da2f8ee1f5e433cabd5c6efe630c885ea7ad6cbbf4
=== MPC Performance Report ===
Round 1: Computation: 55.855µs, I/O: 11.908µs
Round 0: Computation: 237ns, I/O: 185.847µs
Round 1: Computation: 585ns, I/O: 18.356µs
Round 2: Computation: 100.334µs, I/O: 0ns
------------------------------
Total Computation: 157.011µs
Total I/O:         216.111µs
Total Time:        373.122µs

=== MPC Performance Report ===
Round 1: Computation: 54.438µs, I/O: 10.615µs
Round 0: Computation: 235ns, I/O: 31.127µs
Round 1: Computation: 3.203µs, I/O: 2.442668ms
Round 2: Computation: 145.427µs, I/O: 0ns
------------------------------
Total Computation: 203.303µs
Total I/O:         2.48441ms
Total Time:        2.687713ms

=== MPC Performance Report ===
Round 1: Computation: 51.508µs, I/O: 17.401µs
Round 0: Computation: 607ns, I/O: 329.475µs
Round 1: Computation: 824ns, I/O: 2.620497ms
Round 2: Computation: 85.934µs, I/O: 0ns
------------------------------
Total Computation: 138.873µs
Total I/O:         2.967373ms
Total Time:        3.106246ms

=== MPC Performance Report ===
Round 1: Computation: 37.594µs, I/O: 9.016µs
Round 0: Computation: 291ns, I/O: 290.103µs
Round 1: Computation: 582ns, I/O: 2.741237ms
Round 2: Computation: 78.638µs, I/O: 0ns
------------------------------
Total Computation: 117.105µs
Total I/O:         3.040356ms
Total Time:        3.157461ms

=== MPC Performance Report ===
Round 1: Computation: 36.063µs, I/O: 10.334µs
Round 0: Computation: 434ns, I/O: 249.289µs
Round 1: Computation: 911ns, I/O: 2.857082ms
Round 2: Computation: 119.969µs, I/O: 0ns
------------------------------
Total Computation: 157.377µs
Total I/O:         3.116705ms
Total Time:        3.274082ms

Output randomness: bb9c18a2b37992c25f4c1acaeab91aeda9106773390c0f471de633b2e2c54109
=== MPC Performance Report ===
Round 1: Computation: 41.998µs, I/O: 4.299µs
Round 0: Computation: 339ns, I/O: 285.05µs
Round 1: Computation: 665ns, I/O: 13.356µs
Round 2: Computation: 107.471µs, I/O: 0ns
------------------------------
Total Computation: 150.473µs
Total I/O:         302.705µs
Total Time:        453.178µs

test tests::simulation ... ok
=== MPC Performance Report ===
Round 1: Computation: 44.191µs, I/O: 5.168µs
Round 0: Computation: 674ns, I/O: 25.51µs
Round 1: Computation: 3µs, I/O: 374.169µs
Round 2: Computation: 111.766µs, I/O: 0ns
------------------------------
Total Computation: 159.631µs
Total I/O:         404.847µs
Total Time:        564.478µs

RUST_TESTS_SEED=58d69cb1eac246bc7d2a0ba5cdcada7227e73ec9642031ec050fc436c968e916
=== MPC Performance Report ===
Round 1: Computation: 57.17µs, I/O: 43.064µs
Round 0: Computation: 808ns, I/O: 3.406539ms
Round 1: Computation: 934ns, I/O: 477.108µs
Round 2: Computation: 138.188µs, I/O: 0ns
------------------------------
Total Computation: 197.1µs
Total I/O:         3.926711ms
Total Time:        4.123811ms

=== MPC Performance Report ===
Round 1: Computation: 2.93947ms, I/O: 12.455µs
Round 0: Computation: 710ns, I/O: 403.171µs
Round 1: Computation: 443ns, I/O: 832.108µs
Round 2: Computation: 91.932µs, I/O: 0ns
------------------------------
Total Computation: 3.032555ms
Total I/O:         1.247734ms
Total Time:        4.280289ms

=== MPC Performance Report ===
Round 1: Computation: 45.818µs, I/O: 6.615µs
Round 0: Computation: 10.096µs, I/O: 337.034µs
Round 1: Computation: 1.212µs, I/O: 945.989µs
Round 2: Computation: 82.554µs, I/O: 0ns
------------------------------
Total Computation: 139.68µs
Total I/O:         1.289638ms
Total Time:        1.429318ms

=== MPC Performance Report ===
Round 1: Computation: 61.73µs, I/O: 9.072µs
Round 0: Computation: 654ns, I/O: 17.625µs
Round 1: Computation: 3.729µs, I/O: 32.48µs
Round 2: Computation: 64.012µs, I/O: 0ns
------------------------------
Total Computation: 130.125µs
Total I/O:         59.177µs
Total Time:        189.302µs

Output randomness: d30939769306a951dbf021a31041fec7b3819ea01c341e9088843d342191b6ca
test tests::state_machine ... ok
test tests::simulation_async ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Signed-off-by: theroguevigilante <naimish82@proton.me>
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.

2 participants