Skip to content

perf(id/web): avoid reserializing all records on every host-view page #9104

Closed

Description

@dezren39

Evidence

On fresh origin/main (8b4cc5f5aa8e90f0bfc3f9267945c1226e29ab06), pkgs/id/src/web/world_ws.rs:106-114 computes records_revision by serializing the complete Records map into a new Vec<u8> and hashing it. host_view_handler calls world.records() and recomputes this revision on every request, before filtering records by the after cursor (world_ws.rs:153-167). The host-view client fetches these pages sequentially.

The data is bounded, but not to a page: pkgs/id/crates/id-worlds/src/world/mod.rs:2150-2190 permits 4,096 records with values up to 8 KiB each, while pkgs/id/crates/id-caps/src/world_caps.rs:740-744 caps each served page at 768 KiB. A valid near-limit records set can therefore be roughly 33 MiB. Paging such a set can serialize and hash that entire map dozens of times, allocating a full-size temporary buffer each time; per-page slicing also serializes values again. This makes a legitimate large host view disproportionately expensive in CPU and transient memory.

The existing page-count/advance fix tracked by #9043 and PR #9051 addresses a client loop, not the repeated full-map work in the server handler.

Why it matters

A world owner opening a large host view can trigger repeated full-map serialization for each bounded page. This can make the admin view slow and create avoidable memory pressure in the serving process, even though each response is capped.

Acceptance criteria

  • Preserve cross-page snapshot/revision consistency without serializing and allocating the entire records map anew for every page.
  • Keep the 768 KiB page limit and existing behavior when records change during paging.
  • Add a regression test for a multi-page records set that pins bounded revision work (use a structural/counting oracle rather than a timing threshold) and verifies page consistency/change detection.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Nov 13, 2026
  2. developing-today commented on Nov 13, 2026

    @developing-today
    Contributor
  3. added
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    and removed
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 13, 2026
  4. dezren39 commented on Nov 13, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · triaged

    • Agent: triage-step
    • State: triaged
    • Work kind: task/small-fix — a bounded code fix in the id web host view: host_view_handler in pkgs/id/src/web/world_ws.rs reserializes and hashes the entire Records map on every page request to compute records_revision, so paging a near-limit records set repeats full-map CPU and allocation work dozens of times.
    • Priority: priority/normal (already on the issue; kept) — Priorities brief line 5: everything else by usefulness, not by age alone. A real performance bug (a large legitimate host view is disproportionately expensive in CPU and transient memory), but not fleet-stalling breakage under brief line 1, not in the ID design-track expedite set (line 2), and not already-open landing work (line 3).
    • Effort: effort/s (already on the issue; kept) — replace one per-request revision computation with a cached/incremental revision and add the regression test; expected under 2 hours.
    • Kind: kind/bug (already on the issue; kept).
    • First concrete step: In pkgs/id/src/web/world_ws.rs, replace the per-request full-map serialize+hash for records_revision (lines 106-114, recomputed at 153-167) with a revision computed once per records change (cached/incremental revision maintained where Records mutates), preserving cross-page snapshot/revision consistency and change detection during paging. Note fix(id-web): host-view record paging has no page bound or advance check — a repeating next_after loops the browser forever #9043 / PR fix(id-web): bound host-view record paging with an advance check #9051 fix a distinct client page-count loop, not this server work.
    • Acceptance check: No per-page serialization/allocation of the entire records map; the 768 KiB page limit and existing behavior when records change during paging are preserved; a regression test for a multi-page records set pins bounded revision work with a structural/counting oracle (not a timing threshold) and verifies page consistency/change detection.
    • Fix packet: task 15343 in repo-health-code-pilot (dedupe repo-health:v1:fix:developing-today/code:issue:9104, priority 40, kind small_fix; validated and enqueued by triage-step, read back queued by dedupe key; queue signal refreshed). No live queue task for this issue existed under any segment when checked on the laptop before enqueue; the issue's sole prior comment was the creator's Kaneo filing link.
  5. dezren39 commented on Nov 13, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: picked-up
    task: 15343
    issue: #9104
    pr: null

    Lane code-c picked up task 15343 in this shift. Fresh revalidation: issue #9104 OPEN, no hard-stop labels, no competing PR. Plan: in pkgs/id/src/web/world_ws.rs, replace the per-request full-map serialize+hash records_revision with a revision computed once per records change (cached/incremental, maintained where Records mutates), preserving cross-page snapshot/revision consistency, the 768 KiB page limit, and change-during-paging behavior; add a regression test with a structural/counting oracle pinning bounded revision work over a multi-page records set.

  6. 4 remaining items

  7. added
    status/parkedDeliberately paused with a recorded resume condition
    queue/claimedQueue worker lifecycle state
    and removed
    queue/claimedQueue worker lifecycle state
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 13, 2026
  8. dezren39 commented on Nov 13, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up / verified — merging PR #9152

  9. added a commit that references this issue on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions