Skip to content

Commit

Permalink
Merge #2576
Browse files Browse the repository at this point in the history
2576: Fix nightly benchmarks r=rvl a=rvl

### Issue Number

ADP-804

### Overview

Nightly restore bench is still failing.

1. Restore bench: Increase cardano-node startup time allowance

   If the cardano-node database is shared between bench runs, it may need to rebuild the ledger, etc, at startup. So increase the time available for that.

2. Latency bench: Fix working directory

   The meaning of `$src` seems to have changed since the Haskell.nix bump in PR #2533.

3. DB Bench: I broke the criterion env setup - fixed now.



Co-authored-by: Rodney Lorrimar <[email protected]>
  • Loading branch information
iohk-bors[bot] and rvl authored Mar 27, 2021
2 parents 404fd3b + 9b5d1d9 commit 3cef89c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
9 changes: 5 additions & 4 deletions lib/core/test/bench/db/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -659,16 +659,17 @@ withDB
=> Tracer IO WalletDBLog
-> (DBLayer IO s k -> Benchmark)
-> Benchmark
withDB tr bm = envWithCleanup (setupDB tr) cleanupDB (\(BenchEnv _ _ db) -> bm db)
withDB tr bm = envWithCleanup (setupDB tr) cleanupDB $
\benchEnv -> bm (dbLayer benchEnv)

data BenchEnv s k = BenchEnv
{ cleanupDB :: IO ()
, _dbFile :: FilePath
, _dbLayer :: !(DBLayer IO s k)
, dbFile :: FilePath
, dbLayer :: DBLayer IO s k
}

instance NFData (BenchEnv s k) where
rnf (BenchEnv _ fp db) = deepseq (rnf fp) $ deepseq (rnf db) ()
rnf env = deepseq (rnf $ dbFile env) $ deepseq (rnf $ dbLayer env) ()

withTempSqliteFile :: (FilePath -> IO a) -> IO a
withTempSqliteFile action = withSystemTempFile "bench.db" $ \fp _ -> action fp
Expand Down
4 changes: 2 additions & 2 deletions lib/shelley/bench/Restore.hs
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ waitForNodeSync
=> Tracer IO (BenchmarkLog n)
-> NetworkLayer IO Block
-> IO SlotNo
waitForNodeSync tr nw = loop 10
waitForNodeSync tr nw = loop 120 -- allow 30 minutes for first tip
where
loop :: Int -> IO SlotNo
loop retries = do
Expand All @@ -788,7 +788,7 @@ waitForNodeSync tr nw = loop 10
traceWith tr $ MsgRetryShortly delay
threadDelay delay
loop (retries - 1)
else throwString "Gave up waitForNodeSync"
else throwString "Gave up in waitForNodeSync, waiting a tip"

data BenchmarkLog (n :: NetworkDiscriminant)
= MsgNodeTipTick BlockHeader SyncProgress
Expand Down
26 changes: 11 additions & 15 deletions nix/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,17 @@ let
unit.postInstall = libSodiumPostInstall;
};

# Add node backend to the PATH of the latency benchmarks
packages.cardano-wallet.components.benchmarks.latency = wrapBench cardanoNodeExes;
# Add node backend to the PATH of the latency benchmarks, and
# set the source tree as its working directory.
packages.cardano-wallet.components.benchmarks.latency =
lib.optionalAttrs (!stdenv.hostPlatform.isWindows) {
build-tools = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram $out/bin/* \
--run "cd $src/lib/shelley" \
--prefix PATH : ${lib.makeBinPath cardanoNodeExes}
'';
};

# Add cardano-node to the PATH of the byroon restore benchmark.
# cardano-node will want to write logs to a subdirectory of the working directory.
Expand Down Expand Up @@ -325,19 +334,6 @@ let
"$out/bin/$exeName" --fish-completion-script "$out/bin/$exeName" >"$fishCompDir/$exeName.fish"
'';

# Add component options to wrap a benchmark exe, so that it has the
# backend executable on its path, and the source tree as its working
# directory.
wrapBench = progs:
lib.optionalAttrs (!stdenv.hostPlatform.isWindows) {
build-tools = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram $out/bin/* \
--run "cd $src" \
--prefix PATH : ${lib.makeBinPath progs}
'';
};

in
haskell.addProjectAndPackageAttrs {
inherit pkg-set;
Expand Down

0 comments on commit 3cef89c

Please sign in to comment.