From ab032ec74b892e70b1004ea8b2d53a350b9cd6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vinh=20Tr=E1=BB=8Bnh?= <108657096+vinhtc27@users.noreply.github.com> Date: Tue, 23 Sep 2025 18:18:52 +0700 Subject: [PATCH] Use all best practice to squeeze a few more TPS out of Prover (#38) --- Cargo.toml | 9 +++++++++ Makefile | 15 +++++++++++++++ prover_cli/Cargo.toml | 4 ---- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 Makefile diff --git a/Cargo.toml b/Cargo.toml index f54ab8c..74ae87c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,3 +42,12 @@ tonic-prost-build = "0.14.1" #[dev.dependencies] criterion = { version = "0.7.0", features = ["async_tokio"] } + +[profile.release] +lto = "fat" +codegen-units = 1 +opt-level = 3 +debug = false +panic = "abort" +strip = true +incremental = false diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3f9b583 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +NATIVE_FLAGS = -C target-cpu=native + +.PHONY: build +build: + cargo build --release $(ARGS) + +RAYON_NUM_THREADS ?= 64 +PROOF_SERVICE_COUNT ?= 64 +PROOF_COUNT ?= 64 + +.PHONY: bench +bench: + RAYON_NUM_THREADS=$(RAYON_NUM_THREADS) PROOF_SERVICE_COUNT=$(PROOF_SERVICE_COUNT) PROOF_COUNT=$(PROOF_COUNT) RUSTFLAGS="$(NATIVE_FLAGS)" cargo bench $(ARGS) + +# Example: make bench RAYON_NUM_THREADS=128 PROOF_SERVICE_COUNT=32 PROOF_COUNT=8 ARGS="--bench prover_bench" \ No newline at end of file diff --git a/prover_cli/Cargo.toml b/prover_cli/Cargo.toml index 402d13b..400951a 100644 --- a/prover_cli/Cargo.toml +++ b/prover_cli/Cargo.toml @@ -24,7 +24,3 @@ opentelemetry-otlp = { version = "0.30.0", features = [ "tls-roots", ] } tracing-opentelemetry = "0.31.0" - -[profile.release] -codegen-units = 1 # Do not split into multiple codegen units, improve performance, may compile slower -lto = "fat" # Enables Link Time Optimization, enabling more aggressive optimizations across the entire codebase \ No newline at end of file