Skip to content

Commit

Permalink
wb | nix: add UTxO-HD LMDB config options and profile
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeier committed May 8, 2024
1 parent e8e8afb commit 3ba0865
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ ps: ## Plain-text list of profiles
PROFILES_BASE := default default-p2p plutus plutus-secp-ecdsa plutus-secp-schnorr oldtracing idle tracer-only
PROFILES_FAST := fast fast-p2p fast-plutus fast-notracer fast-oldtracing faststartup-24M
PROFILES_CI_TEST := ci-test ci-test-p2p ci-test-plutus ci-test-notracer ci-test-rtview ci-test-dense10
PROFILES_CI_BENCH := ci-bench ci-bench-p2p ci-bench-plutus ci-bench-plutus-secp-ecdsa ci-bench-plutus-secp-schnorr ci-bench-notracer ci-bench-rtview
PROFILES_CI_BENCH := ci-bench ci-bench-p2p ci-bench-plutus ci-bench-plutus-secp-ecdsa ci-bench-plutus-secp-schnorr ci-bench-notracer ci-bench-rtview ci-bench-lmdb
PROFILES_TRACE_BENCH := trace-bench trace-bench-notracer trace-bench-oldtracing trace-bench-rtview
PROFILES_TRACE_FULL := trace-full trace-full-rtview
PROFILES_EPOCHTRANS := epoch-transition
Expand Down
32 changes: 31 additions & 1 deletion nix/nixos/cardano-node-service.nix
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ let
];
};
instanceDbPath = cfg.databasePath i;
utxoLmdbParams = ["--v1-lmdb-ledger-db-backend"]
++ lib.optionals (cfg.lmdbDatabasePath i != null)
[ "--ssd-database-dir ${cfg.lmdbDatabasePath i}"
"--ssd-snapshot-tables"
];
cmd = builtins.filter (x: x != "") [
"${cfg.executable} run"
"--config ${nodeConfigFile}"
Expand All @@ -143,7 +148,8 @@ let
"--tracer-socket-path-accept ${cfg.tracerSocketPathAccept i}"
] ++ lib.optionals (cfg.tracerSocketPathConnect i != null) [
"--tracer-socket-path-connect ${cfg.tracerSocketPathConnect i}"
] ++ consensusParams.${cfg.nodeConfig.Protocol} ++ cfg.extraArgs ++ cfg.rtsArgs;
] ++ lib.optionals (cfg.withUtxoHdLmdb i) utxoLmdbParams
++ consensusParams.${cfg.nodeConfig.Protocol} ++ cfg.extraArgs ++ cfg.rtsArgs;
in ''
echo "Starting: ${concatStringsSep "\"\n echo \"" cmd}"
echo "..or, once again, in a single line:"
Expand Down Expand Up @@ -343,13 +349,30 @@ in {
'';
};

ssdDatabaseDir = mkOption {
type = nullOrStr;
default = null;
description = ''
Optional mount point of a device with high performance disk I/O.
This could be a direct-access SSD, with a specifically created journal-less file system and optimized mount options.
It'll be used as storage for UTxO-HD's LMDB backend only.
'';
};

databasePath = mkOption {
type = funcToOr types.str;
default = i : "${cfg.stateDir i}/${cfg.dbPrefix i}";
apply = x : if builtins.isFunction x then x else _ : x;
description = ''Node database path, for each instance.'';
};

lmdbDatabasePath = mkOption {
type = funcToOr nullOrStr;
default = i : if cfg.ssdDatabaseDir == null then null else "${cfg.ssdDatabaseDir}/lmdb-${cfg.dbPrefix i}";
apply = x : if builtins.isFunction x then x else if x == null then _: null else i: x;
description = ''Node UTxO-HD LMDB path for performant disk I/O, for each instance.'';
};

socketPath = mkOption {
type = funcToOr types.str;
default = i : "${runtimeDir i}/node.socket";
Expand Down Expand Up @@ -648,6 +671,13 @@ in {
default = false;
};

withUtxoHdLmdb = mkOption {
type = funcToOr types.bool;
default = false;
apply = x: if builtins.isFunction x then x else _: x;
description = ''On an UTxO-HD enabled node, the in-memory backend is the default. This activates the on-disk backend (LMDB) instead.'';
};

extraArgs = mkOption {
type = types.listOf types.str;
default = [];
Expand Down
4 changes: 3 additions & 1 deletion nix/workbench/profile/prof0-defaults.jq
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def era_defaults($era):
, shutdown_on_block_synced: null
, tracing_backend: "trace-dispatcher" ## or "iohk-monitoring"
, tracer: true
, utxo_lmdb: false ## use LMDB backend (instead of default in-mem) on a UTxO-HD node; will be ignored by non-UTxO-HD nodes
, verbatim:
{
}
Expand Down Expand Up @@ -110,7 +111,8 @@ def era_defaults($era):
, explorer: 14155776 # 13.5×1024×1024
}
, keep_running: false
, ssd_directory: null
}

}

} | (.common * (.[$era] // {}));
5 changes: 5 additions & 0 deletions nix/workbench/profile/prof1-variants.jq
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,11 @@ def all_profile_variants:
, $cibench_base * $with_rtview *
{ name: "ci-bench-rtview"
}
, $cibench_base * $p2p *
{ name: "ci-bench-lmdb"
, node: { utxo_lmdb: true }
, cluster: { ssd_directory: "/tmp" }
}
, $cibench_base * $nomad_perf_torus * $p2p *
{ name: "ci-bench-nomadperf"
, desc: "ci-bench on P&T exclusive cluster"
Expand Down
6 changes: 6 additions & 0 deletions nix/workbench/service/nodes.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ let
topology = "topology.json";
nodeConfigFile = "config.json";

# Allow for local clusters to have multiple LMDB directories in the same physical ssd_directory
withUtxoHdLmdb = profile.node.utxo_lmdb;
lmdbDatabasePath =
if (profile.cluster ? "ssd_directory" && profile.cluster.ssd_directory != null)
then "${profile.cluster.ssd_directory}/lmdb-node-${toString i}"
else null;

## Combine:
## 0. baseNodeConfig (coming cardanoLib's testnet environ)
Expand Down

0 comments on commit 3ba0865

Please sign in to comment.