Skip to content

perf(core): recheck the shared trust file once per interval, not per read - #436

Merged
Mearman merged 1 commit into
mainfrom
perf/gateway-trust-stat
Oct 21, 2026
Merged

Mearman merged 1 commit into
mainfrom
perf/gateway-trust-stat

Conversation

@Mearman

@Mearman Mearman commented Oct 21, 2026

Copy link
Copy Markdown
Member

Every directory entry a node merges asks the trust boundary several questions (isTrusted, isTrustedPrincipal, isVouchedBy, hasAny), and each one stated the shared trust file to see whether another process had replaced it. A profile of a busy hub process showed that at several thousand stats a second (#434).

Reads now rest on the last look at the file for TRUST_FILE_RECHECK_INTERVAL_MS, paced by an injected clock. That interval is the longest another process's revocation can go unseen by a read; I chose one second because a hub-only device already stays in the directory until the next presence re-advertisement, so the bound adds no delay to that path. Writes still re-read first, since each rewrites the whole file and would otherwise erase another process's change. The four existing tests that relied on instant cross-instance visibility now advance a manual clock past the interval.

GatewayTrust now takes { location, clock } as one options object, which the lint rule on trailing optional parameters asked for; the only production caller is MeshStore.

The new tests count looks at the file through an injected clock, not time: reads inside an interval cost none, one look per interval after it, a revocation seen once the interval passes and not before. With the throttle removed three of the four fail.

Refs #434

…read

Every directory entry a node merges asks the trust boundary several
questions, and each question stat()ed the shared trust file to see
whether another process had replaced it. On a node serving a large
local mesh that was thousands of stats a second.

Reads now rest on the last look for TRUST_FILE_RECHECK_INTERVAL_MS,
paced by an injected clock, which bounds how long another process's
revocation can go unseen by a read. Writes still re-read first, since
each rewrites the whole file and must not erase another process's change.

GatewayTrust takes its location and clock as one options object.
@Mearman
Mearman marked this pull request as ready for review October 21, 2026 06:53
@Mearman

Mearman commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ⚠️ Failed 2026-10-21T06:54:01.256721Z
We couldn’t complete this review. Comment @codex security review to try again.
c195840 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins.

@Mearman
Mearman merged commit 0d21103 into main Oct 21, 2026
7 checks passed
@Mearman
Mearman deleted the perf/gateway-trust-stat branch October 21, 2026 06:54
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 8.15.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant