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

Add {100,10,1}-wallet restore benchmarks #2243

Merged
merged 4 commits into from
Oct 19, 2020

Conversation

Anviking
Copy link
Member

@Anviking Anviking commented Oct 14, 2020

Issue Number

ADP-469

Overview

  • Auxiliary: Make benchmark actually respect passing in --node-db
  • Auxiliary: Add --running-node SOCKET_PATH for easier development
  • Benchmark restoring 100, 10 and 1 wallet to 1%
    • Some tweaks to helpers to support this
  • Refactor to make the benchmark declarations more high-level and readable
  • Make sure the plotting of the results hasn't boken

Comments

  • Currently we won't a get plot for these new multi-wallet benchmarks, like for the existing ones. Could consider adding in another PR.
  • Open to disagreement on only restoring 1% (here is the old thread), but I think even 10% might be tricky to pull off in this PR. We'd need much more work for that.

@@ -711,7 +769,7 @@ waitForNodeSync tr nw = loop 10

data BenchmarkLog (n :: NetworkDiscriminant)
= MsgNodeTipTick BlockHeader SyncProgress
| MsgRestorationTick SyncProgress
| MsgRestorationTick POSIXTime [SyncProgress]
Copy link
Member Author

Choose a reason for hiding this comment

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

Why did I add this? Might not be needed yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

well, below you don't use it in toText, so probably superflouous ;-)

Copy link
Contributor

Choose a reason for hiding this comment

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

But why not introduce MsgRestorationTick [(POSIXTime,SyncProgress)] to have this time for each sync progress? that would be useful probably

@Anviking Anviking force-pushed the anviking/ADP-469/100-wallet-restore branch from 768675c to 03d31a3 Compare October 14, 2020 14:57
(walletSeq "0.4-percent-seq" $ mkSeqAnyState' @4 networkProxy)
benchmarksSeq
runBenchmarks
[ benchRestoreMultipleWallets 1
Copy link
Member Author

Choose a reason for hiding this comment

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

Takes 6s to reach 1%.

I suspect the extrapolated value (600s to 100%) is a bit wrong.

  • Could increase the number of wallets for this test only
  • Could leave it as is
  • Could increase the restore-to target for this test only
  • Could increase restore-to target for all {1,10,100} cases (but 100 would be really slow)

Copy link
Member Author

@Anviking Anviking Oct 14, 2020

Choose a reason for hiding this comment

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

Locally 1 wallet takes 276.4 s, vs 600s extrapolated, so pretty wrong, yes.

I should also note though, that when I compared 100 wallets to 1% extrapolated vs 100 wallets to 10%, they were very similar.

Copy link
Contributor

Choose a reason for hiding this comment

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

so what's executive summary of the above?

Copy link
Member Author

@Anviking Anviking Oct 15, 2020

Choose a reason for hiding this comment

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

Summary:

  1. Should restore the 1 wallet to 10% for better extrapolation. But we can keep 10 and 100 wallets restoring to 1%, where it doesn't matter much.
  2. There may be some interesting slowdowns (e.g. 10%, 16%), only visible when restoring to 100% (as Piotr also suggested), but I think we can ignore that in this PR.

Based on the data:

  • To 1%
    • 1 wallets -> 4.015s (extrapolation is 54% higher than the to-10% value ❌)
    • 10 wallets -> 24.62s (extrapolation is 0.9% higher than the to-10% value 🆗 )
    • 100 wallets -> 345.0s (extrapolation is 0.8% higher than the to-10% value 🆗 )
  • To 10%
    • 1 wallets -> 26.13s (extrapolation is 9.3% lower than the to-100% value 🤔 )
    • 10 wallets -> 244.0s (extrapolation is 14.1% lower than the to-100% value 🤔 )
    • 100 wallets -> 3423s (IIRC)
  • To 100% (includes the Shelley part of the chain)
    • 1 wallets -> 288s
    • 10 wallets -> 2842s
    • 100 wallets -> 38578s

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

@Anviking Anviking marked this pull request as ready for review October 14, 2020 15:11
@Anviking Anviking self-assigned this Oct 14, 2020
@Anviking
Copy link
Member Author

@Anviking Anviking requested a review from paweljakubas October 14, 2020 15:17
void $ withNetworkConfiguration args $ \nodeConfig ->
withCardanoNode (trMessageText tr) nodeConfig $ \cp ->
action tr (networkConfig args) (nodeSocketFile cp)
case argUseAlreadyRunningNodeSocketPath args of
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

(walletRnd "0.4-percent-rnd" $ mkRndAnyState @4)
[walletRnd (showPercent permillProxy <> "-percent-rnd")
$ mkRndAnyState' permillProxy networkProxy]
True -- Write progress to .timelog file
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment correct? The one in line 235 is opposite but the value is also True

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, the value was supposed to be False on line 235.

Could have added a new datatype to better represent this, but maybe I should more fundamentally refactor the bench_restoration function instead 🤔

@@ -9,6 +9,7 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NoMonoLocalBinds #-}
Copy link
Contributor

Choose a reason for hiding this comment

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

ok, will need to read about it 😅 At this moment do not understand why it is used

Copy link
Member Author

Choose a reason for hiding this comment

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

So we have the main bench_results function with a bunch of arguments, type parameters and constraints.

I wanted to define more descriptive helpers where I apply most of the boring arguments, e.g.:

    let benchRestoreRndWithOwnership permillProxy = bench_restoration
            networkProxy
            (trMessageText tr)
            socketFile
            np
            vData
            [walletRnd (showPercent permillProxy <> "-percent-rnd")
                $ mkRndAnyState' permillProxy networkProxy]
            True -- Write progress to .timelog file
            (unsafeMkPercentage 1)
            benchmarksRnd

But the per-mille ownership is a type parameter, and Haskell will fix it when inferring the type of the let binding.

benchRestoreRndWithOwnership (Proxy @0) -- compiles
benchRestoreRndWithOwnership (Proxy @1) -- Expected type: Proxy 0; Actual type: Proxy 1

Moving it to a where-clause, and explicitly specifying forall (p :: Nat) didn't seem like a good solution because the full type signature is really big and cumbersome, and I wouldn't have access to the locally bound vData, np, networkProxy.

With NoMonoLocalBinds it just works.

Looking here it seems that MonoLocalBinds is off by default, but enabled automatically by GADTs. Didn't know that.

The extension MonoLocalBinds is implied by TypeFamilies and GADTs. You can switch it off again with NoMonoLocalBinds but type inference becomes less predictable if you do so. (Read the papers!)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

@paweljakubas paweljakubas left a comment

Choose a reason for hiding this comment

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

LGTM

@Anviking Anviking force-pushed the anviking/ADP-469/100-wallet-restore branch 2 times, most recently from c07e99c to 6839b47 Compare October 15, 2020 15:56
benchmarksSeq
[ benchRestoreMultipleWallets 1 (unsafeMkPercentage 0.1)
, benchRestoreMultipleWallets 10 (unsafeMkPercentage 0.01)
, benchRestoreMultipleWallets 100 (unsafeMkPercentage 0.01)
Copy link
Member

Choose a reason for hiding this comment

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

Why not using the same percentage here? That will skew the benchmark a bit, wouldn't it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Why not using the same percentage here?

To make it run in a few minutes rather than more than an hour.

See #2243 (comment)

That will skew the benchmark a bit, wouldn't it?

Well, only if you interpret in the wrong way.

Copy link
Member

Choose a reason for hiding this comment

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

I mean, why not:

        [ benchRestoreMultipleWallets 1 (unsafeMkPercentage 0.01)
        , benchRestoreMultipleWallets 10 (unsafeMkPercentage 0.01)
        , benchRestoreMultipleWallets 100 (unsafeMkPercentage 0.01)

The first 0.1 looks like a typo to me ?

Copy link
Member Author

@Anviking Anviking Oct 16, 2020

Choose a reason for hiding this comment

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

Ah — the extrapolation from 0.01 to 0.1 is 54% off because it is so fast (imprecise start and stop times + ramping-up time, I take).

Extrapolating from 0.01 to 0.1 in the for 10 and 100 wallets saves an hour of time, but the accuracy of the extrapolation seem within 1%.

@Anviking Anviking force-pushed the anviking/ADP-469/100-wallet-restore branch from dbd4938 to 6c9422b Compare October 17, 2020 18:37
@Anviking
Copy link
Member Author

https://buildkite.com/input-output-hk/cardano-wallet-nightly/builds/680#ea0dfcad-4a8b-4461-99cc-a826b0a4eba1

BenchSeqResults:
  benchName: 1-wallets-to-0.1
  restoreTime: 40.50 s
  readWalletTime: 2.820 ms
  listAddressesTime: 156.5 μs
  listTransactionsTime: 552.8 μs
  estimateFeesTime: 9.631 s
  walletOverview:
     number of addresses: 20
     number of transactions: -0
     = Total value of -0 lovelace across 0 UTxOs

BenchSeqResults:
  benchName: 10-wallets-to-0.01
  restoreTime: 32.13 s
  readWalletTime: 37.23 ms
  listAddressesTime: 1.256 ms
  listTransactionsTime: 1.549 ms
  estimateFeesTime: 12.66 s
  walletOverview:
     number of addresses: 20
     number of transactions: -0
     = Total value of -0 lovelace across 0 UTxOs

BenchSeqResults:
  benchName: 100-wallets-to-0.01
  restoreTime: 551.2 s
  readWalletTime: 7.828 ms
  listAddressesTime: 99.44 μs
  listTransactionsTime: 665.3 μs
  estimateFeesTime: 19.78 s
  walletOverview:
     number of addresses: 20
     number of transactions: -0
     = Total value of -0 lovelace across 0 UTxOs

@Anviking Anviking force-pushed the anviking/ADP-469/100-wallet-restore branch from 6c9422b to 9b22f9e Compare October 19, 2020 10:52
@Anviking
Copy link
Member Author

🤞
bors r+

iohk-bors bot added a commit that referenced this pull request Oct 19, 2020
2243: Add {100,10,1}-wallet restore benchmarks r=Anviking a=Anviking

# Issue Number

ADP-469

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] Auxiliary: Make benchmark actually respect passing in `--node-db`
- [x] Auxiliary: Add `--running-node SOCKET_PATH` for easier development
- [x] Benchmark restoring 100, 10 and 1 wallet to 1%
    - [x] Some tweaks to helpers to support this
- [x] Refactor to make the benchmark declarations more high-level and readable
- [x] Make sure the plotting of the results hasn't boken

# Comments

- Currently we won't a get plot for these new multi-wallet benchmarks, like for the existing ones. Could consider adding in another PR.
- Open to disagreement on only restoring 1% ([here](https://input-output-rnd.slack.com/archives/GBT05825V/p1602674480071800?thread_ts=1602142785.076200&cid=GBT05825V) is the old thread), but I think even 10% might be tricky to pull off in this PR. We'd need much more work for that.

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 19, 2020

Build failed:


builder for '/nix/store/cd3n0bwmg2g515f2h7w3lcrn1369f55g-dot-cabal-hackage.haskell.org-at-2020-10-03T000000Z.drv' failed with exit code 1
--
  | cannot build derivation '/nix/store/p4qz6gfr3z9dn743m64lv6s4dmrr8qar-haskell-language-server-plan-to-nix-pkgs.drv': 1 dependencies couldn't be built


@Anviking
Copy link
Member Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 19, 2020

Build succeeded:

@iohk-bors iohk-bors bot merged commit 5c00a79 into master Oct 19, 2020
@iohk-bors iohk-bors bot deleted the anviking/ADP-469/100-wallet-restore branch October 19, 2020 15:19
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.

3 participants