# Tune HPT USB CSV buffer window Workpackage

Status: complete
Type: workpackage
Updated: 2026-07-26
Next Action: none; operator review proceeds on the live Graph screens

Project Map: work/maps/map-smi-firmware-stabilization-and-qualification.md
Parent: work/wp/active/wp-triple-mirrored-circular-hpt-log-store.md
Depends On: work/wp/completed/wp-optimize-hpt-usb-csv-publication-throughput.md
Canonical Truth: docs/sd-card-operation-and-recovery.md

## Current Context

The accepted 8 KiB writer reduced normalized USB publication time by `34.15x`
on A and `13.71x` on B, but still issued 12 and 11 FileX writes for only
approximately 90 KiB. Phase telemetry attributes `0.36 / 1.05 s` to those
writes. The 32 KiB candidate's exact map reserves all configured heap and
stacks and leaves `18.6 KiB` of linker-address headroom.

## Recommendation

Measure a bounded aligned 32 KiB buffer, equivalent to 64 sectors and a common
FAT32 allocation cluster. This is the largest conservative window for this
pass: it should reduce write calls by roughly four without creating a large
unbounded transfer or materially reducing RAM margin.

Do not add preallocation, remove durable flushes, weaken temporary-file
publication, change CSV content, format B, or normalize its abnormal lanes.
Keep the accepted 8 KiB image as the rollback candidate.

## Goal

Select the faster safe buffer window using real B-first/A-second exports and
leave the exact winning image running with both Graph screens restored.

## Completion Criteria

- [x] 32 KiB image passes all source/model/build gates.
- [x] B passes first with unchanged CID, lane starts, and retirements.
- [x] A passes after B.
- [x] Both exports retain zero gaps/errors/fallbacks/drops.
- [x] Write count, phase timing, total timing, and projections are compared
  against the accepted 8 KiB baseline.
- [x] The winning image is installed on both controls and both Graph screens
  are returned for operator review.

## Closeout Routing

- Current truth: docs/sd-card-operation-and-recovery.md
- Evidence: work/evidence/hpt-usb-csv-buffer-window-tuning-20260726.md
- Rollback evidence:
  work/evidence/hpt-usb-csv-buffered-publication-20260726.md
