Skip to content

Commit

Permalink
hlint-bench: pass --max-jobs, --cores more places
Browse files Browse the repository at this point in the history
nix.mk should not be touched even if it looks like an issue.
  • Loading branch information
NadiaYvette committed Aug 14, 2024
1 parent 43742d2 commit 1dd1341
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
help: ## Print documentation
@{ grep -hE '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST); echo -e '$(EXTRA_HELP)'; } | sed 's/^ //' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-33s\033[0m %s\n", $$1, $$2}'

NUM_PROC:=$(shell nproc --all)
MFLAGS_STRIP:=$(strip $(MAKEFLAGS))
MFLAGS_FIRST:=$(firstword $(filter --j%,-$(MFLAGS_STRIP)))
ifneq (,$(MFLAGS_FIRST))
JOBS:=$(subst --j,,$(MFLAGS_FIRST))
JOBS:=$(intcmp $(JOBS),$(NUM_PROC),$(NUM_PROC),$(NUM_PROC),$(JOBS))
endif

include lib.mk
include nix.mk

PROJECT_NAME = cardano-node
NUM_PROC = $(shell nproc --all)

## One of: coay shey alra mary alzo bage
ERA ?= coay
Expand All @@ -18,25 +25,26 @@ BATCH ?=
ARGS ?=
CMD ?=
RUN ?=
JOBS ?=: $(shell expr $(NUM_PROC) \* 5)

lint hlint: ## Run the CI version of hlint
nix build --no-link '.#checks/hlint' --cores 0
nix build --no-link '.#checks/hlint' --max-jobs $(JOBS) --cores 0
haddock-hoogle haddocks hoogle:
if test -z "$$IN_NIX_SHELL"; then nix-shell --run 'cabal update && cabal haddock all --haddock-hoogle'; else cabal update && cabal haddock all --haddock-hoogle; fi
if test -z "$$IN_NIX_SHELL"; then nix-shell --max-jobs $(JOBS) --cores 0 --run "cabal update && cabal --jobs=$$JOBS haddock all --haddock-hoogle"; else cabal update && cabal --jobs=$(JOBS) haddock all --haddock-hoogle; fi
host-hlint: ## Run the system (not Nix) version of hlint
hlint bench cardano-{api,cli,node,node-capi,node-chairman,submit-api,testnet,tracer}

stylish-haskell: ## Apply stylish-haskell on all *.hs files
@find . -type f -name "*.hs" -not -path '.git' -print0 | xargs -0 stylish-haskell -i

cabal-hashes:
nix run .#checkCabalProject
nix run --max-jobs $(JOBS) --cores 0 .#checkCabalProject

cli node:
cabal --ghc-options="+RTS -qn8 -A32M -RTS" build cardano-$@
cabal --jobs=$(JOBS) --ghc-options="+RTS -qn8 -A32M -RTS" build cardano-$@

trace-documentation:
cabal run -- exe:cardano-node trace-documentation --config 'configuration/cardano/mainnet-config-new-tracing.yaml' --output-file 'doc/new-tracing/tracers_doc_generated.md'
cabal --jobs=$(JOBS) run -- exe:cardano-node trace-documentation --config 'configuration/cardano/mainnet-config-new-tracing.yaml' --output-file 'doc/new-tracing/tracers_doc_generated.md'

###
### Workbench
Expand All @@ -55,7 +63,7 @@ workbench-internals-walkthrough:
## Base targets:
##
shell: ## Nix shell, (workbench from /nix/store), vars: PROFILE, CMD, RUN
nix-shell -A 'workbench-shell' --max-jobs 8 --cores 0 --show-trace --argstr profileName ${PROFILE} --argstr backendName ${BACKEND} ${ARGS} ${if ${CMD},--command "${CMD}"} ${if ${RUN},--run "${RUN}"}
nix-shell -A 'workbench-shell' --max-jobs $(JOBS) --cores 0 --show-trace --argstr profileName ${PROFILE} --argstr backendName ${BACKEND} ${ARGS} ${if ${CMD},--command "${CMD}"} ${if ${RUN},--run "${RUN}"}
shell-dev shell-prof shell-nix: shell
shell-nix: ARGS += --arg 'useCabalRun' false ## Nix shell, (workbench from Nix store), vars: PROFILE, CMD, RUN
shell-prof: ARGS += --arg 'profiling' '"space"' ## Nix shell, everything Haskell built profiled
Expand All @@ -64,12 +72,12 @@ analyse: RUN := wb analyse std ${TAG}
analyse: shell

list-profiles: ## List workbench profiles
nix build .#all-profiles-json && cat result
nix build --max-jobs $(JOBS) --cores 0 .#all-profiles-json && cat result
show-profile: ## NAME=profile-name
@test -n "${NAME}" || { echo 'HELP: to specify profile to show, add NAME=profle-name' && exit 1; }
nix build .#all-profiles-json --json --option substitute false | jq '.[0].outputs.out' -r | xargs jq ".\"${NAME}\" | if . == null then error(\"\n###\n### Error: unknown profile: ${NAME} Please consult: make list-profiles\n###\") else . end"
nix build --max-jobs $(JOBS) --cores 0 .#all-profiles-json --json --option substitute false | jq '.[0].outputs.out' -r | xargs jq ".\"${NAME}\" | if . == null then error(\"\n###\n### Error: unknown profile: ${NAME} Please consult: make list-profiles\n###\") else . end"
ps: ## Plain-text list of profiles
@nix build .#workbench.profile-names-json --json | jq '.[0].outputs.out' -r | xargs jq '.[]' --raw-output
@nix build --max-jobs $(JOBS) --cores 0 .#workbench.profile-names-json --json | jq '.[0].outputs.out' -r | xargs jq '.[]' --raw-output

##
## Profile-based cluster shells (autogenerated targets)
Expand Down

0 comments on commit 1dd1341

Please sign in to comment.