Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate AccountId::compute_account_seed multi-threaded vs single-threaded performance #1056

Closed
PhilippGackstatter opened this issue Jan 9, 2025 · 2 comments
Assignees
Milestone

Comments

@PhilippGackstatter
Copy link
Contributor

Investigate whether using multiple threads for account ID computation still makes sense due to the PoW requirements being much lower after #982.
The trigger for this issue is that the single-threaded benchmark for account IDs outperforms the multi-threaded one:

Multi-threaded:

Benchmarking grind-seed/Grind regular on-chain account seed: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 20.0s. You may wish to increase target time to 24.3s, enable flat sampling, or reduce sample count to 60.
grind-seed/Grind regular on-chain account seed
                        time:   [4.8463 ms 4.9013 ms 4.9553 ms]
Found 10 outliers among 100 measurements (10.00%)
  5 (5.00%) low severe
  1 (1.00%) low mild
  4 (4.00%) high severe
Benchmarking grind-seed/Grind fungible faucet on-chain account seed: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 20.0s. You may wish to increase target time to 24.3s, enable flat sampling, or reduce sample count to 60.
grind-seed/Grind fungible faucet on-chain account seed
                        time:   [4.8270 ms 4.8631 ms 4.9002 ms]
Found 16 outliers among 100 measurements (16.00%)
  3 (3.00%) low severe
  7 (7.00%) low mild
  3 (3.00%) high mild
  3 (3.00%) high severe

Single-threaded:

grind-seed/Grind regular on-chain account seed
                        time:   [2.4025 ms 2.4436 ms 2.4843 ms]
                        change: [-52.238% -50.167% -48.090%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
  1 (1.00%) low severe
  4 (4.00%) low mild
  1 (1.00%) high mild
  2 (2.00%) high severe
grind-seed/Grind fungible faucet on-chain account seed
                        time:   [2.4048 ms 2.4617 ms 2.5198 ms]
                        change: [-51.462% -49.524% -47.735%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) low severe

The actual grinding in the single-threaded approach only takes 2-3 milliseconds, so perhaps the multi-threaded approach is now more inefficient due to spawning threads, context switching and similar management tasks. We may want to investigate this by profiling to make sure.
If single threaded performance is better, we should disable multi-threading for now and reintroduce later if necessary.

Note that this uses the changes to the benchmark in #1055 (mainly using a different seed for each iteration which previously biased the result).

@bobbinth
Copy link
Contributor

bobbinth commented Jan 9, 2025

Yes, I would say let's disable it (3ms for single-threaded is more than good enough, even if multi-threaded implementation turns out to be faster). If we need to enforce more significant PoW in the future (e.g., over 10 bits), we can re-enable it.

@PhilippGackstatter
Copy link
Contributor Author

Closed by #1061.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants