Skip to content

perf(mobile): evict verified-profile interest in one pass - #9007

Merged
brow merged 1 commit into
mainfrom
tomb/verified-interest-one-pass-evict
Nov 3, 2026
Merged

brow merged 1 commit into
mainfrom
tomb/verified-interest-one-pass-evict

Conversation

@brow

@brow brow commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #8931, from Wes's review note.

#8931 replaced the per-eviction scan in VerifiedProfilesNotifier.track with keys.first. That was much cheaper than main, but not constant time: removing from a Dart map leaves deleted slots, and each new keys iterator walks past them. One track call that overflows the 1,024-subject cap by E subjects still costs about E²/2 slot checks. Wes measured ~3 ms at 4,300 subjects, 62 ms at 8,600 and 205 ms at 17,200.

Eviction now takes the overflow from a single iteration (keys.take(overflow).toList()), so it's linear. Which subjects are kept doesn't change: still the 1,024 most recently inserted.

The #8931 eviction test counted keys yielded by the map, which keys.first keeps at one per eviction, so it couldn't fail on the quadratic path. It now counts iterations started over the interest map and expects exactly one per track call. Main's scan and the merged keys.first loop both start one per eviction.

Testing

  • Falsification: with the merged keys.first loop restored, the new test fails (Expected: <1>, Actual: <3276>). With this change it passes.

  • flutter test test/shared/verified_profiles/: 31 passed. The existing "keeps the 1,024 most recently tracked subjects" journey still passes, so retention is unchanged.

  • just mobile-check: clean.

  • just mobile-test: 4,227 Flutter tests passed, 40 skipped, plus 4 push and 27 crypto tests.

  • Automated app run: installed this build on an iOS 27 simulator (iPhone 17 Pro) signed in to a Builderlab community, opened the inbox, a channel timeline with images and the image viewer, and the channel details member list, which all track verified-profile subjects. No errors. That community is small (30 members), so the overflow path itself is covered by the unit tests, not the app run.

  • Agent review: an independent agent review found no blockers.

  • Human test: waived under the mobile testing exception; the automated app run above replaces it.

Not covered: Android, and no new device profile (Wes's AOT numbers above are the cost model; this removes the E² term).

buzz-review-completed

🤖 Generated with Claude Code

#8931 replaced the per-eviction scan with `keys.first`, but each new
iterator over a Dart map skips the slots earlier removals left behind,
so one track call that overflows by E subjects still costs about E^2/2
slot checks. Eviction now takes the overflow from one iteration.

The eviction test counted yielded keys, which `keys.first` keeps at one
per eviction, so it could not see the quadratic cost. It now counts
iterations started over the interest map and expects exactly one; the
merged loop starts 3,276.

Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Tom Brow <[email protected]>
@brow
brow marked this pull request as ready for review November 3, 2026 17:35
@brow
brow requested a review from a team as a code owner November 3, 2026 17:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 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-03T17:38:13.250971Z 210c28d Draft marked ready
ℹ️ 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.

@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

🔐 Codex Security Review

Note: This is an automated, security-focused review generated by Codex.
Use it as a supplement to human review; false positives are possible.

Scope

  • Exact PR diff: 0e5a69962e5cbe5e81ea46b557770ce27a120a14...210c28dc065252e49cc2c7e8400eebd6c50d2d6b
  • Model: gpt-6.1-sol

💡 Click "edited" above to see earlier reviews for this PR.


Review Summary

Overall Risk: NONE

No concrete security, correctness, or reliability findings in the authorized PR range. The eviction change preserves ordering, cache cleanup, and the 1,024-subject limit.

Findings

No concrete security, correctness, or reliability findings were identified.

Notes

  • Review used read-only source and history inspection. Builds and tests were not executed, as instructed.

Generated by Codex Security Review |
Requested by: @brow |
Workflow run

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 Carl, an automated reviewer, commenting via Wes's GitHub account.

No blockers. I'm leaving this as a comment, not an approval.

  • Eviction matches the old loop. _wanted.keys.take(overflow).toList() snapshots the oldest overflow keys in insertion order before anything is removed, so there's no concurrent modification, and it evicts the same subjects the keys.first loop did. added = true still fires only when something was evicted.
  • The test now measures the right thing. _CountingMap overrides length, isEmpty, containsKey, [], []= and remove, so only keys (and entries/values via MapBase) count as an iteration. The sync* getter counts when iteration starts, so keys.first per eviction counts 3,276, which is the "Actual: <3276>" in the falsification note. The pass is exactly 1.
  • CI on 210c28d: 22 passed, 31 skipped, none failing.

@brow
brow merged commit 40fe4b5 into main Nov 3, 2026
60 checks passed
@brow
brow deleted the tomb/verified-interest-one-pass-evict branch November 3, 2026 18:32

This branch was previously deployed

1 inactive deployment
codex-review — 210c28dc Deployed Nov 3, 2026 by brow via Run Codex Security Review #12170
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex-security-review-current The posted Codex security review matches its recorded range.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants