Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

perf(ci): give test binaries their own profile and fix the cache key collision

buger428dc1e0371e
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a0d55144b..a00e99954 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -63,15 +63,9 @@ jobs:
components: rustfmt, clippy
- name: Cache
- uses: actions/cache@v4
+ uses: Swatinem/rust-cache@v2
with:
- path: |
- ~/.cargo/registry/cache
- ~/.cargo/registry/index
- ~/.cargo/git/db
- engine/target
- key: ci-lint-cargo-${{ hashFiles('engine/Cargo.lock') }}
- restore-keys: ci-lint-cargo-
+ workspaces: engine
- name: rustfmt (check)
working-directory: engine
@@ -185,24 +179,51 @@ jobs:
uses: dtolnay/rust-toolchain@stable
- name: Cache
- uses: actions/cache@v4
+ uses: Swatinem/rust-cache@v2
with:
- path: |
- ~/.cargo/registry/cache
- ~/.cargo/registry/index
- ~/.cargo/git/db
- engine/target
- key: ci-cargo-${{ hashFiles('engine/Cargo.lock') }}
- restore-keys: ci-cargo-
+ workspaces: engine
+
+ # One cargo invocation, not two. `cargo build --release --workspace` used
+ # to run first, but `panic = "abort"` in [profile.release] makes cargo
+ # rebuild the whole dependency graph with `panic = "unwind"` for the test
+ # targets, so that step handed the tests almost nothing: on run
+ # 31571998506 it compiled 39 crates in 9m17s and the test step then
+ # compiled 453. The fat-LTO link of every workspace member is still
+ # gated -- it moved to the `release-build` job, which runs concurrently
+ # instead of in front of this one.
+ #
+ # [profile.ci-test] keeps opt-level 3 and release's assertion settings and
+ # only drops whole-program LTO / codegen-unit merging. Fat-LTO linking of
+ # ~99 separate test binaries was 76m05s of this job's 78-minute test step;
+ # the tests themselves ran in 1m52s.
+ - name: Unit + integration tests
+ working-directory: engine
+ run: cargo test --profile ci-test --workspace -- --test-threads=2
+
+ # Fat LTO + codegen-units=1 + panic=abort over every workspace member is a
+ # failure mode of its own (LTO ICEs, symbol collisions, panic-strategy
+ # mismatches) and is not covered by `cargo clippy --all-targets` in `lint`
+ # nor by the `-p xerj-server` builds elsewhere -- xerj-wasm, for one, is in
+ # no other job's dependency closure. So it stays gated, just not in series
+ # with the tests.
+ release-build:
+ name: Release build (fat LTO, all members link)
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install Rust
+ uses: dtolnay/rust-toolchain@stable
+
+ - name: Cache
+ uses: Swatinem/rust-cache@v2
+ with:
+ workspaces: engine
- name: Build (release)
working-directory: engine
run: cargo build --release --workspace
- - name: Unit + integration tests
- working-directory: engine
- run: cargo test --release --workspace -- --test-threads=2
-
onnx-feature:
name: ONNX feature compile + tests
runs-on: ubuntu-latest
@@ -215,15 +236,9 @@ jobs:
components: clippy
- name: Cache
- uses: actions/cache@v4
+ uses: Swatinem/rust-cache@v2
with:
- path: |
- ~/.cargo/registry/cache
- ~/.cargo/registry/index
- ~/.cargo/git/db
- engine/target
- key: ci-onnx-cargo-${{ hashFiles('engine/Cargo.lock') }}
- restore-keys: ci-onnx-cargo-
+ workspaces: engine
- name: Compile the server ONNX feature path
working-directory: engine
@@ -251,15 +266,9 @@ jobs:
uses: dtolnay/rust-toolchain@stable
- name: Cache
- uses: actions/cache@v4
+ uses: Swatinem/rust-cache@v2
with:
- path: |
- ~/.cargo/registry/cache
- ~/.cargo/registry/index
- ~/.cargo/git/db
- engine/target
- key: ci-cargo-${{ hashFiles('engine/Cargo.lock') }}
- restore-keys: ci-cargo-
+ workspaces: engine
- uses: actions/setup-node@v4
with:
@@ -285,15 +294,9 @@ jobs:
uses: dtolnay/rust-toolchain@stable
- name: Cache
- uses: actions/cache@v4
+ uses: Swatinem/rust-cache@v2
with:
- path: |
- ~/.cargo/registry/cache
- ~/.cargo/registry/index
- ~/.cargo/git/db
- engine/target
- key: ci-cargo-${{ hashFiles('engine/Cargo.lock') }}
- restore-keys: ci-cargo-
+ workspaces: engine
- name: Build server + conformance runner (release)
working-directory: engine
@@ -410,15 +413,9 @@ jobs:
uses: dtolnay/rust-toolchain@stable
- name: Cache
- uses: actions/cache@v4
+ uses: Swatinem/rust-cache@v2
with:
- path: |
- ~/.cargo/registry/cache
- ~/.cargo/registry/index
- ~/.cargo/git/db
- engine/target
- key: ci-cargo-${{ hashFiles('engine/Cargo.lock') }}
- restore-keys: ci-cargo-
+ workspaces: engine
- name: Build xerj + xerj-mcp (release)
working-directory: engine
@@ -449,15 +446,9 @@ jobs:
uses: dtolnay/rust-toolchain@stable
- name: Cache
- uses: actions/cache@v4
+ uses: Swatinem/rust-cache@v2
with:
- path: |
- ~/.cargo/registry/cache
- ~/.cargo/registry/index
- ~/.cargo/git/db
- engine/target
- key: ci-smoke-${{ matrix.os }}-${{ hashFiles('engine/Cargo.lock') }}
- restore-keys: ci-smoke-${{ matrix.os }}-
+ workspaces: engine
- name: Build xerj (release)
working-directory: engine
diff --git a/engine/Cargo.toml b/engine/Cargo.toml
index c75b5731e..f9c93d111 100644
--- a/engine/Cargo.toml
+++ b/engine/Cargo.toml
@@ -117,6 +117,28 @@ codegen-units = 1
strip = true
panic = "abort"
+# CI test profile. Identical *code semantics* to [profile.release] --
+# opt-level 3, debug-assertions off, overflow-checks off -- so tests still
+# exercise optimized codegen. Only the optimization *scope* changes: no
+# whole-program LTO and 16 codegen units instead of 1.
+#
+# Why it exists: `cargo test --release` links every one of the ~99 test
+# binaries with fat LTO + codegen-units=1. On CI run 31571998506 that was
+# 76m05s of compilation for 1m52s of actual test execution. `panic = "abort"`
+# additionally forces cargo to rebuild the entire dependency graph with
+# `panic = "unwind"` for test targets, so a preceding `cargo build --release`
+# shares almost nothing with it; `panic = "unwind"` here makes that split
+# explicit rather than accidental.
+#
+# [profile.release] above is deliberately untouched: release.yml builds the
+# shipped binary with `cargo build --release`, and it must stay fat-LTO.
+[profile.ci-test]
+inherits = "release"
+lto = false
+codegen-units = 16
+panic = "unwind"
+strip = false
+
# Fast iteration profile: symbolized with thin LTO and parallel codegen.
# It is intentionally not production-codegen-equivalent.
[profile.profiling]