Skip to content

perf(mobile): avoid redundant message list sorting - #7647

Merged
brow merged 2 commits into
mainfrom
mobile-live-window-sort
Sep 15, 2026
Merged

brow merged 2 commits into
mainfrom
mobile-live-window-sort

Conversation

@brow

@brow brow commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

When new messages arrive in a mobile channel, the app updates the list of loaded messages on the UI thread. It currently sorts that list twice. The second sort is needed only when the app has retained messages opened through a link to a specific message.

This change uses the first sorted list when there are no retained messages to merge. It reduces work during message bursts and keeps the existing merge and ordering behavior for message links.

A controlled debug test with 2,000 loaded messages and 1,000 incoming messages reduced processing time from 446 ms to 266 ms. This measures the message update code, not screen rendering or release-device performance. All 26 focused tests pass, including a regression test that fails if the extra pass returns. Tests also cover message order and retained messages.

Repository checks and downstream test/build suites passed, apart from unrelated Rust timing failures in the full local run; each passed an isolated retry. GitHub CI passed after retrying an unrelated desktop attachment test failure.

Signed-off-by: Tom Brow <tomb@block.xyz>
@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is a9dd4d3bd771b47f0efb4e7f6f7329a5921372b5...77e6594d7ac77e4ce012bc2e4d810f852efd0d0f.
A new review must complete for this exact range. When manual authorization
is required, a Block organization member must comment exactly
@buzz-security-review 77e6594d7ac77e4ce012bc2e4d810f852efd0d0f to authorize a new review.
Any previous review applies only to its recorded range.

@brow

brow commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@brow

brow commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

@builderbot review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 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-09-15T18:13:10.184798Z 77e6594 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.

@brow

brow commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

@buzz-security-review 8f6e19f

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f6e19f59f

ℹ️ 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".

Comment thread mobile/lib/features/channels/channel_messages_provider.dart
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Sep 14, 2026
Signed-off-by: Tom Brow <tomb@block.xyz>
@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Sep 14, 2026
@brow

brow commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

@buzz-security-review 77e6594

@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Sep 14, 2026
@brow brow changed the title Reduce mobile live message burst sorting perf(mobile): avoid redundant message list sorting Sep 15, 2026
@brow
brow marked this pull request as ready for review September 15, 2026 18:09
@brow
brow requested a review from a team as a code owner September 15, 2026 18:09
@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Sep 15, 2026

@jedwards27 jedwards27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: APPROVE

Reviewed: 4cd82f513214aad11c2b742ce7cc7c681e8e32a0..77e6594d7ac77e4ce012bc2e4d810f852efd0d0f (exact head 77e6594d7ac77e4ce012bc2e4d810f852efd0d0f)

Risk: medium — this changes the mobile live-message timeline construction path, where ordering, retained deep-link rows, and UI-thread burst cost matter; it does not alter relay, persistence, identity, permissions, widgets, scrolling, or accessibility contracts.

Behavior/contracts traced: relay buffer delivery → channel live callback → window-store merge/dedup → authoritative chronological flatten → optional retained deep-link merge. flattenChannelWindowEvents already deduplicates and sorts with the same comparator used by _withDeepLinkEvents; the fast path is selected only when the retained map is empty, while retained targets preserve the previous merge/dedup/sort path. Buffered callbacks remain synchronous and ordered, and equal-second ordering remains deterministic by descending event ID.

Findings: no blocking or non-blocking code defects found.

Author action: none.

Verification owner: reviewer/tooling for optional native iOS release-device frame/scroll and VoiceOver observation; no author rework is required.

Validation at matching clean HEAD:

  • Full touched-package test gate: just mobile-test — PASS, 2,124 passed / 1 skipped.
  • Focused provider suite — PASS, 26/26.
  • flutter analyze — PASS; changed Dart formatting and git diff --check — PASS.
  • Causal mutation: restoring the redundant _withDeepLinkEvents(...) call makes the new production-seam regression test fail (historyIdReads: 3, allowed <=2); restoring the candidate passes.
  • CI at the exact head: all selected required checks are successful, including Mobile, Desktop, relay-backed Desktop integration, macOS/Windows builds, Semgrep, zizmor, DCO, and the authorized security review.
  • Same-host synthetic diagnostics through the real relay buffer/notifier seam independently reproduced a substantial reduction for 2,000 history / 1,000 live events. Observed magnitude varied by run/harness (~40% to ~80%), which reinforces the README's explicit debug/JIT limitation rather than a release-device latency claim.

Manual/native evidence: no native release-device run. No widget, focus, scroll-controller, input, or semantics code changed; the full package/widget suite passed.

Residual risk: the opt-in diagnostic is synthetic debug/JIT work and excludes rendering, networking, signature verification, and other subscriptions. It proves reduced synchronous consumer work and final-count correctness, not smooth frames or production-device latency under extreme bursts. The implementation and PR description scope that claim honestly.

— :bot: Jude’s code review agent

@brow
brow merged commit 5b9dbcb into main Sep 15, 2026
119 of 122 checks passed
@brow
brow deleted the mobile-live-window-sort branch September 15, 2026 18:29
brow added a commit that referenced this pull request Sep 15, 2026
…ush-cache-offload

* commit '41c5ace93740261ee5a5d962c2a17e8d846c2c1b':
  perf(mobile): move profile sig checks off main thread (#7648)
  perf(mobile): avoid redundant message list sorting (#7647)
  perf(mobile): avoid reparsing unchanged Markdown (#7649)
  Fix desktop onboarding regressions (#7659)
  Deduplicate thread context by ACP session delivery (#7620)
  feat(mobile): hard-block under-18 users on the store age signal (#4665)
  Document incoming Buzz turn structure (#7624)
  Refresh desktop onboarding flow (#7528)
  Fix Apple Silicon iOS simulator builds (#7646)

Signed-off-by: Tom Brow <tomb@block.xyz>
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.

2 participants