Repository navigation
perf: remove cache range pipe relay - #215
Merged
Merged
Conversation
|
perfloop
Bot
force-pushed
the
perfloop-pr-open-1a34ftfbjy
branch
from
September 12, 2026 07:42
a005731 to
b6790d0
Compare
ovaistariq
approved these changes
Oct 21, 2026
|
🎉 This PR is included in version 1.22.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove the cache-range pipe relay for cached single-range GETs.
serveRangeFromCachenow writes cache chunks directly to the existing lazy response writer. It sends the 206 headers andX-Cache: HITonly when the first non-empty chunk arrives, so empty reads and failures before the first byte remain uncommitted for upstream fallback. After commitment, a stream error keeps the partial response and does not append an upstream response. The cache read continues to use the metadata body's discriminator for versioned entries.The change keeps range parsing, 206 headers, byte accounting, revalidation, and fallback behavior. Focused tests cover empty reads, failures before and after a strict partial first write, normal-handler fallback, and revalidation callers.
The benchmark enters the transparent-mode production router, warms a non-block cache entry, validates the complete 206 response, and measures 1 KiB, 64 KiB, 1 MiB, and 4 MiB hits.
Tests:
go test ./proxy -run '^(TestServeRangeFromCache_EmptyBodyReportsGone|TestServeRangeFromCache_ErrorBeforeFirstByte|TestServeRangeFromCache_ErrorAfterFirstByteKeepsCommittedResponse|TestHandleGetObject_RangeCacheHitPostCommitErrorDoesNotFallBack|TestHandleGetObject_EmptyRangeCacheHitFallsBackBeforeHeaders|TestRevalidationRange304_ServesCachedRange|TestRevalidationRange304_BodyEvictedForwardsUpstream)$' -count=1make lint-cimake buildmake testmake test-integrationmake test-racemake test-coverageWorkload:
warm non-block single-range cache hit through the transparent-mode production router, 1 KiB responsecpu-ns/opns/opWorkload:
warm non-block single-range cache hit through the transparent-mode production router, 64 KiB responsecpu-ns/opns/opWorkload:
warm non-block single-range cache hit through the transparent-mode production router, 1 MiB responsecpu-ns/opns/opWorkload:
warm non-block single-range cache hit through the transparent-mode production router, 4 MiB responsecpu-ns/opns/opGenerated by Perfloop. Measurements and checks.
Note
Medium Risk
Changes hot-path GET/range cache serving and HTTP commit/fallback semantics; behavior is heavily tested but mistakes could affect partial responses or upstream fallback.
Overview
Removes the
io.Piperelay for single-range cache hits and streams range bytes straight to the client via an extendedlazyCommitWriter.serveRangeFromCachenow pipesGetRangeStreaminto that writer, which emits 206, range headers, andX-Cache: HITonly after the first non-empty chunk—so empty or pre-commit failures stay uncommitted andHandleGetObjectcan still fall back upstream. Post-commit stream errors keep the partial 206 and do not trigger upstream.lazyCommitWriter.Writealso surfacesio.ErrShortWriteon incomplete writes.Adds router-level benchmarks (
BenchmarkServeRangeFromCacheat 1K–4M) and tests for range stream errors, empty-body fallback, and post-commit behavior. Revalidation comments are updated to match the shared lazy-commit contract.Reviewed by Cursor Bugbot for commit b6790d0. Bugbot is set up for automated code reviews on this repo. Configure here.