From 3958f46163258d0d2bb71bcc7777cd334cdb2665 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Tue, 4 Jul 2023 17:01:36 +0100 Subject: [PATCH] add build-pgo make target --- Makefile | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 122eca7cf..7d88cd7b7 100644 --- a/Makefile +++ b/Makefile @@ -16,23 +16,35 @@ install-rust-coverage: cargo install rustfilt coverage-prepare rustup component add llvm-tools-preview +.PHONY: install-pgo + rustup component add llvm-tools-preview + .PHONY: build-dev build-dev: @rm -f python/pydantic_core/*.so - cargo build --features extension-module - @rm -f target/debug/lib_pydantic_core.d - @rm -f target/debug/lib_pydantic_core.rlib - @mv target/debug/lib_pydantic_core.* python/pydantic_core/_pydantic_core.so + pip install -v -e . --config-settings=build-args='--profile dev' .PHONY: build-prod build-prod: @rm -f python/pydantic_core/*.so - maturin develop --release + pip install -v -e . .PHONY: build-coverage build-coverage: - rm -f python/pydantic_core/*.so - maturin develop -- -C instrument-coverage + @rm -f python/pydantic_core/*.so + RUSTFLAGS='-C instrument-coverage' pip install -v -e . + +.PHONY: build-pgo +build-pgo: + @rm -f python/pydantic_core/*.so + $(eval PROFDATA := $(shell mktemp -d)) + RUSTFLAGS='-Cprofile-generate=$(PROFDATA)' pip install -v -e . + pytest tests/benchmarks + $(eval LLVM_PROFDATA := $(shell rustup run stable bash -c 'echo $$RUSTUP_HOME/toolchains/$$RUSTUP_TOOLCHAIN/lib/rustlib/$$(rustc -Vv | grep host | cut -d " " -f 2)/bin/llvm-profdata')) + $(LLVM_PROFDATA) merge -o $(PROFDATA)/merged.profdata $(PROFDATA) + RUSTFLAGS='-Cprofile-use=$(PROFDATA)/merged.profdata' pip install -v -e . + @rm -rf $(PROFDATA) + .PHONY: build-wasm build-wasm: