Skip to content

Commit

Permalink
Fix restore benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Apr 9, 2019
1 parent 5fb35ca commit 9c5f6df
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 31 deletions.
9 changes: 8 additions & 1 deletion .buildkite/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

set -euo pipefail

stack bench cardano-wallet:restore --interleaved-output --ba "+RTS -N2 -qg -A1m -I0 -T -M1G -h -RTS"
netname="${1-}"

if [ -z "$netname" ]; then
echo "usage: benchmark.sh NETWORK"
exit 1
fi

stack bench cardano-wallet:restore --interleaved-output --ba "$netname +RTS -N2 -qg -A1m -I0 -T -M1G -h -RTS"

hp2pretty restore.hp

Expand Down
9 changes: 7 additions & 2 deletions .buildkite/nightly.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
env:
NIX_PATH: "channel:nixos-19.03"
steps:
- label: 'Restore benchmarks'
command: "nix-shell -p nix git stack haskellPackages.hp2pretty buildkite-agent --run ./.buildkite/benchmark.sh"
- label: 'Restore benchmark - testnet'
command: "nix-shell -p nix git stack haskellPackages.hp2pretty buildkite-agent --run ./.buildkite/benchmark.sh testnet"
timeout_in_minutes: 60
agents:
system: x86_64-linux
- label: 'Restore benchmark - mainnet'
command: "nix-shell -p nix git stack haskellPackages.hp2pretty buildkite-agent --run ./.buildkite/benchmark.sh mainnet"
timeout_in_minutes: 60
agents:
system: x86_64-linux
3 changes: 3 additions & 0 deletions cardano-wallet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,12 @@ benchmark restore
-Werror
build-depends:
base
, ansi-terminal
, async
, cardano-wallet
, criterion-measurement
, deepseq
, docopt
, fmt
, generic-lens
, process
Expand All @@ -324,6 +326,7 @@ benchmark restore
main-is:
Main.hs
other-modules:
Cardano.CLI
Cardano.Launcher
if os(windows)
build-depends: Win32
Expand Down
42 changes: 14 additions & 28 deletions test/bench/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import Cardano.Launcher
import Cardano.Wallet
( NewWallet (..), WalletLayer (..), mkWalletLayer, unsafeRunExceptT )
import Cardano.Wallet.Network
( networkTip )
( NetworkLayer (..), networkTip )
import Cardano.Wallet.Network.HttpBridge
( newNetworkLayer )
import Cardano.Wallet.Primitive.AddressDerivation
( Passphrase (..) )
import Cardano.Wallet.Primitive.AddressDiscovery
( mkAddressPoolGap )
import Cardano.Wallet.Primitive.Types
( SlotId, WalletName (..) )
( SlotId (..), WalletName (..) )
import Control.Arrow
( left )
import Control.Concurrent
Expand All @@ -35,36 +35,22 @@ import Control.Monad
( mapM_ )
import Control.Monad.Fail
( MonadFail )
import Control.Monad.Trans.Except
( runExceptT )
import Criterion.Measurement
( getTime, initializeTime, secs )
import Data.Generics.Internal.VL.Lens
( (^.) )
import Data.Text
( Text )
import Data.Time.Clock.POSIX
( POSIXTime, getPOSIXTime )
import qualified Data.Text as T
import Data.Text.Class
( FromText (..), TextDecodingError (..), ToText (..) )
import Data.Time.Clock.POSIX
( POSIXTime, getPOSIXTime )
import Fmt
( fmt, (+|), (+||), (|+), (||+) )
import Say
( say )
import System.Exit
( die )

import Cardano.Wallet
( NewWallet (..), WalletLayer (..), mkWalletLayer )
import Cardano.Wallet.Network
( NetworkLayer, networkTip )
import Cardano.Wallet.Network.HttpBridge
( newNetworkLayer )
import Cardano.Wallet.Primitive.AddressDerivation
( Passphrase (..) )
import Cardano.Wallet.Primitive.AddressDiscovery
( mkAddressPoolGap )
import Cardano.Wallet.Primitive.Types
( SlotId (..), WalletName (..) )
import System.Environment
( getArgs )

Expand All @@ -79,7 +65,7 @@ main :: IO ()
main = do
network <- getArgs >>= either fail return . parseArgs
installSignalHandlers
prepareNode
prepareNode network
runBenchmarks
[ bench ("restore " <> toText network <> " seq")
(bench_restoration network walletSeq)
Expand Down Expand Up @@ -171,13 +157,13 @@ walletSeq = baseWallet
, name = WalletName "Benchmark Sequential Wallet"
}

prepareNode :: Text -> IO ()
prepareNode netName = do
say . fmt $ "Syncing "+|netName|+" node... "
sl <- withHttpBridge netName $ \port -> do
network <- newNetworkLayer netName port
waitForNodeSync network netName logQuiet
say . fmt $ "Completed sync of "+|netName|+" up to "+||sl||+""
prepareNode :: Network -> IO ()
prepareNode net = do
say . fmt $ "Syncing "+|toText net|+" node... "
sl <- withHttpBridge net $ \port -> do
network <- newNetworkLayer (toText net) port
waitForNodeSync network (toText net) logQuiet
say . fmt $ "Completed sync of "+|toText net|+" up to "+||sl||+""

-- | Poll the network tip until it reaches the slot corresponding to the current
-- time.
Expand Down

0 comments on commit 9c5f6df

Please sign in to comment.