Skip to content

perf (speculative): six micro-candidates — evaluate each before any work #28

Description

@JavaGT

Filed by the Account-2 read-only amplifier (2026-09-16, HEAD f635e62). Six low-stakes candidates from the hot-path/simplification sweep. Each is evaluate whether it is worth doing — implementation is explicitly NOT the todo. All evidence coordinator-verified (read + rg).

  1. CookieJar's keep-alive agent is never destroyed — created per fetchOpenbook (src/openbook.mjs:299; agent at :341); rg finds no .destroy. One idle socket accumulates per loan in archive --all; impact bounded by the explicit process.exit at end of run. Evaluate: destroy in a finally, or accept and close.
  2. Legacy eager {body} spine shape is production-dead — archive-read.mjs:121-126 emits only {data} thunks; only tests construct {body} (test/ram-thunk.test.mjs:83-93); epub.mjs:251-252 keeps the branch alive for them. Evaluate: migrate the tests and retire the branch.
  3. collect()'s textDone sentinel looks redundantbuffer.toString('utf8') never returns undefined; only the JSON variant needs the guard (src/http.mjs:56-77). The contract is test-pinned (test/http.test.mjs:18), so change only with tests in hand. Evaluate.
  4. Cover download is chained behind thunderP although loan.coverUrl is synchronously available (src/archive.mjs:57, src/archive-read.mjs:74) — the perf: start thunder/cover at archive entry — catalog RTTs are serialized after the open chain though they depend on nothing from it #18 entry-time window must then cover thunder+cover serially. Decoupling risks re-fetching a "better" cover late (behavior change). Evaluate against perf: start thunder/cover at archive entry — catalog RTTs are serialized after the open chain though they depend on nothing from it #18's intent.
  5. TOC→part mapping does Array.indexOf per TOC entry — O(toc×parts) where a Map is the standard primitive (src/archive.mjs:122-125); trivial at current sizes (buildNav already uses a Set). Evaluate/decline.
  6. Entry extension split+lowercase runs twice per asset — encodeEntry (src/epub.mjs:42) and mimeOf (:226). Nano alloc noise. Evaluate/decline.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions