Skip to content

id(search): memoize subject_kind resolution in search_terms (#3013) - #3688

Merged
dezren39 merged 1 commit into
mainfrom
queue/5518-3013-memoize-subject-kind
Nov 2, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/5518-3013-memoize-subject-kind

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #3013 (queue task 5518).

search_terms documents subject_kind as 'called at most once per subject', but its per-term loop re-filtered all subjects through the lookup for every SubjectKind term — N subjects × K kind terms calls, each a store read on the search_store_terms path.

Change (pkgs/id/src/search.rs): resolve each subject's kind once into a memo inside search_terms (the unresolvable None is memoised too) and let every kind term read the memo. AND results are identical; only the lookup count changes.

Test (pkgs/id/tests/search.rs): new counting-lookup test — 3 subjects × 3 kind terms (one duplicated) perform exactly 3 lookups (was 9), and a single kind term returns the same subjects as before. Existing kind tests cover the unchanged semantics.

Verification: targeted cargo test --test search test_search_ running on the laptop at push time (fleet load is high today); CI on this PR is the check of record per fleet policy.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

search_terms documented subject_kind as called at most once per subject,
but its per-term loop re-filtered every subject through the lookup for
each SubjectKind term (N subjects x K kind terms calls). Resolve each
subject kind once into a memo (including the unresolvable None) and let
every kind term read it; AND results are unchanged.

Adds a counting-lookup test: 3 subjects x 3 kind terms (one duplicated)
resolve exactly 3 lookups, and a single kind term still returns the same
subjects.
@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 12:54
@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 38 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bde443c2-ddee-4485-bfec-f3b3d2abf667
Commits

Reviewing files that changed from the base of the PR and between 9be9c22 and c3dc2f1.

Files selected for processing: 2
  • pkgs/id/src/search.rs
  • pkgs/id/tests/search.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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
📝 Code Review ✅ Completed 2026-11-01T12:56:51.706164Z c3dc2f1 PR opened
ℹ️ 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.

@dezren39

dezren39 commented Nov 7, 2026

Copy link
Copy Markdown
Member Author

🤖 Salvage note (duplicate-PR protocol, from the #6608 pr-shepherd pass, Lane W fallback mode)

This PR is the canonical landing of queue task 5518 for issue #3013. The duplicate, PR #3678 (same task, same base blob 7bec033cb), was diffed against this PR in full before being closed as superseded — not on a file-list comparison:

Conclusion: nothing unique to salvage from PR #3678; it is being closed as superseded by this PR.

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

Labels

None yet

Projects

None yet

1 participant