Skip to content

fix(service): record single-chunk egress only when response body is polled - #241

Merged
shikhar merged 1 commit into
mainfrom
fix/single-chunk-egress-accounting
Dec 5, 2026
Merged

shikhar merged 1 commit into
mainfrom
fix/single-chunk-egress-accounting

Conversation

@shikhar

@shikhar shikhar commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add SingleChunkBody implementing http_body::Body (Data = Bytes, Error = Infallible) in src/service/routes.rs so single-chunk responses record egress bytes in poll_frame() rather than eagerly in the /fetch handler before Hyper polls the body.
  • Implement is_end_stream() and exact size_hint() on SingleChunkBody (matching http_body_util::Full<Bytes>) to preserve PR perf(server): tune HTTP/2 settings, single-chunk response framing, and disk decode #231's HTTP/2 END_STREAM-on-DATA framing with the same single UnsyncBoxBody allocation as axum::body::Body::from(Bytes).
  • Use SingleChunkBody in both the FetchPlan::Single and FetchPlan::Multi early-EOF fast paths, restoring the PR fix(service): count egress only for body bytes sent #188 invariant that dropped/unpolled response bodies do not count toward egress throughput.

Verification

  • cargo +nightly fmt
  • cargo clippy --locked --all-features --all-targets -- -D warnings --allow deprecated
  • cargo deny check
  • cargo nextest run --locked (router-level test covering HEAD, dropped GET, and read GET across both single-chunk and early-EOF fast paths, plus existing HTTP/2 END_STREAM framing tests)

Closes #239

@greptile-apps

greptile-apps Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Single-chunk responses now count outgoing bytes when the body is polled, rather than when the handler returns.

  • Single-chunk fetches count egress when their response body is polled.

Reviews (1) · Last reviewed commit: "fix(service): record single-chunk egress..." · Reviewed by Greptile

@shikhar
shikhar force-pushed the fix/single-chunk-egress-accounting branch from 04fcaa0 to 7b7d706 Compare December 5, 2026 17:42
@shikhar
shikhar force-pushed the fix/single-chunk-egress-accounting branch from 7b7d706 to 6877543 Compare December 5, 2026 19:42
@shikhar
shikhar merged commit 94825fa into main Dec 5, 2026
7 checks passed
@shikhar
shikhar deleted the fix/single-chunk-egress-accounting branch December 5, 2026 19:49
@github-actions github-actions Bot mentioned this pull request Dec 5, 2026
shikhar pushed a commit that referenced this pull request Dec 5, 2026
## 🤖 New release

* `cachey`: 0.13.7 -> 0.13.8

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.13.8](0.13.7...0.13.8)
- 2026-12-05

### Fixed

- *(service)* record single-chunk egress only when response body is
polled ([#241](#241))
- *(object_store)* refund unstarted attempt credits and gate hedge
outcomes ([#240](#240))

### Other

- *(deps)* upgrade dependencies
([#242](#242))
- drop nightly Cargo cooldown requirement and soften Cargo.lock guidance
([#237](#237))
- pin rust-dependency-cooldown workflow to commit SHA
([#236](#236))
- use shared rust-dependency-cooldown workflow
([#234](#234))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

[Detail Bug] Metrics: Egress throughput counts response bytes even when clients drop the body

1 participant