Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add build-pgo make target #741

Merged
merged 3 commits into from
Jul 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ black = black python/pydantic_core tests generate_self_schema.py wasm-preview/ru
ruff = ruff python/pydantic_core tests generate_self_schema.py wasm-preview/run_tests.py
mypy-stubtest = python -m mypy.stubtest pydantic_core._pydantic_core --allowlist .mypy-stubtest-allowlist

# using pip install cargo (via maturin via pip) doesn't get the tty handle
# so doesn't render color without some help
export CARGO_TERM_COLOR=$(shell (test -t 0 && echo "always") || echo "auto")

.PHONY: install
install:
pip install -U pip wheel pre-commit
Expand All @@ -16,23 +20,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'
davidhewitt marked this conversation as resolved.
Show resolved Hide resolved

.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:
Expand Down