Skip to content

Remove the decoded-avatar hot set; respect Save-Data - #60

Merged
comp615 merged 1 commit into
block:mainfrom
comp615:remove-decoded-hotset
Sep 14, 2026
Merged

comp615 merged 1 commit into
block:mainfrom
comp615:remove-decoded-hotset

Conversation

@comp615

@comp615 comp615 commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

What

Removes the 16 MiB decoded-avatar hot set (the detached-HTMLImageElement LRU in createMediaPreparation). Media preparation is now pure request warming, the react-native-web Image model: fetch, decode(), release — retention is delegated to the browser's own HTTP and decoded-image caches.

Evidence that drove this: an A/B harness (mode toggle in the Developer tab on a stacked branch) measured against the live community relay showed warm and cold avatar decodes are identical at 1–2 ms p50 for thumbnail-sized media, and detached-image decode probes stayed under 2 ms even a minute after every JS reference dropped. The LRU cost up to 16 MiB of RAM and bought nothing measurable.

Also: when the browser reports navigator.connection.saveData, all speculative warming is disabled — avatar preparation and the hover-driven speculative head read both early-return. Demand fetches are untouched.

Validation

  • src/features/relay/media.test.ts: request warming without retention (decode called, nothing stored); in-flight dedupe; oversized-original decode skip with unchanged timer cleanup; Save-Data on → zero requests, off/absent → normal.
  • Full relay suite: 512 passed; pnpm typecheck and biome clean.
  • Live-network verification on the real community relay (stacked build): cold load warms 26 avatar thumbs in the background with no channel opened; opening warmed channels served 7 of 8 avatar loads from cache; decode telemetry stayed 1–2 ms warm/cold without the LRU.

Notes for review

  • No renderer consumes the LRU — renderers use plain <img> with the same URLs, so display behavior is unchanged by construction; only RAM changes.
  • docs/channels.md's "bounded avatar preparation cache" line is updated to describe request warming.
  • The background channel warming itself is Warm channel heads in the background before they are opened #54; this PR is independent of it and applies to main directly.

🤖 Description written by AI (Amp); commits signed off by the agent on Charlie Croom's behalf per DCO.

A/B measurement against the live community showed warm and cold avatar
decodes are identical at 1-2ms for thumbnail-sized media, so the 16 MiB
decoded-element LRU bought nothing. Media preparation is now request
warming only, the react-native-web Image model: fetch, decode(),
release. Speculative warming is skipped under the Save-Data preference.

Signed-off-by: Charlie Croom <ccroom@squareup.com>
Co-authored-by: Amp <amp@ampcode.com>
Signed-off-by: Charlie Croom <ccroom@squareup.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a0a053-f85b-754c-a353-03fb77a26363
@comp615
comp615 requested a review from wesbillman as a code owner September 14, 2026 18:08

@baxen baxen 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.

makes sense

@comp615
comp615 merged commit 0dabd8e into block:main Sep 14, 2026
12 checks passed
@comp615
comp615 deleted the remove-decoded-hotset branch September 14, 2026 19:20
delkc added a commit that referenced this pull request Sep 15, 2026
* origin/main:
  Fix inline mention styling in channels (#74)
  Fix self-replenishing background channel warming (#71)
  Add links and thread previews (#42)
  Add shared receive-only channel and thread typing (#33)
  Warm channel heads in the background before they are opened (#54)
  Add Developer settings tab with cache clear and broker stats (#53)
  Request sized relay media for avatars (#58)
  Allow parallel browser development ports (#57)
  Add worktree bootstrap for local configuration (#56)
  Make thread opens part of navigation history (#55)
  Remove the decoded-avatar hot set; respect Save-Data (#60)
  Add CODEOWNERS reviewers (#61)
  Add guarded Workflows page and session capability (#48)

Signed-off-by: Clay Delk <clay.delk@gmail.com>

# Conflicts:
#	dev/relay-broker.mjs
#	src/bundled/channels/ChannelsPage.tsx
#	src/features/messages/ChannelTimeline.tsx
#	src/features/messages/MessageComposer.tsx
#	src/features/messages/MessageRow.tsx
#	src/features/messages/ThreadPanel.test.tsx
#	src/features/messages/ThreadPanel.tsx
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