Skip to content

Extend MCP idle timeout to one hour#328

Merged
justrach merged 1 commit intorelease/0.2.579from
fix/mcp-hour-timeout
Apr 26, 2026
Merged

Extend MCP idle timeout to one hour#328
justrach merged 1 commit intorelease/0.2.579from
fix/mcp-hour-timeout

Conversation

@justrach
Copy link
Copy Markdown
Owner

Summary

  • extend the MCP idle timeout from 10 minutes to 1 hour
  • keep dead-client cleanup separate from idle timeout with a 1-second stdin HUP poll
  • update tests and README copy for the new timeout behavior

Verification

  • zig build test
  • zig build
  • installed binary smoke: closing MCP stdin exited cleanly in ~285ms

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

codedb/src/main.zig

Lines 967 to 968 in 9a70fb4

const last = mcp.last_activity.load(.acquire);
if (last == 0) continue;

P2 Badge Avoid tight loop when activity timestamp is unset

The watchdog now sleeps only at the end of the loop, but if (last == 0) continue; bypasses that sleep. This introduces a hot spin path that repeatedly polls and reloads atomics with no delay until last_activity is initialized, which can peg a core if MCP startup is delayed or refactored to initialize activity later. Add a sleep in this branch (or initialize last_activity before starting the watchdog) to keep the 1-second polling behavior.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions
Copy link
Copy Markdown

Benchmark Regression Report

Thresholds: 10.00% and 50,000 ns absolute delta

NOISE means the percentage threshold was exceeded, but the absolute delta was too small to fail CI.

Tool Base (ns) Head (ns) Delta Abs Delta (ns) Status
codedb_bundle 481005 487143 +1.28% +6138 OK
codedb_changes 54861 53992 -1.58% -869 OK
codedb_deps 8958 9104 +1.63% +146 OK
codedb_edit 6124 6109 -0.24% -15 OK
codedb_find 61830 63170 +2.17% +1340 OK
codedb_hot 98770 97587 -1.20% -1183 OK
codedb_outline 231731 238884 +3.09% +7153 OK
codedb_read 83841 83474 -0.44% -367 OK
codedb_search 174453 177438 +1.71% +2985 OK
codedb_snapshot 251022 243525 -2.99% -7497 OK
codedb_status 216322 218376 +0.95% +2054 OK
codedb_symbol 59188 57909 -2.16% -1279 OK
codedb_tree 87990 91863 +4.40% +3873 OK
codedb_word 67519 66759 -1.13% -760 OK

@justrach justrach merged commit 4e38a29 into release/0.2.579 Apr 26, 2026
1 check passed
@justrach justrach deleted the fix/mcp-hour-timeout branch April 26, 2026 04:53
@justrach
Copy link
Copy Markdown
Owner Author

Speed comparison for timeout change

Compared current #328 build (67746b5d..., 1h idle timeout) against the immediately previous installed 0.2.579 build (f0a40ecd..., 10m idle timeout).

GitHub bench-regression

Official PR bench artifact passed with all rows OK; no benchmark regression from the timeout/watchdog change.

Tool Base Head Delta Status
codedb_bundle 481005 ns 487143 ns +1.28% OK
codedb_outline 231731 ns 238884 ns +3.09% OK
codedb_search 174453 ns 177438 ns +1.71% OK
codedb_snapshot 251022 ns 243525 ns -2.99% OK
codedb_status 216322 ns 218376 ns +0.95% OK
codedb_symbol 59188 ns 57909 ns -2.16% OK
codedb_tree 87990 ns 91863 ns +4.40% OK

Full artifact had every benchmark row within the 10% / 50,000ns gate.

Local MCP lifecycle smoke

20 local runs per binary, using the installed binaries directly:

Measurement Current avg / median / p95 Previous avg / median / p95
initialize response 40.2 / 40.6 / 46.9 ms 41.2 / 41.5 / 42.4 ms
tools/list 0.2 / 0.1 / 0.3 ms 0.1 / 0.1 / 0.2 ms
codedb_status 0.1 / 0.1 / 0.4 ms 0.1 / 0.1 / 0.1 ms
normal stdin-close shutdown 1195.5 / 1190.2 / 1278.0 ms 1189.6 / 1188.7 / 1346.9 ms

The lifecycle numbers are effectively unchanged for normal MCP EOF shutdown. The behavioral change in #328 is the policy: idle timeout is now 1 hour, while the dead-client watchdog poll remains independent and is bounded to 1 second.

Remote wiki calls

Both current and previous builds successfully handled backend=wiki calls for chromium policy and axios/axios CVEs. Timings were network-bound and noisy, so I’m treating them as smoke checks rather than regression data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant