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

perf: Use LTO in image builds #1032

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ categories = ["game-development", "network-programming"]
edition.workspace = true
exclude = ["docs", "build", "examples", "image"]

[profile.lto]
inherits = "release"
opt-level = 3
codegen-units = 1
lto = "fat"

[features]
default = []
instrument = []
mimalloc = ["dep:mimalloc"]
heap-stats = ["dep:crossbeam-utils"]


[lints]
workspace = true

Expand Down
8 changes: 4 additions & 4 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ kube_mount_args := -v $(kubeconfig_path):/root/.kube -v $(helm_config):/root/.co
minikube_args := --network=host -v ~/.minikube:$(HOME)/.minikube
gcloud_mount_args := -v $(build_path)/.config/gcloud:/root/.config/gcloud

cargo_build_x86_64_linux := build --release --target x86_64-unknown-linux-gnu
cargo_build_x86_64_linux := build --profile=lto --target x86_64-unknown-linux-gnu
cargo_build_x86_64_apple := build --release --target x86_64-apple-darwin
cargo_build_aarch64-apple := build --release --target aarch64-apple-darwin
cargo_build_x86_64_windows := build --release --target x86_64-pc-windows-gnu
Expand Down Expand Up @@ -140,7 +140,7 @@ gen-protobuf: ensure-build-image
# Build an archive all binaries
binary-archive: ensure-build-image build-licence-report build-all-binaries
docker run --rm $(common_rust_args) -w $(CARGO_TARGET_DIR) \
--entrypoint=bash $(BUILD_IMAGE_TAG) -c 'cp ../../license.html . && zip ../../quilkin-$(package_version).zip ./*/release/quilkin ./*/release/quilkin.exe ./license.html'
--entrypoint=bash $(BUILD_IMAGE_TAG) -c 'cp ../../license.html . && zip ../../quilkin-$(package_version).zip ./*/lto/quilkin ./*/lto/quilkin.exe ./license.html'

# Build binary for x86_64-unknown-linux-gnu.
# Use BUILD_LOCAL=1 to build through local cargo rather than through the build container.
Expand Down Expand Up @@ -188,9 +188,9 @@ build-image: ensure-build-image build-licence-report build-linux-binary
build-image:
-mkdir -p "$(project_path)/target/image/"
ifdef BUILD_LOCAL
cp "$(project_path)/target/x86_64-unknown-linux-gnu/release/quilkin" "$(project_path)/target/image/"
cp "$(project_path)/target/x86_64-unknown-linux-gnu/lto/quilkin" "$(project_path)/target/image/"
else
cp "$(project_path)/target/build-image/x86_64-unknown-linux-gnu/release/quilkin" "$(project_path)/target/image/"
cp "$(project_path)/target/build-image/x86_64-unknown-linux-gnu/lto/quilkin" "$(project_path)/target/image/"
endif
docker run --rm $(common_rust_args) \
--entrypoint=bash $(BUILD_IMAGE_TAG) -c './image/archive_dependencies.sh'
Expand Down
Loading