Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
test(soak): real multi-hour #581 soak (query-leak mode) + fix soak timeout cap
Martin Vogel23333bc7f3e0
diff --git a/.github/workflows/_soak.yml b/.github/workflows/_soak.ymlindex f5799aa2a..3a10d6e6e 100644--- a/.github/workflows/_soak.yml+++ b/.github/workflows/_soak.yml@@ -47,7 +47,12 @@ jobs:cc: cccxx: c++runs-on: ${{ matrix.os }}- timeout-minutes: 30+ # BUG FIX: this was hard-coded to 30, but the caller (nightly-soak.yml)+ # passes duration_minutes: 240. GitHub killed the job at 30 min, so the+ # "4h nightly soak" was SILENTLY TRUNCATED to 30 min and never once ran+ # multi-hour. Budget must always exceed the passed duration; 300 covers+ # the 240-min nightly with headroom (build + analysis + idle phases).+ timeout-minutes: 300steps:- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3- name: Install deps (Linux)@@ -67,7 +72,10 @@ jobs:soak-quick-windows:runs-on: windows-latest- timeout-minutes: 30+ # BUG FIX (same 30→240 mismatch as soak-quick above): the caller passes+ # duration_minutes: 240, so a 30-min cap truncated the nightly soak here+ # too. 300 covers the 240-min nightly with headroom.+ timeout-minutes: 300steps:- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2@@ -125,7 +133,12 @@ jobs:cc: cccxx: c++runs-on: ${{ matrix.os }}- timeout-minutes: 45+ # ASan soak runs a FIXED 15-min soak (hard-coded below, NOT driven by+ # inputs.duration_minutes), but the ASan-instrumented build is slow and+ # leak reporting adds teardown time. 60 keeps the budget comfortably above+ # the 15-min run so it is never truncated. (Same class of bug as the+ # soak-quick 30→240 mismatch above — keep the timeout above the run length.)+ timeout-minutes: 60steps:- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3- name: Install deps (Linux)@@ -150,7 +163,10 @@ jobs:soak-asan-windows:if: ${{ inputs.run_asan }}runs-on: windows-latest- timeout-minutes: 45+ # FIXED 15-min soak (hard-coded below). MSYS2/Wine + ASan build is the+ # slowest path; 60 keeps the budget well above the run length so it is+ # never truncated.+ timeout-minutes: 60steps:- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2diff --git a/.github/workflows/soak.yml b/.github/workflows/soak.ymlnew file mode 100644index 000000000..883637b1c--- /dev/null+++ b/.github/workflows/soak.yml@@ -0,0 +1,85 @@+# Real multi-hour soak — #581 query-only memory-leak reproducer.+#+# WHY THIS EXISTS (separate from _soak.yml / nightly-soak.yml):+# The nightly path was structurally incapable of running a real long soak:+# 1. nightly-soak.yml passes duration_minutes: 240, but _soak.yml's+# soak-quick / soak-asan jobs hard-cap `timeout-minutes: 30` (45 for+# ASan). GitHub kills the job at 30 min → the "4h" soak NEVER ran past+# 30 min. (Fixed in _soak.yml too, but this workflow guarantees the+# right budget for the long #581 run.)+# 2. scripts/soak-test.sh's default mode reindexes every 2 min;+# index_repository triggers cbm_mem_collect (mimalloc page return),+# which sweeps the query-only leak — masking #581 even on a long run.+# This workflow drives CBM_SOAK_MODE=query-leak, which never reindexes+# and never mutates files, so the leak can accumulate and be detected+# by soak-test.sh's RSS slope / ratio / ceiling analysis.+#+# NON-GATING: workflow_dispatch + push to qa/soak-** only. Never a required+# check, never blocks a merge.+#+# CRITICAL: timeout-minutes = duration + 60. A 240-min soak gets ~300 min.+name: Soak (multi-hour #581)++on:+ workflow_dispatch:+ inputs:+ duration_minutes:+ description: 'Soak duration in minutes (default: 240 = 4h)'+ type: number+ default: 240+ mode:+ description: 'Soak mode (query-leak = #581 detector, no reindex/mutate)'+ type: choice+ options: ['default', 'query-leak']+ default: 'query-leak'+ # Iteration convenience: pushing a qa/soak-** branch starts a real run from+ # that branch's own copy of this file (no main merge needed). Non-gating.+ push:+ branches: ['qa/soak-**']++permissions:+ contents: read++jobs:+ soak:+ strategy:+ fail-fast: false+ matrix:+ # Limited to the two platforms where soak-test.sh's RSS reading works+ # well, to bound cost (no windows / no arm here).+ include:+ - os: ubuntu-latest+ cc: gcc+ cxx: g+++ - os: macos-14+ cc: cc+ cxx: c+++ runs-on: ${{ matrix.os }}+ # duration + 60 min headroom. On push (no inputs) duration defaults to 240,+ # so the budget is 300 min — NOT the 30 min that silently truncated nightly.+ timeout-minutes: ${{ fromJSON(inputs.duration_minutes || '240') + 60 }}+ steps:+ - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3++ - name: Install deps (Linux)+ if: startsWith(matrix.os, 'ubuntu')+ run: sudo apt-get update && sudo apt-get install -y zlib1g-dev python3 git++ - name: Build (prod binary)+ run: scripts/build.sh CC=${{ matrix.cc }} CXX=${{ matrix.cxx }}++ - name: Soak+ env:+ # On push events there are no inputs → fall back to shell defaults+ # (240 min / query-leak) so a qa/soak-** push runs the real #581 soak.+ CBM_SOAK_MODE: ${{ inputs.mode || 'query-leak' }}+ DURATION_MINUTES: ${{ inputs.duration_minutes || '240' }}+ run: scripts/soak-test.sh build/c/codebase-memory-mcp "${DURATION_MINUTES}"++ - name: Upload metrics+ if: always()+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ with:+ name: soak-${{ matrix.os }}-${{ inputs.mode || 'query-leak' }}+ path: soak-results/+ retention-days: 14diff --git a/scripts/soak-test.sh b/scripts/soak-test.shindex adf3446a8..9429a2397 100755--- a/scripts/soak-test.sh+++ b/scripts/soak-test.sh@@ -20,6 +20,20 @@ DURATION_MIN="${2:?Usage: soak-test.sh <binary> <duration_minutes>}"SKIP_CRASH="${3:-}"BINARY=$(cd "$(dirname "$BINARY")" && pwd)/$(basename "$BINARY")+# Soak mode selector.+# default = original mixed workload (queries + mutations + periodic reindex+# + crash-recovery). Unchanged from before this env var existed.+# query-leak = #581 detector. After the initial index, NEVER reindex and NEVER+# mutate files, so the mimalloc page-return path (cbm_mem_collect,+# triggered by index_repository) is never invoked and cannot sweep+# a query-only leak. Phase 3 then hammers a variety of READ tools+# (search_graph / query_graph / trace_path / get_code_snippet /+# search_code) to exercise the query-only store-open + WAL + alloc+# paths the bug report implicates. The RSS slope/ratio/ceiling+# analysis below is the leak detector. The crash-recovery phase is+# skipped in this mode because it reindexes (which would mask #581).+CBM_SOAK_MODE="${CBM_SOAK_MODE:-default}"+RESULTS_DIR="soak-results"mkdir -p "$RESULTS_DIR"@@ -33,7 +47,7 @@ echo "timestamp,tool,duration_ms,exit_code" > "$LATENCY_CSV"DURATION_S=$((DURATION_MIN * 60))-echo "=== soak-test: binary=$BINARY duration=${DURATION_MIN}m ==="+echo "=== soak-test: binary=$BINARY duration=${DURATION_MIN}m mode=${CBM_SOAK_MODE} ==="# ── Helper: generate realistic test project (~200 files) ─────────@@ -287,22 +301,36 @@ while [ "$(date +%s)" -lt "$END_TIME" ]; doNOW=$(date +%s)CYCLE=$((CYCLE + 1))- # Queries every 2 seconds- mcp_call search_graph "{\"project\":\"$PROJ_NAME\",\"name_pattern\":\".*compute.*\"}"- mcp_call trace_path "{\"project\":\"$PROJ_NAME\",\"function_name\":\"compute\",\"direction\":\"both\"}"-- # File mutation every 2 minutes- if [ $((NOW - LAST_MUTATE)) -ge 120 ]; then- echo "# mutation at cycle $CYCLE $(date)" >> "$SOAK_PROJECT/src/main.py"- git -C "$SOAK_PROJECT" add -A 2>/dev/null- git -C "$SOAK_PROJECT" -c user.email=test@test -c user.name=test commit -q -m "cycle $CYCLE" 2>/dev/null || true- LAST_MUTATE=$NOW- fi-- # Full reindex every 2 minutes (compressed — simulates 15min real interval)- if [ $((NOW - LAST_REINDEX)) -ge 120 ]; then- mcp_call index_repository "{\"repo_path\":\"$SOAK_PROJECT\"}"- LAST_REINDEX=$NOW+ if [ "$CBM_SOAK_MODE" = "query-leak" ]; then+ # ── #581 query-only leak mode ────────────────────────────────+ # Pure read-query hammering: no mutation, no reindex — so+ # cbm_mem_collect (mimalloc page return) is NEVER triggered and+ # cannot sweep a query-only leak. Hammer a VARIETY of read tools to+ # exercise the store-open + WAL + alloc paths the report implicates.+ mcp_call search_graph "{\"project\":\"$PROJ_NAME\",\"name_pattern\":\".*Handle.*\"}"+ mcp_call query_graph "{\"project\":\"$PROJ_NAME\",\"query\":\"MATCH (n) RETURN n.name LIMIT 25\"}"+ mcp_call trace_path "{\"project\":\"$PROJ_NAME\",\"function_name\":\"handle_1\",\"direction\":\"both\"}"+ mcp_call get_code_snippet "{\"project\":\"$PROJ_NAME\",\"qualified_name\":\"handle_1\"}"+ mcp_call search_code "{\"project\":\"$PROJ_NAME\",\"pattern\":\"def \"}"+ else+ # ── default mode (unchanged) ─────────────────────────────────+ # Queries every 2 seconds+ mcp_call search_graph "{\"project\":\"$PROJ_NAME\",\"name_pattern\":\".*compute.*\"}"+ mcp_call trace_path "{\"project\":\"$PROJ_NAME\",\"function_name\":\"compute\",\"direction\":\"both\"}"++ # File mutation every 2 minutes+ if [ $((NOW - LAST_MUTATE)) -ge 120 ]; then+ echo "# mutation at cycle $CYCLE $(date)" >> "$SOAK_PROJECT/src/main.py"+ git -C "$SOAK_PROJECT" add -A 2>/dev/null+ git -C "$SOAK_PROJECT" -c user.email=test@test -c user.name=test commit -q -m "cycle $CYCLE" 2>/dev/null || true+ LAST_MUTATE=$NOW+ fi++ # Full reindex every 2 minutes (compressed — simulates 15min real interval)+ if [ $((NOW - LAST_REINDEX)) -ge 120 ]; then+ mcp_call index_repository "{\"repo_path\":\"$SOAK_PROJECT\"}"+ LAST_REINDEX=$NOW+ fifi# Collect diagnostics every 10 seconds (5 cycles)@@ -324,8 +352,11 @@ IDLE_CPU=$(ps -o %cpu= -p "$SERVER_PID" 2>/dev/null | tr -d ' ' || echo "0")echo "OK: idle CPU=${IDLE_CPU}%"# ── Phase 5: Crash recovery test ────────────────────────────────+# Skipped in query-leak mode: crash recovery re-indexes (Phase 5 calls+# index_repository), which triggers cbm_mem_collect and would mask the #581+# query-only leak the whole run is trying to surface.-if [ "$SKIP_CRASH" != "--skip-crash-test" ]; then+if [ "$SKIP_CRASH" != "--skip-crash-test" ] && [ "$CBM_SOAK_MODE" != "query-leak" ]; thenecho "--- Phase 5: crash recovery ---"# Kill server mid-operation, restart, verify clean index