Skip to content

F4: profile fragment-write hot path before optimizing #304

@crippledgeek

Description

@crippledgeek

From the 2026-05-04 download-optimization audit (F4 in docs/superpowers/specs/2026-05-04-download-optimization-audit.md).

The audit speculated 5–15% wall-clock improvement from streaming fragment writes (bytes_stream() end-to-end) instead of resp.bytes().await into a Vec<u8> per fragment. Round-2 research (docs/superpowers/specs/2026-05-21-f3-f6-download-optimization-design.md) showed the claim was speculative: glibc malloc at ~18ns/alloc means 600 fragment allocations cost ~10µs total — not in the top 10 hot frames for a network-bound HLS download. bytes_stream() would ADD per-chunk Arc-decrement traffic (320 Bytes drops per 5 MiB H2 segment vs 1).

Action

Profile first. If cargo flamegraph on a real 4K HLS download (~600 fragments) shows allocator/syscall in the top 10 hot frames, revisit. Otherwise close as no-op.

References

  • Spec non-goal: docs/superpowers/specs/2026-05-21-f3-f6-download-optimization-design.md (F4 dropped after research)
  • Audit: docs/superpowers/specs/2026-05-04-download-optimization-audit.md (F4 section)

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