diff --git a/lib.mk b/lib.mk index f0fe8572888..cb8dba66794 100644 --- a/lib.mk +++ b/lib.mk @@ -1,16 +1,16 @@ -## proftgt :: target -> profile -> fullnixmode -> devmode -> autostart -> autostay -> profiled -> backend -> IO () +## proftgt :: target -> profile -> fullnixmode -> devmode -> autostart -> autostay -> backend -> IO () define proftgt $(1): shell $(1): PROFILE = $(2)-${ERA} -$(1): BACKEND = $(8) +$(1): BACKEND = $(7) ifeq ($(strip $(3)),true) $(1): ARGS += --arg 'useCabalRun' false endif ifeq ($(strip $(4)),true) $(1): ARGS += --arg 'workbenchDevMode' true endif -ifeq ($(strip $(7)),true) +ifneq ($(strip $(WB_PROFILING)),) $(1): ARGS += --arg 'profiling' '"$(WB_PROFILING)"' else $(1): ARGS += --arg 'profiling' '"none"' @@ -30,22 +30,18 @@ endef define define_profile_targets ID ?= $(shell git symbolic-ref HEAD | sed 's_/_\n_g' | tail -n1) -## defining this target profname nix dev auto stay profiled backend -$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof), $$(prof),false, true,false,false, false, supervisor))) -$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-prof, $$(prof),false, true,false,false, true, supervisor))) -$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autoprof, $$(prof),false, true, true,false, true, supervisor))) -$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-profnix, $$(prof), true, true,false,false, true, supervisor))) -$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autoprofnix, $$(prof), true, true, true,false, true, supervisor))) -$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-auto, $$(prof),false, true, true,false, false, supervisor))) -$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autostay, $$(prof),false, true, true, true, false, supervisor))) -$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nix, $$(prof), true,false,false,false, false, supervisor))) -$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonix, $$(prof), true,false, true,false, false, supervisor))) -$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadexec, $$(prof), true,false,false,false, false, nomadexec))) -$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadexec-auto, $$(prof), true,false, true,false, false, nomadexec))) +## defining this target profname nix dev auto stay backend +$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof), $$(prof),false, true,false,false,supervisor))) +$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-auto, $$(prof),false, true, true,false,supervisor))) +$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autostay, $$(prof),false, true, true, true,supervisor))) +$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nix, $$(prof), true,false,false,false,supervisor))) +$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonix, $$(prof), true,false, true,false,supervisor))) +$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadexec, $$(prof), true,false,false,false,nomadexec))) +$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadexec-auto, $$(prof), true,false, true,false,nomadexec))) endef define define_profile_targets_nomadcloud -## defining this target profname nix dev auto stay profiled backend -$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof), $$(prof), true,false,false,false, false, nomadcloud))) -$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-auto, $$(prof), true,false, true,false, false, nomadcloud))) +## defining this target profname nix dev auto stay backend +$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof), $$(prof), true,false,false,false,nomadcloud))) +$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-auto, $$(prof), true,false, true,false,nomadcloud))) endef diff --git a/nix/nixos/cardano-node-service.nix b/nix/nixos/cardano-node-service.nix index 40bfa7b9b78..251f2363b83 100644 --- a/nix/nixos/cardano-node-service.nix +++ b/nix/nixos/cardano-node-service.nix @@ -825,19 +825,27 @@ in { profilingArgs = mkOption { type = listOf str; - default = let commonProfilingArgs = ["--machine-readable" "-tcardano-node.stats" "-pocardano-node"] - ++ optional (cfg.eventlog) "-l"; - in if cfg.profiling == "time" then ["-p"] ++ commonProfilingArgs - else if cfg.profiling == "time-detail" then ["-P"] ++ commonProfilingArgs - else if cfg.profiling == "space" then ["-h"] ++ commonProfilingArgs - else if cfg.profiling == "space-cost" then ["-hc"] ++ commonProfilingArgs - else if cfg.profiling == "space-module" then ["-hm"] ++ commonProfilingArgs - else if cfg.profiling == "space-closure" then ["-hd"] ++ commonProfilingArgs - else if cfg.profiling == "space-type" then ["-hy"] ++ commonProfilingArgs - else if cfg.profiling == "space-retainer" then ["-hr"] ++ commonProfilingArgs - else if cfg.profiling == "space-bio" then ["-hb"] ++ commonProfilingArgs - else if cfg.profiling == "space-heap" then ["-hT"] ++ commonProfilingArgs - else []; + default = + [ "--machine-readable" + "-tcardano-node.stats" + "-pocardano-node" + ] + ++ optional (cfg.eventlog) "-l" + ++ ( + if cfg.profiling == "time" then ["-p"] + else if cfg.profiling == "time-detail" then ["-P"] + else if cfg.profiling == "space" then ["-h"] + else if cfg.profiling == "space-bio" then ["-hb"] + else if cfg.profiling == "space-closure" then ["-hd"] + else if cfg.profiling == "space-cost" then ["-hc"] + else if cfg.profiling == "space-heap" then ["-hT"] + else if cfg.profiling == "space-info" then ["-hi"] + else if cfg.profiling == "space-module" then ["-hm"] + else if cfg.profiling == "space-retainer" then ["-hr"] + else if cfg.profiling == "space-type" then ["-hy"] + else [] + ) + ; description = ''RTS profiling options''; }; diff --git a/nix/pkgs.nix b/nix/pkgs.nix index 9e295536b6e..14da52dbb24 100644 --- a/nix/pkgs.nix +++ b/nix/pkgs.nix @@ -6,33 +6,42 @@ let inherit (final) pkgs; inherit (prev.pkgs) lib; inherit (prev) customConfig; - - # A generic, fully parametric version of the workbench development environment. + # Parametrized helper entrypoint for the workbench development environment. workbench = import ./workbench - {inherit pkgs lib; inherit (final) cardanoNodePackages cardanoNodeProject;}; + { inherit pkgs; + haskellProject = final.cardanoNodeProject; + } + ; - # Workbench runner instantiated by parameters from customConfig: +in with final; +{ + inherit (cardanoNodeProject.args) compiler-nix-name; + + # To make it a flake output so it's available as input to external flakes. + inherit workbench; + + # A workbench runner with default parameters from customConfig. + # Used in flake.nix for "workbench-ci-test" flake output package for CI. workbench-runner = { profileName ? customConfig.localCluster.profileName - , profiling ? customConfig.profiling , backendName ? customConfig.localCluster.backendName , stateDir ? customConfig.localCluster.stateDir , basePort ? customConfig.localCluster.basePort , useCabalRun ? customConfig.localCluster.useCabalRun + , profiling ? customConfig.profiling , batchName ? customConfig.localCluster.batchName , workbenchStartArgs ? customConfig.localCluster.workbenchStartArgs , cardano-node-rev ? null }: workbench.runner - { inherit profileName profiling backendName stateDir basePort useCabalRun; + { # To construct profile attrset with its `materialise-profile` function. + inherit profileName; + # To construct backend attrset with its `materialise-profile` function. + inherit backendName stateDir basePort useCabalRun profiling; + # Parameters for the workbench shell `start-cluster` command. inherit batchName workbenchStartArgs cardano-node-rev; - }; - -in with final; -{ - inherit (cardanoNodeProject.args) compiler-nix-name; - - inherit workbench workbench-runner; + } + ; cabal = haskell-nix.cabal-install.${compiler-nix-name}; @@ -160,15 +169,13 @@ in with final; value = let # Default values only ("run/current", 30000, profiling "none"). - profile = workbench.profile { - inherit profileName; - profiling = "none"; - }; + profile = workbench.profile profileName; backend = workbench.backend { backendName = "nomadcloud"; stateDir = customConfig.localCluster.stateDir; basePort = customConfig.localCluster.basePort; useCabalRun = customConfig.localCluster.useCabalRun; + profiling = "none"; } ; profileBundle = profile.profileBundle diff --git a/nix/workbench/backend/nomad-job.nix b/nix/workbench/backend/nomad-job.nix index 6ee5003c19d..d859ec62030 100644 --- a/nix/workbench/backend/nomad-job.nix +++ b/nix/workbench/backend/nomad-job.nix @@ -4,7 +4,6 @@ # To make it easier to improve and debug the almighty workbench! ################################################################################ { pkgs -, lib , stateDir , profileBundle , generatorTaskName @@ -15,6 +14,8 @@ let + inherit (pkgs) lib; + profile = profileBundle.profile.value; # Filesystem @@ -737,8 +738,9 @@ let destination = "local/${task_supervisord_conf}"; data = escapeTemplate ( import ./supervisor-conf.nix - { inherit pkgs lib stateDir; + { inherit pkgs stateDir; inherit profile; + profiling = "none"; # Include only this taks' node nodeSpecs = if taskName == "tracer" then {} diff --git a/nix/workbench/backend/nomad.nix b/nix/workbench/backend/nomad.nix index ff8ca9baf02..9b272b86b29 100644 --- a/nix/workbench/backend/nomad.nix +++ b/nix/workbench/backend/nomad.nix @@ -1,11 +1,13 @@ { pkgs -, lib +, haskellProject , stateDir , subBackendName , ... }: let + inherit (pkgs) lib; + # Backend-specific Nix bits: materialise-profile = { profileBundle }: # Intermediate / workbench-adhoc container specifications @@ -145,29 +147,33 @@ let # the one used to enter the shell. cardano-node = rec { # Local reference only used if not "cloud". - # Avoid rebuilding on every commit because of `set-git-rev`. - nix-store-path = pkgs.cardanoNodePackages.cardano-node.passthru.noGitRev; + nix-store-path = haskellProject.exes.cardano-node; flake-reference = "github:intersectmbo/cardano-node"; + # Where to fetch the binary from during "cloud" runs. + # Avoid nix cache misses on every commit because of `set-git-rev`. flake-output = "cardanoNodePackages.cardano-node.passthru.noGitRev" ; }; cardano-cli = rec { # Local reference only used if not "cloud". - # Avoid rebuilding on every commit because of `set-git-rev`. - nix-store-path = pkgs.cardanoNodePackages.cardano-cli.passthru.noGitRev; + nix-store-path = haskellProject.hsPkgs.cardano-cli.components.exes.cardano-cli; flake-reference = "github:input-output-hk/cardano-cli"; + # Where to fetch the binary from during "cloud" runs. + # Avoid nix cache misses on every commit because of `set-git-rev`. flake-output = "cardanoNodePackages.cardano-cli.passthru.noGitRev"; }; cardano-tracer = rec { # Local reference only used if not "cloud". - nix-store-path = pkgs.cardanoNodePackages.cardano-tracer; + nix-store-path = haskellProject.exes.cardano-tracer; flake-reference = "github:intersectmbo/cardano-node"; flake-output = "cardanoNodePackages.cardano-tracer"; }; tx-generator = rec { # Local reference only used if not "cloud". - nix-store-path = pkgs.cardanoNodePackages.tx-generator.passthru.noGitRev; + nix-store-path = haskellProject.exes.tx-generator; flake-reference = "github:intersectmbo/cardano-node"; + # Where to fetch the binary from during "cloud" runs. + # Avoid nix cache misses on every commit because of `set-git-rev`. flake-output = "cardanoNodePackages.tx-generator.passthru.noGitRev"; }; } @@ -187,7 +193,7 @@ let exec = { # TODO: oneTracerPerGroup oneTracerPerCluster = import ./nomad-job.nix - { inherit pkgs lib stateDir; + { inherit pkgs stateDir; inherit profileBundle; inherit generatorTaskName; inherit installables; @@ -195,7 +201,7 @@ let withSsh = false; }; oneTracerPerNode = import ./nomad-job.nix - { inherit pkgs lib stateDir; + { inherit pkgs stateDir; inherit profileBundle; inherit generatorTaskName; inherit installables; @@ -210,7 +216,7 @@ let # Always "oneTracerPerNode" # TODO: oneTracerPerCluster and oneTracerPerGroup nomadExec = import ./nomad-job.nix - { inherit pkgs lib stateDir; + { inherit pkgs stateDir; inherit profileBundle; inherit generatorTaskName; inherit installables; @@ -218,7 +224,7 @@ let withSsh = false; }; ssh = import ./nomad-job.nix - { inherit pkgs lib stateDir; + { inherit pkgs stateDir; inherit profileBundle; inherit generatorTaskName; inherit installables; diff --git a/nix/workbench/backend/nomad/cloud.nix b/nix/workbench/backend/nomad/cloud.nix index e2974b45876..116a2f4f529 100644 --- a/nix/workbench/backend/nomad/cloud.nix +++ b/nix/workbench/backend/nomad/cloud.nix @@ -1,8 +1,9 @@ { pkgs -, lib +, haskellProject , stateDir -, basePort # Ignored here and just returned to be used by `runner.nix`! -## `useCabalRun` not used here unlike `supervisor.nix`. +, basePort # ignored, just passed to the runner (unlike `supervisor.nix`). +## `useCabalRun` overridden parameter (unlike `supervisor.nix`). +## `profiling` overridden parameter (unlike `supervisor.nix`). , ... }: let @@ -12,9 +13,12 @@ let # genesis files (Buckets needs write permissions for the deployer machine). name = "nomadcloud"; - # Unlike the supervisor backend `useCabalRun` is always false here. + # Unlike the supervisor backend `useCabalRun` is always `false` here. useCabalRun = false; + # Unlike the supervisor backend `profiling` is always `"none"` here. + profiling = "none"; + extraShellPkgs = [ # SRE's patched Nomad 1.6.3 that enables `nix_installables` as artifacts. @@ -35,7 +39,9 @@ let # Build a Nomad Job specification for this Nomad "sub-backend". materialise-profile = let params = { - inherit pkgs lib stateDir; + inherit pkgs; + inherit haskellProject; + inherit stateDir; subBackendName = "cloud"; }; in (import ../nomad.nix params).materialise-profile @@ -58,7 +64,11 @@ in inherit extraShellPkgs; inherit materialise-profile; inherit service-modules; - inherit stateDir basePort; + inherit stateDir; + + # Returns something only to be compatible with what `runner.nix` expects. + inherit basePort; - inherit useCabalRun; + # Ignores the parameters and always returns `false` and `"none"`. + inherit useCabalRun profiling; } diff --git a/nix/workbench/backend/nomad/exec.nix b/nix/workbench/backend/nomad/exec.nix index 62e1b2aff18..62598230d3a 100644 --- a/nix/workbench/backend/nomad/exec.nix +++ b/nix/workbench/backend/nomad/exec.nix @@ -1,8 +1,9 @@ { pkgs -, lib +, haskellProject , stateDir -, basePort # Ignored here and just returned to be used by `runner.nix`! -## `useCabalRun` not used here unlike `supervisor.nix`. +, basePort # ignored, just passed to the runner (unlike `supervisor.nix`). +## `useCabalRun` overridden parameter (unlike `supervisor.nix`). +## `profiling` overridden parameter (unlike `supervisor.nix`). , ... }: let @@ -15,6 +16,9 @@ let # Unlike the supervisor backend `useCabalRun` is always false here. useCabalRun = false; + # Unlike the supervisor backend `profiling` is always `"none"` here. + profiling = "none"; + extraShellPkgs = [ # SRE's patched Nomad 1.6.3 that enables `nix_installables` as artifacts. @@ -33,7 +37,9 @@ let # Build a Nomad Job specification for this Nomad "sub-backend". materialise-profile = let params = { - inherit pkgs lib stateDir; + inherit pkgs; + inherit haskellProject; + inherit stateDir; subBackendName = "exec"; }; in (import ../nomad.nix params).materialise-profile @@ -56,7 +62,11 @@ in inherit extraShellPkgs; inherit materialise-profile; inherit service-modules; - inherit stateDir basePort; + inherit stateDir; + + # Returns something only to be compatible with what `runner.nix` expects. + inherit basePort; - inherit useCabalRun; + # Ignores the parameters and always returns `false` and `"none"`. + inherit useCabalRun profiling; } diff --git a/nix/workbench/backend/runner.nix b/nix/workbench/backend/runner.nix index 9a3fed8e706..d96269d6d2e 100644 --- a/nix/workbench/backend/runner.nix +++ b/nix/workbench/backend/runner.nix @@ -1,7 +1,6 @@ -{ pkgs, lib +{ pkgs ## The binaries/scripts to use when calling the workbench. -, cardanoNodeProject -, cardanoNodePackages +, haskellProject , workbench # The derivation. ## Profile dependent parameters. , profile @@ -18,10 +17,9 @@ let ############################################################################## profileName = profile.name; - inherit (profile) profiling; backendName = backend.name; - inherit (backend) stateDir basePort useCabalRun; + inherit (backend) stateDir basePort useCabalRun profiling; profileBundle = profile.profileBundle { inherit backend; }; @@ -34,9 +32,9 @@ let cacheDir = "${__getEnv "HOME"}/.cache/cardano-workbench"; # recover CHaP location from cardano's project - chap = cardanoNodeProject.args.inputMap."https://chap.intersectmbo.org/"; + chap = haskellProject.args.inputMap."https://chap.intersectmbo.org/"; # build plan as computed by nix - nixPlanJson = cardanoNodeProject.plan-nix + "/plan.json"; + nixPlanJson = haskellProject.plan-nix + "/plan.json"; # Optimize cache hits setting gitrev using bash once inside the shell. workbench-envars = @@ -47,6 +45,7 @@ let export WB_SHELL_PROFILE_DATA=${profileDataDir} export WB_BACKEND=${backendName} export WB_BACKEND_DATA=${backendDataDir} + export WB_PROFILING="${profiling}" export WB_CREATE_TESTNET_DATA=''${WB_CREATE_TESTNET_DATA:-1} export WB_DEPLOYMENT_NAME=''${WB_DEPLOYMENT_NAME:-$(basename $(pwd))} export WB_MODULAR_GENESIS=''${WB_MODULAR_GENESIS:-0} @@ -57,7 +56,7 @@ let fi export CARDANO_NODE_SOCKET_PATH=${stateDir}/node-0/node.socket '' - + lib.optionalString (profileBundle.profile.value.scenario == "chainsync") ( + + pkgs.lib.optionalString (profileBundle.profile.value.scenario == "chainsync") ( let cardano-mainnet-mirror = # "nix" branch last commit 819488be9eabbba6aaa7c931559bc584d8071e3d __getFlake "github:input-output-hk/cardano-mainnet-mirror/nix"; @@ -122,12 +121,9 @@ let ] ) ++ - (with cardanoNodePackages; - [ - cardano-cli - locli - ] - ) + [ haskellProject.exes.locli + haskellProject.hsPkgs.cardano-cli.components.exes.cardano-cli + ] ; workbench-profile-run = @@ -145,29 +141,12 @@ let cache_key_input=$(wb genesis profile-cache-key-input ${profileJson}) cache_key=$( wb genesis profile-cache-key ${profileJson}) - genesis_keepalive() { - while test ! -e $out/profile - do - echo 'genesis_keepalive for Hydra' - sleep 10s - done - } - genesis_keepalive & - __genesis_keepalive_pid=$! - __genesis_keepalive_termination() { - kill $__genesis_keepalive_pid 2>/dev/null || true - } - trap __genesis_keepalive_termination EXIT - - time \ - wb genesis actually-genesis \ - "${profileJson}" \ - "${nodeSpecsJson}" \ - "$out" \ - "$cache_key_input" \ - "$cache_key" - - touch done + wb genesis actually-genesis \ + "${profileJson}" \ + "${nodeSpecsJson}" \ + "$out" \ + "$cache_key_input" \ + "$cache_key" '' ; # Run the profile. @@ -200,7 +179,7 @@ let --genesis-cache-entry ${genesisFiles} --batch-name smoke-test --base-port ${toString basePort} - --node-source ${pkgs.cardanoNodeProject.args.src} + --node-source ${haskellProject.args.src} --node-rev ${cardano-node-rev} --cache-dir ./cache ${__concatStringsSep " " workbenchStartArgs} @@ -278,8 +257,8 @@ let in { - inherit backend; - inherit profiling; + # Don't expose the backend. Just what the shell could need. + inherit (backend) useCabalRun profiling extraShellPkgs; inherit workbench-envars; inherit workbench-interactive-start; diff --git a/nix/workbench/backend/supervisor-conf.nix b/nix/workbench/backend/supervisor-conf.nix index 863f5c02255..12cd1e1e2b4 100644 --- a/nix/workbench/backend/supervisor-conf.nix +++ b/nix/workbench/backend/supervisor-conf.nix @@ -1,7 +1,7 @@ { pkgs -, lib , stateDir , profile +, profiling , nodeSpecs , withGenerator , withTracer @@ -10,9 +10,10 @@ , inetHttpServerPort ? null }: -with lib; - let + + inherit (pkgs) lib; + # The prefix for every "[program:X] command=sh start.sh" because `supervisord` # may run in the most unexpected places where we can't asume what is or isn't # included in $PATH. Just make sure pkgs.bashInteractive is in the nix store. @@ -140,6 +141,18 @@ let ### - forge-stress-large: 11300000 ### - value: 5000000 (50s more needed) startsecs = 5 + (profile.derived.dataset_measure / (5000000 / 50)); + # The number of seconds to wait for the OS to return a SIGCHLD to + # supervisord after the program has been sent a stopsignal. If this + # number of seconds elapses before supervisord receives a SIGCHLD from + # the process, supervisord will attempt to kill it with a final SIGKILL. + stopwaitsecs = + if profiling == null || profiling == "none" + # Use the default value. + then 10 + # May need a lot of time for a long running node to dump all the + # profiling data. Not risking it. 5 minutes. + else 5*60 + ; }) nodeSpecs)) // @@ -242,4 +255,4 @@ let ; in - generators.toINI {} supervisorConf + lib.generators.toINI {} supervisorConf diff --git a/nix/workbench/backend/supervisor.nix b/nix/workbench/backend/supervisor.nix index 4d0482d40a7..94bcbe5ab8d 100644 --- a/nix/workbench/backend/supervisor.nix +++ b/nix/workbench/backend/supervisor.nix @@ -1,11 +1,12 @@ { pkgs -, lib +, haskellProject , stateDir , basePort , useCabalRun +, profiling , ... }: -with lib; +with pkgs.lib; let extraShellPkgs = with pkgs; [ @@ -20,8 +21,9 @@ let "workbench-backend-data-${profileBundle.profile.value.name}-supervisor" { # Create a `supervisord.conf` supervisorConf = import ./supervisor-conf.nix - { inherit pkgs lib stateDir; + { inherit pkgs stateDir; profile = profileBundle.profile.value; + inherit profiling; nodeSpecs = profileBundle.node-specs.value; withGenerator = true; withTracer = profileBundle.profile.value.node.tracer; @@ -56,5 +58,5 @@ in inherit service-modules; inherit stateDir basePort; - inherit useCabalRun; + inherit useCabalRun profiling; } diff --git a/nix/workbench/default.nix b/nix/workbench/default.nix index f8b3e92e0da..9c72e0724db 100644 --- a/nix/workbench/default.nix +++ b/nix/workbench/default.nix @@ -1,12 +1,23 @@ -{ pkgs, lib -, cardanoNodeProject -, cardanoNodePackages +# The workbench entrypoint, +{ pkgs + # This provided project attrset will be used all over the workbench instead + # of the flake's `pkgs` or `cardanoNodePackages`. This allows to easily + # parametrize the whole build at any point, be it only for the workbench in + # "nix/pkgs.nix" or when entering a workbench shell in + # "nix/workbench/shell.nix". + # Also, by using a haskell.nix project instead of `cardanoNodePackages` or + # `pkgs` to fetch it's project related dependencies we are sure they are not + # tagged with the git commit because if we use the `set-git-rev` versions of + # `cardano-node` and/or `tx-generator` then on every distinct commit ID all + # the scripts generated by the workbench (start.sh files) will be re-generated + # instead of obtained from the cache in the nix store. +, haskellProject }: -with lib; - let + inherit (pkgs) lib; + # Workbench derivation to create derivations from `wb` commands. ############################################################################## @@ -32,7 +43,7 @@ let profile = [".sh" ".json"]; topology = [".sh"]; }; - in lib.any id [ + in lib.any lib.id [ # Include the "wb" file (has no ".sh", workbench's entrypoint). (relativePath == "wb") # Include all top level "*.sh" files. @@ -50,8 +61,8 @@ let ) ) # Include only the extensions defined above. - (lib.any id - (attrValues (mapAttrs + (lib.any lib.id + (lib.attrValues (lib.mapAttrs (dirName: suffixes: (lib.hasPrefix (dirName + "/") relativePath) && @@ -90,35 +101,32 @@ let profile-names-json = pkgs.runCommand "profile-names.json" {} '' - ${cardanoNodePackages.cardano-profile}/bin/cardano-profile "names" > $out + ${haskellProject.exes.cardano-profile}/bin/cardano-profile "names" > $out '' ; # Output ################################################################################ -in pkgs.lib.fix (self: { +in lib.fix (self: { - inherit cardanoNodePackages; inherit workbench; + inherit haskellProject; inherit profile-names-json profile-names; # Return a profile attr with a `materialise-profile` function. - # profileName -> profiling -> profile - profile = - { profileName - , profiling - }: + # profileName -> profile + profile = profileName: (import ./profile/profile.nix - { inherit pkgs lib; + { inherit pkgs; workbenchNix = self; - inherit profileName profiling; + inherit profileName; } ) ; # Return a backend attr with a `materialise-profile` function. - # backendName -> stateDir -> basePort -> useCabalRun -> backend + # backendName -> stateDir -> basePort -> useCabalRun -> profiling -> backend backend = let backendRegistry = { nomadcloud = params: @@ -132,15 +140,21 @@ in pkgs.lib.fix (self: { , stateDir , basePort , useCabalRun + , profiling }: - # The `useCabalRun` flag is set in the backend to allow the backend to - # override its value. The runner uses the value of `useCabalRun` from - # the backend to prevent a runner using a different value. (backendRegistry."${backendName}") - { inherit pkgs lib stateDir basePort useCabalRun; } + { inherit pkgs; + inherit haskellProject; + inherit stateDir basePort; + # The `useCabalRun` and `profiling` flags are set in the backend to + # allow the backend to override its values. The runner must use the + # value of these two flags from the backend to prevent having a runner + # that uses a different value than the ones the backend supports. + inherit useCabalRun profiling; + } ; - # A conveniently-parametrisable workbench preset. + # A conveniently-parametrizable workbench preset. # See https://input-output-hk.github.io/haskell.nix/user-guide/development/ # The general idea is: # 1. profileName -> profiling -> profile @@ -148,28 +162,33 @@ in pkgs.lib.fix (self: { # 3. profile -> backend -> batchName -> runner runner = { profileName - , profiling , backendName , stateDir , basePort , useCabalRun + , profiling , batchName , workbenchStartArgs , cardano-node-rev }: let # Only a name needed to create a profile attrset. - profile = self.profile { inherit profileName profiling; }; - # The `useCabalRun` flag is set in the backend to allow the backend to - # override its value. The runner uses the value of `useCabalRun` from - # the backend to prevent a runner using a different value. + profile = self.profile profileName; backend = self.backend - { inherit backendName stateDir basePort useCabalRun; } + { inherit backendName stateDir basePort; + # The `useCabalRun` and `profiling` flags final decisions + # belong to the backend. We allow the backend to override + # its values. + # The runner must use the values returned from the backend + # to prevent having a runner that uses a different value + # than the ones supported by the chosen backend. + inherit useCabalRun profiling; + } ; in import ./backend/runner.nix { - inherit pkgs lib; - inherit cardanoNodeProject cardanoNodePackages; + inherit pkgs; + inherit haskellProject; inherit workbench; inherit profile backend; inherit batchName workbenchStartArgs; diff --git a/nix/workbench/lib-cabal.sh b/nix/workbench/lib-cabal.sh index 8ad4263d14f..a2a556a7bdd 100644 --- a/nix/workbench/lib-cabal.sh +++ b/nix/workbench/lib-cabal.sh @@ -1,23 +1,20 @@ -progress "workbench" "cabal-inside-nix-shell mode enabled, calling cardano-* via '$(white cabal run)' (instead of using Nix store); $(red lib-cabal.sh) flags: $(yellow $*)" - -while test $# -gt 0 -do case "$1" in - --profiling-time ) export WB_PROFILING='time'; WB_RTSARGS=-p;; - --profiling-space ) export WB_PROFILING='space-cost'; WB_RTSARGS=-hc;; - --profiling-heap ) export WB_PROFILING='space-heap'; WB_RTSARGS=-hT;; - --profiling-module ) export WB_PROFILING='space-module'; WB_RTSARGS=-hm;; - --profiling-retainer ) export WB_PROFILING='space-retainer'; WB_RTSARGS=-hr;; - --profiling-type ) export WB_PROFILING='space-type'; WB_RTSARGS=-hy;; - * ) break;; esac; - progress "workbench" "enabling $(red profiling mode): $(white $WB_PROFILING)" - shift; done - -if test ! -v WB_PROFILING || test "$WB_PROFILING" = 'none' -then export WB_PROFILING='none' WB_FLAGS_CABAL= -else export WB_FLAGS_CABAL='--enable-profiling --builddir dist-profiled'; fi - -if test ! -v WB_RTSARGS; then export WB_RTSARGS= ; fi -export WB_FLAGS_RTS=${WB_RTSARGS:++RTS $WB_RTSARGS -RTS} +progress "workbench" "cabal-inside-nix-shell mode enabled, calling cardano-* via '$(white cabal run)' (instead of using Nix store); $(red lib-cabal.sh) flags: $(red WB_PROFILING):$(white $WB_PROFILING)" + +# If profiling envar not empty and not "none", we build with profiling. +if test -z "${WB_PROFILING:-}" || test "${WB_PROFILING}" = 'none' +then + export WB_FLAGS_CABAL="" +else + export WB_FLAGS_CABAL='--enable-profiling --builddir dist-profiled' +fi + +# If RTS args envar not empty, append the extra RTS parameters to `cabal run`. +if test -z "${WB_RTSARGS:-}" +then + export WB_FLAGS_RTS= +else + export WB_FLAGS_RTS="+RTS ${WB_RTSARGS} -RTS" +fi WB_TIME=( time @@ -26,7 +23,6 @@ WB_TIME=( ) export WB_NODE_EXECPREFIX="eval ${WB_TIME[*]@Q}" - function workbench-prebuild-executables() { eval $muffle_trace_set_exit @@ -37,45 +33,46 @@ function workbench-prebuild-executables() newline unset NIX_ENFORCE_PURITY - for exe in cardano-node cardano-profile cardano-topology cardano-tracer tx-generator locli + # Executables with profiling support. + for exe in cardano-node cardano-tracer tx-generator locli do echo "workbench: $(blue prebuilding) $(red $exe)" - verbose "exec" "cabal build ${WB_FLAGS_CABAL} -- exe:$exe" - cabal $(test -z "${verbose:-}" && echo '-v0') build ${WB_FLAGS_CABAL} -- exe:$exe || return 1 + verbose "exec" "cabal build ${WB_FLAGS_CABAL} -- exe:$exe" + cabal $(test -z "${verbose:-}" && echo '-v0') build ${WB_FLAGS_CABAL} -- exe:$exe || return 1 + done + # Executables without profiling support. + for exe in cardano-profile cardano-topology + do echo "workbench: $(blue prebuilding) $(red $exe)" + verbose "exec" "cabal build -- exe:$exe" + cabal $(test -z "${verbose:-}" && echo '-v0') build -- exe:$exe || return 1 done echo eval $restore_trace } function cardano-node() { - ${WB_NODE_EXECPREFIX} cabal -v0 run ${WB_FLAGS_CABAL} exe:cardano-node -- ${WB_FLAGS_RTS} "$@" + ${WB_NODE_EXECPREFIX} cabal -v0 run ${WB_FLAGS_CABAL} exe:cardano-node -- ${WB_FLAGS_RTS} "$@" } -function cardano-profile() { - cabal -v0 run ${WB_FLAGS_CABAL} exe:cardano-profile -- ${WB_FLAGS_RTS} "$@" +function cardano-tracer() { + ${WB_NODE_EXECPREFIX} cabal -v0 run ${WB_FLAGS_CABAL} exe:cardano-tracer -- ${WB_FLAGS_RTS} "$@" } -function cardano-topology() { - cabal -v0 run ${WB_FLAGS_CABAL} exe:cardano-topology -- ${WB_FLAGS_RTS} "$@" +function locli() { + ${WB_NODE_EXECPREFIX} cabal -v0 run ${WB_FLAGS_CABAL} exe:locli -- ${WB_FLAGS_RTS} "$@" } -function cardano-tracer() { - cabal -v0 run ${WB_FLAGS_CABAL} exe:cardano-tracer -- ${WB_FLAGS_RTS} "$@" +function tx-generator() { + ${WB_NODE_EXECPREFIX} cabal -v0 run ${WB_FLAGS_CABAL} exe:tx-generator -- ${WB_FLAGS_RTS} "$@" } -function locli() { - #cabal -v0 build ${WB_FLAGS_CABAL} exe:locli - #set-git-rev \ - # $(git rev-parse HEAD) \ - # $(cabal list-bin locli) || true - # cabal -v0 exec ${WB_FLAGS_CABAL} locli -- ${WB_FLAGS_RTS} "$@" - - cabal -v0 run ${WB_FLAGS_CABAL} exe:locli -- ${WB_FLAGS_RTS} "$@" +function cardano-profile() { + cabal -v0 run exe:cardano-profile "$@" } -function tx-generator() { - cabal -v0 run ${WB_FLAGS_CABAL} exe:tx-generator -- ${WB_FLAGS_RTS} "$@" +function cardano-topology() { + cabal -v0 run exe:cardano-topology "$@" } export WB_MODE_CABAL=t -export -f cardano-node cardano-profile cardano-topology cardano-tracer locli tx-generator +export -f cardano-node cardano-tracer locli tx-generator cardano-profile cardano-topology diff --git a/nix/workbench/profile/profile.nix b/nix/workbench/profile/profile.nix index 846b4576039..5bcbdbac7b0 100644 --- a/nix/workbench/profile/profile.nix +++ b/nix/workbench/profile/profile.nix @@ -1,6 +1,7 @@ -{ pkgs, lib +{ pkgs +# The workbench attrset as it was parametrized. , workbenchNix -, profileName, profiling +, profileName }: let @@ -18,8 +19,8 @@ let moreutils # sponge jq graphviz - workbenchNix.cardanoNodePackages.cardano-profile - workbenchNix.cardanoNodePackages.cardano-topology + workbenchNix.haskellProject.exes.cardano-profile + workbenchNix.haskellProject.exes.cardano-topology ]; } '' @@ -55,12 +56,13 @@ let profile = __fromJSON (__readFile profileJsonPath); nodeSpecs = __fromJSON (__readFile nodeSpecsJsonPath); inherit - (pkgs.callPackage + (import ../service/nodes.nix - { inherit backend profile nodeSpecs; - inherit profiling; - inherit profileJsonPath topologyJsonPath; + { inherit pkgs; inherit workbenchNix; + inherit backend profile nodeSpecs; + inherit (backend) profiling; + inherit profileJsonPath topologyJsonPath; ## This ports the (very minimal) config of the deprecated iohk-nix ## testnet environment to workbench, removing the dependency on it. baseNodeConfig = @@ -71,16 +73,18 @@ let LastKnownBlockVersion-Alt = 0; } // - workbenchNix.cardanoNodePackages.cardanoLib.defaultLogConfig + workbenchNix.haskellProject.pkgs.cardanoLib.defaultLogConfig ; } ) node-services ; inherit - (pkgs.callPackage + (import ../service/generator.nix - { inherit backend profile nodeSpecs; + { inherit pkgs; + inherit (workbenchNix) haskellProject; + inherit backend profile nodeSpecs; inherit node-services; } ) @@ -92,7 +96,10 @@ let start = '' ${import ../workload/${name}.nix - {inherit pkgs profile nodeSpecs workload;} + { inherit pkgs; + inherit (workbenchNix) haskellProject; + inherit profile nodeSpecs workload; + } } ${workload.entrypoints.producers} '' @@ -101,16 +108,22 @@ let profile.workloads ; inherit - (pkgs.callPackage + (import ../service/tracer.nix - {inherit backend profile nodeSpecs;} + { inherit pkgs; + inherit (workbenchNix) haskellProject; + inherit backend profile nodeSpecs; + } ) tracer-service ; healthcheck-service = - (pkgs.callPackage + (import ../service/healthcheck.nix - {inherit backend profile nodeSpecs;} + { inherit pkgs; + inherit (workbenchNix) haskellProject; + inherit backend profile nodeSpecs; + } ) ; in { @@ -145,7 +158,7 @@ let inherit topologyJsonPath topologyDotPath; inherit nodeSpecsJsonPath; nodeServices = __toJSON - (lib.mapAttrs + (pkgs.lib.mapAttrs (name: node-service: { inherit name; inherit (node-service) start config; @@ -203,7 +216,6 @@ let in { name = profileName; - inherit profiling; inherit profileJsonPath nodeSpecsJsonPath; inherit profileBundle materialise-profile; } diff --git a/nix/workbench/service/generator.nix b/nix/workbench/service/generator.nix index a595c8ca52e..2f4a294edc3 100644 --- a/nix/workbench/service/generator.nix +++ b/nix/workbench/service/generator.nix @@ -1,5 +1,5 @@ { pkgs - +, haskellProject , backend , profile , nodeSpecs @@ -57,11 +57,13 @@ let ; } // optionalAttrs profile.node.tracer { tracerSocketPath = "../tracer/tracer.socket"; + # Decide where the executable comes from: + ######################################### } // optionalAttrs (!backend.useCabalRun) { - # Use to `noGitRev` to avoid rebuilding on every commit. - executable = "${pkgs.cardanoNodePackages.tx-generator.passthru.noGitRev}/bin/tx-generator"; - } // optionalAttrs backend.useCabalRun { + executable = "${haskellProject.exes.tx-generator}/bin/tx-generator"; + } // optionalAttrs backend.useCabalRun { executable = "tx-generator"; + ######################################### }); ## @@ -169,7 +171,7 @@ let then '' ${import ../workload/${workload_name}.nix - {inherit pkgs profile nodeSpecs workload;} + {inherit pkgs haskellProject profile nodeSpecs workload;} } (cd ../workloads/${workload_name} && ${entrypoint} ${node_name}) '' diff --git a/nix/workbench/service/healthcheck.nix b/nix/workbench/service/healthcheck.nix index 27dac71a0bd..d06fbf93fe3 100644 --- a/nix/workbench/service/healthcheck.nix +++ b/nix/workbench/service/healthcheck.nix @@ -1,4 +1,5 @@ { pkgs +, haskellProject , backend , profile , nodeSpecs @@ -12,17 +13,19 @@ let supervisor = pkgs.supervisor; grep = pkgs.gnugrep; jq = pkgs.jq; - # Avoid rebuilding the script on every commit. - # `noGitRev` does not have `set-git-rev` that is set on every commit. - cardano-node = with pkgs; + # Decide where the executables come from: + ######################################### + cardano-node = if backend.useCabalRun then "cardano-node" - else cardanoNodePackages.cardano-node.passthru.noGitRev + "/bin/cardano-node" + else haskellProject.exes.cardano-node + "/bin/cardano-node" ; - cardano-cli = with pkgs; + cardano-cli = if backend.useCabalRun then "cardano-cli" - else cardanoNodePackages.cardano-cli.passthru.noGitRev + "/bin/cardano-cli"; + else haskellProject.hsPkgs.cardano-cli.components.exes.cardano-cli + "/bin/cardano-cli" + ; + ######################################### in { start = # Assumptions: diff --git a/nix/workbench/service/nodes.nix b/nix/workbench/service/nodes.nix index 82e1fd6e994..37e5011124c 100644 --- a/nix/workbench/service/nodes.nix +++ b/nix/workbench/service/nodes.nix @@ -149,12 +149,16 @@ let ]; } // optionalAttrs (profiling != "none") { inherit profiling; - } // optionalAttrs (profiling == "none") { - # Switch to `noGitRev` to avoid rebuilding with every commit. - package = pkgs.cardano-node.passthru.noGitRev; - } // optionalAttrs backend.useCabalRun { + # Always add the `-l` RTS param with profiling. + eventlog = true; + # Decide where the executable comes from: + ######################################### + } // optionalAttrs (!backend.useCabalRun) { + package = workbenchNix.haskellProject.exes.cardano-node; + } // optionalAttrs backend.useCabalRun { # Allow the shell function to take precedence. executable = "cardano-node"; + ######################################### } // optionalAttrs isProducer { operationalCertificate = "../genesis/node-keys/node${toString i}.opcert"; kesKey = "../genesis/node-keys/node-kes${toString i}.skey"; @@ -223,7 +227,7 @@ let # A workbench with only the dependencies needed for this command. [ workbenchNix.workbench jq - workbenchNix.cardanoNodePackages.cardano-topology + workbenchNix.haskellProject.exes.cardano-topology ]; } '' diff --git a/nix/workbench/service/tracer.nix b/nix/workbench/service/tracer.nix index 7076483c091..cfbf1c1bec3 100644 --- a/nix/workbench/service/tracer.nix +++ b/nix/workbench/service/tracer.nix @@ -1,5 +1,5 @@ { pkgs - +, haskellProject , backend , profile , nodeSpecs @@ -27,8 +27,13 @@ let networkMagic = profile.genesis.network_magic; configFile = "config.json"; metricsHelp = "../../../cardano-tracer/configuration/metrics_help.json"; - } // optionalAttrs backend.useCabalRun { + # Decide where the executable comes from: + ######################################### + } // optionalAttrs (!backend.useCabalRun) { + executable = "${haskellProject.exes.cardano-tracer}/bin/cardano-tracer"; + } // optionalAttrs backend.useCabalRun { executable = "cardano-tracer"; + ######################################### } // optionalAttrs profile.tracer.rtview { RTView = { epHost = "127.0.0.1"; diff --git a/nix/workbench/shell.nix b/nix/workbench/shell.nix index c0b3e7de24f..efe404f00cb 100644 --- a/nix/workbench/shell.nix +++ b/nix/workbench/shell.nix @@ -17,7 +17,7 @@ project.shellFor { name = "workbench-shell"; shellHook = - let inherit (workbench-runner) backend profiling; + let inherit (workbench-runner) useCabalRun; in '' while test $# -gt 0 @@ -29,8 +29,9 @@ project.shellFor { progress "profile name" $WB_SHELL_PROFILE progress "backend name" $WB_BACKEND + progress "profiling" $WB_PROFILING + progress "params" 'useCabalRun=${toString useCabalRun} workbenchDevMode=${toString workbenchDevMode}' progress "deployment name" $WB_DEPLOYMENT_NAME - progress "params" 'useCabalRun=${toString backend.useCabalRun} workbenchDevMode=${toString workbenchDevMode} profiling=${toString profiling}' progress "WB_SHELL_PROFILE_DATA=" $WB_SHELL_PROFILE_DATA progress "WB_BACKEND_DATA=" $WB_BACKEND_DATA progress "WB_LOCLI_DB=" $WB_LOCLI_DB @@ -52,9 +53,9 @@ project.shellFor { } export -f wb '' - + optionalString backend.useCabalRun + + optionalString useCabalRun '' - . nix/workbench/lib-cabal.sh ${optionalString (profiling != "none") "--profiling-${profiling}"} + . nix/workbench/lib-cabal.sh cabal update '' + @@ -94,57 +95,83 @@ project.shellFor { }; # These programs will be available inside the nix-shell. - nativeBuildInputs = with pkgs; with haskellPackages; with cardanoNodePackages; [ - db-analyser - cardano-cli.passthru.noGitRev - pkgs.graphviz - graphmod - jq - weeder - nix - (pkgs.pkg-config or pkgconfig) - pkgs.profiteur - profiterole - ghc-prof-flamegraph - sqlite-interactive - tmux - pkgs.cairo - pkgs.dyff - pkgs.git - pkgs.hlint - pkgs.moreutils - pkgs.time - pkgs.util-linux - workbench-runner.workbench-interactive-start - workbench-runner.workbench-interactive-stop - workbench-runner.workbench-interactive-restart - ] + nativeBuildInputs = + (with pkgs; [ + cairo + dyff + em # Performance report generation + git + graphviz + hlint + jq + moreutils + nix + (pkgs.pkg-config or pkgconfig) + profiteur + sqlite-interactive + time + tmux + util-linux + ]) + ++ (with pkgs.haskellPackages; [ + ghc-prof-flamegraph + graphmod + profiterole + weeder + ]) + ++ + ## Cabal run flag: + # Include the packages or the tools to build them (see `lib-cabal.sh`). + (if !workbench-runner.useCabalRun + then + (with project.exes; [ + # A `notGitRev` version, faster to enter a workbench after a new commit. + cardano-node + cardano-profile + cardano-topology + cardano-tracer + locli + # A `notGitRev` version, faster to enter a workbench after a new commit. + tx-generator + ]) + else + (with pkgs; [ + pkgs.cabal-install + pkgs.ghcid + pkgs.haskellBuildUtils + pkgs.cabal-plan + ]) + ) + ++ (with project.hsPkgs; [ + # A `notGitRev` version, faster to enter a workbench after a new commit. + cardano-cli.components.exes.cardano-cli + ouroboros-consensus-cardano.components.exes.db-analyser + ]) + ++ (with workbench-runner; [ + workbench-interactive-start + workbench-interactive-stop + workbench-interactive-restart + ]) # Backend dependent packages take precedence. - ++ workbench-runner.backend.extraShellPkgs + ++ workbench-runner.extraShellPkgs ++ [ # Publish - bench-data-publish + pkgs.bench-data-publish # Debugging - postgresql - # Performance report generation - em + pkgs.postgresql ] ++ lib.optional haveGlibcLocales pkgs.glibcLocales - ## Cabal run flag - # Include the packages (defined in `lib-cabal.sh`) or the tools to build them. - ++ lib.optionals ( workbench-runner.backend.useCabalRun) [ - cabal-install - ghcid - haskellBuildUtils - pkgs.cabal-plan - ] - ++ lib.optionals (!workbench-runner.backend.useCabalRun) [ - cardano-node.passthru.noGitRev - cardano-profile - cardano-topology - cardano-tracer - locli - tx-generator.passthru.noGitRev + + ## When profiling include useful helper programs. + ++ lib.optionals ( workbench-runner.profiling != null + && workbench-runner.profiling != "none" + ) + [ + # For the legacy prog.hp format. + # Which has been deprecated in favour of eventlog based profiling. + pkgs.haskellPackages.hp2pretty + pkgs.haskellPackages.hp2html + pkgs.haskellPackages.eventlog2html ] # Include the workbench as a derivation or use the sources directly ? ++ lib.optionals (!workbenchDevMode) [ workbench.workbench ] diff --git a/nix/workbench/wb b/nix/workbench/wb index 14ff3a7510f..d4d6b9579a2 100755 --- a/nix/workbench/wb +++ b/nix/workbench/wb @@ -209,7 +209,7 @@ start() { esac; shift; done if test -n "$cabal_mode" - then . $(dirname "$0")/lib-cabal.sh ${WB_PROFILING:+--profiling-${WB_PROFILING}} + then . $(dirname "$0")/lib-cabal.sh fi backend validate diff --git a/nix/workbench/workload/cgroup_memory.nix b/nix/workbench/workload/cgroup_memory.nix index b8e9b60c3e2..b92bb6416eb 100644 --- a/nix/workbench/workload/cgroup_memory.nix +++ b/nix/workbench/workload/cgroup_memory.nix @@ -1,4 +1,5 @@ { pkgs +, haskellProject , profile , nodeSpecs , workload diff --git a/nix/workbench/workload/latency.nix b/nix/workbench/workload/latency.nix index 70be055d360..5c2d2bbba2e 100644 --- a/nix/workbench/workload/latency.nix +++ b/nix/workbench/workload/latency.nix @@ -1,4 +1,5 @@ { pkgs +, haskellProject , profile , nodeSpecs , workload diff --git a/nix/workbench/workload/voting.nix b/nix/workbench/workload/voting.nix index 922ccc7bb2d..b68f0c885cd 100644 --- a/nix/workbench/workload/voting.nix +++ b/nix/workbench/workload/voting.nix @@ -1,4 +1,5 @@ { pkgs +, haskellProject , profile , nodeSpecs , workload @@ -13,7 +14,7 @@ let coreutils = pkgs.coreutils; jq = pkgs.jq; # Avoid rebuilding on every commit because of `set-git-rev`. - cardano-cli = pkgs.cardanoNodePackages.cardano-cli.passthru.noGitRev; + cardano-cli = haskellProject.hsPkgs.cardano-cli.components.exes.cardano-cli; # Script params! ################ diff --git a/shell.nix b/shell.nix index b13ed965a7d..19843f721e4 100644 --- a/shell.nix +++ b/shell.nix @@ -27,16 +27,58 @@ let profilingEff = if profiling == "none" + # Time and allocation profiling. + ################################ + ### `-p`: produces a standard time profile report. || profiling == "time" + ### `-P`: produces a more detailed report containing the actual time and + ### allocation data as well (not used much.). || profiling == "time-detail" + # RTS options for heap profiling + ################################ + # There are several different kinds of heap profile that can be + # generated. All the different profile types yield a graph of live heap + # against time, but they differ in how the live heap is broken down into + # bands. The following RTS options select which break-down to use: + ### `-hb` (Requires -prof): + ### Breaks down the graph by biography. + || profiling == "space-bio" + ### `-hd` (Requires -prof): + ### Breaks down the graph by closure description. For actual data, the + ### description is just the constructor name, for other closures it is a + ### compiler-generated string identifying the closure. + || profiling == "space-closure" + ### `-hc` (Requires -prof): + ### Breaks down the graph by the cost-centre stack which produced the + ### data. || profiling == "space-cost" + ### `-hT` (This does not require the profiling runtime): + ### Breaks down the graph by heap closure type. || profiling == "space-heap" + ### `-hi` (This does not require the profiling runtime): + ### Break down the graph by the address of the info table of a closure. + ### For this to produce useful output the program must have been compiled + ### with -finfo-table-map but it does not require the profiling runtime. + || profiling == "space-info" + ### `-hm` (Requires -prof). + ### Break down the live heap by the module containing the code which + ### produced the data. || profiling == "space-module" + ### `-hr` (Requires -prof): + ### Break down the graph by retainer set. || profiling == "space-retainer" + ### `-hy` (Requires -prof): + ### Breaks down the graph by type. For closures which have function type + ### or unknown/polymorphic type, the string will represent an + ### approximation to the actual type. || profiling == "space-type" then profiling - else throw "FATAL: WB_PROFILING must be one of: none, time, time-detail, space-cost, space-heap, space-module, space-retainer, space-type"; - project = if profilingEff != "none" then cardanoNodeProject.profiled else cardanoNodeProject; + else throw "FATAL: WB_PROFILING must be one of: none, time, time-detail, space-bio, space-closure, space-cost, space-heap, space-info, space-module, space-retainer, space-type"; + + project = if profilingEff != "none" + then cardanoNodeProject.profiled + else cardanoNodeProject + ; ## The default shell is defined by flake.nix: (cardanoNodeProject = flake.project.${final.system}) inherit (project) shell;