From 18a5c326bd369eb58a17253a632c9e70b206b239 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Thu, 12 Oct 2023 12:28:24 +0000 Subject: [PATCH] ci: fix unnecessary node rebuilds during benchmarking --- --- a/Makefile +++ b/Makefile @@ -88,69 +88,36 @@ evm_stubs: UniqueFungible UniqueNFT UniqueRefungible UniqueRefungibleToken ContractHelpers CollectionHelpers -.PHONY: _bench -_bench: - cargo run --profile production --features runtime-benchmarks,$(RUNTIME) -- \ - benchmark pallet --pallet pallet-$(if $(PALLET),$(PALLET),$(error Must set PALLET)) \ - --wasm-execution compiled --extrinsic '*' \ - $(if $(TEMPLATE),$(TEMPLATE),--template=.maintain/frame-weight-template.hbs) --steps=50 --repeat=80 --heap-pages=4096 \ - --output=$(if $(OUTPUT),$(OUTPUT),./pallets/$(if $(PALLET_DIR),$(PALLET_DIR),$(PALLET))/src/weights.rs) - -.PHONY: bench-evm-migration -bench-evm-migration: - make _bench PALLET=evm-migration - -.PHONY: bench-configuration -bench-configuration: - make _bench PALLET=configuration - -.PHONY: bench-common -bench-common: - make _bench PALLET=common - -.PHONY: bench-unique -bench-unique: - make _bench PALLET=unique - -.PHONY: bench-fungible -bench-fungible: - make _bench PALLET=fungible - -.PHONY: bench-refungible -bench-refungible: - make _bench PALLET=refungible - -.PHONY: bench-nonfungible -bench-nonfungible: - make _bench PALLET=nonfungible - -.PHONY: bench-structure -bench-structure: - make _bench PALLET=structure - -.PHONY: bench-foreign-assets -bench-foreign-assets: - make _bench PALLET=foreign-assets - -.PHONY: bench-collator-selection -bench-collator-selection: - make _bench PALLET=collator-selection +# TODO: Create benchmarking profile, make it a proper dependency +.PHONY: benchmarking-node +benchmarking-node: + cargo build --profile production --features runtime-benchmarks -.PHONY: bench-identity -bench-identity: - make _bench PALLET=identity +define _bench = +.PHONY: bench-$(1) +bench-$(1): benchmarking-node + ./target/production/unique-collator \ + benchmark pallet --pallet pallet-$(1) \ + --wasm-execution compiled --extrinsic '*' \ + $(if $(4),$(4),--template=.maintain/frame-weight-template.hbs) --steps=50 --repeat=80 --heap-pages=4096 \ + --output=$$(if $(3),$(3),./pallets/$(if $(2),$(2),$(1))/src/weights.rs) +endef -.PHONY: bench-app-promotion -bench-app-promotion: - make _bench PALLET=app-promotion - -.PHONY: bench-maintenance -bench-maintenance: - make _bench PALLET=maintenance - -.PHONY: bench-xcm -bench-xcm: - make _bench PALLET=xcm OUTPUT=./runtime/common/weights/xcm.rs TEMPLATE="--template=.maintain/external-weight-template.hbs" +# _bench,pallet,(pallet_dir|),(output|),(extra|) +$(eval $(call _bench,evm-migration)) +$(eval $(call _bench,configuration)) +$(eval $(call _bench,common)) +$(eval $(call _bench,unique)) +$(eval $(call _bench,fungible)) +$(eval $(call _bench,refungible)) +$(eval $(call _bench,nonfungible)) +$(eval $(call _bench,structure)) +$(eval $(call _bench,foreign-assets)) +$(eval $(call _bench,collator-selection)) +$(eval $(call _bench,identity)) +$(eval $(call _bench,app-promotion)) +$(eval $(call _bench,maintenance)) +$(eval $(call _bench,xcm,,./runtime/common/weights/xcm.rs,"--template=.maintain/external-weights/template.hbs")) .PHONY: bench bench: bench-app-promotion bench-common bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-configuration bench-foreign-assets bench-maintenance bench-xcm bench-collator-selection bench-identity -- gitstuff