From e01952c5d732e53e0c85d837d51bf2c9962abc4e Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Thu, 26 Feb 2026 23:53:07 +0100 Subject: [PATCH] feat(ci): add dev-release profile for fast CI iteration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Cargo profile `dev-release` (opt-level=2, thin LTO, 16 codegen-units) for ~3-5x faster compile vs full release. Activate by setting DEV_RELEASE=true in pipeline variables — skips check stage and uses fast profile. - Move profile definitions from .cargo/config.toml to Cargo.toml (config.toml silently ignores [profile.*] blocks — they were dead code) - Add hft and bench profiles to Cargo.toml (were only in config.toml) - compile-services now selects profile via $DEV_RELEASE env var - test stage uses optional check dependency (runs without check in dev mode) Co-Authored-By: Claude Opus 4.6 --- .cargo/config.toml | 22 ++-------------------- .gitlab-ci.yml | 25 ++++++++++++++++++------- Cargo.toml | 25 ++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 8a58a6859..cd418dbec 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -37,24 +37,6 @@ rustflags = [ # forcing full O3 + single-thread codegen on test builds. ] -[profile.release] -opt-level = 3 -lto = "fat" -codegen-units = 1 -panic = "abort" -strip = false -debug = false -overflow-checks = false -[profile.bench] -inherits = "release" -debug = false - -[profile.hft] -inherits = "release" -opt-level = 3 -lto = "fat" -codegen-units = 1 -panic = "abort" -strip = false -overflow-checks = false +# Profile definitions live in Cargo.toml — [profile.*] blocks in config.toml +# are silently ignored by Cargo. Do NOT add profiles here. diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2d33cad8c..8068c10ac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,6 +36,9 @@ variables: # sccache base dir on PVC — GPU stages override to /mnt/sccache/sm_ SCCACHE_DIR: "/mnt/sccache" RUSTC_WRAPPER: /usr/local/bin/sccache + # Build profile: "release" (default, fat LTO) or "dev-release" (thin LTO, fast) + # Set DEV_RELEASE=true in pipeline vars or CI/CD settings to use fast profile + CARGO_BUILD_PROFILE: release # S3 credentials for Kaniko registry auth and Dockerfile builds AWS_ACCESS_KEY_ID: $SCW_ACCESS_KEY AWS_SECRET_ACCESS_KEY: $SCW_SECRET_KEY @@ -160,6 +163,8 @@ check: stage: check needs: [] rules: + - if: $DEV_RELEASE == "true" + when: never - if: $CI_PIPELINE_SOURCE == "push" changes: - Cargo.toml @@ -194,7 +199,9 @@ check: test: extends: .rust-base stage: test - needs: [check] # check is a fast no-op; keeps stage ordering + needs: + - job: check + optional: true # skipped in dev-release mode rules: - if: $CI_PIPELINE_SOURCE == "push" changes: @@ -269,8 +276,12 @@ compile-services: - export SCCACHE_DIR="/mnt/sccache/sm_${CUDA_COMPUTE_CAP}" - mkdir -p "$SCCACHE_DIR" - sccache --zero-stats || true + # Select build profile: dev-release (fast, thin LTO) or release (full, fat LTO) + - PROFILE=${DEV_RELEASE:+dev-release}; PROFILE=${PROFILE:-release} + - echo "Building with --profile $PROFILE" + - TARGET_DIR="target/$PROFILE" # 1) Build service binaries (no CUDA feature) - - cargo build --release + - cargo build --profile $PROFILE -p trading_service -p api_gateway -p broker_gateway_service @@ -280,7 +291,7 @@ compile-services: -p data_acquisition_service -p web-gateway # 2) Build training binaries with CUDA (sccache already warm from step 1) - - cargo build --release -p ml --features ml/cuda + - cargo build --profile $PROFILE -p ml --features ml/cuda --example train_baseline_rl --example train_baseline_supervised --example evaluate_baseline @@ -288,19 +299,19 @@ compile-services: --example hyperopt_baseline_rl --example hyperopt_baseline_supervised # 3) Build training uploader sidecar (no CUDA needed) - - cargo build --release -p training_uploader + - cargo build --profile $PROFILE -p training_uploader - sccache --show-stats || true - mkdir -p build-out - | for bin in trading_service api_gateway broker_gateway_service ml_training_service backtesting_service trading_agent_service data_acquisition_service web-gateway; do - cp target/release/$bin build-out/ + cp $TARGET_DIR/$bin build-out/ strip build-out/$bin done for bin in train_baseline_rl train_baseline_supervised evaluate_baseline evaluate_supervised hyperopt_baseline_rl hyperopt_baseline_supervised; do - cp target/release/examples/$bin build-out/ + cp $TARGET_DIR/examples/$bin build-out/ strip build-out/$bin done - cp target/release/training_uploader build-out/ + cp $TARGET_DIR/training_uploader build-out/ strip build-out/training_uploader - ls -lh build-out/ artifacts: diff --git a/Cargo.toml b/Cargo.toml index 7ae1fda40..9dafc376b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -405,11 +405,34 @@ opt-level = 3 debug = false debug-assertions = false overflow-checks = false -lto = true +lto = "fat" panic = 'abort' codegen-units = 1 strip = true +# Fast release builds for CI iteration — skip fat LTO, parallelize codegen. +# Usage: cargo build --profile dev-release -p +# ~3-5x faster compile than full release, ~10-15% slower runtime. +[profile.dev-release] +inherits = "release" +opt-level = 2 +lto = "thin" +codegen-units = 16 +strip = true + +# HFT production profile — identical to release but preserves frame pointers +# for perf profiling. Used by deploy scripts. +[profile.hft] +inherits = "release" +opt-level = 3 +lto = "fat" +codegen-units = 1 +strip = false + +[profile.bench] +inherits = "release" +debug = false + [profile.test] opt-level = 0 # Disable optimizations for faster test compilation debug = 0 # Remove debug info completely for faster linking