Skip to content

perf: write peer Get chunks directly - #217

Merged
ovaistariq merged 3 commits into
mainfrom
perfloop-pr-open-zmgx3kg7fw
Aug 17, 2026
Merged

ovaistariq merged 3 commits into
mainfrom
perfloop-pr-open-zmgx3kg7fw

Conversation

@perfloop

@perfloop perfloop Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Remote GetRangeStream relays peer chunks through grpcStreamReader.Read, so io.Copy copies every gRPC response chunk into its buffer before delivering it to the consumer.

Fix

Implement io.WriterTo on grpcStreamReader so io.Copy writes pending and received peer chunks directly to the destination. Keep Read for other callers.

Writes stay capped at 32 KiB to preserve compatibility with destinations that accept the previous io.Copy buffer size. The change keeps eager response resolution, ordering, stream errors, and close cancellation; gRPC receive decoding remains unchanged.

Test

  • TestGrpcStreamReader_* covers direct chunks, write limits, short writes, errors, and cleanup.
  • TestEmbeddedClient_GetRangeStreamRemote covers the cross-node stream path, byte-exact delivery, eager found/not-found handling, ordering, and cancellation.
  • BenchmarkEmbeddedClient_GetRangeStreamRemote covers remote streams from 64 KiB through 1 MiB.
  • make lint and make license-check

Workload: steady-state embedded cross-node GetRangeStream of a 64 KiB range

Metric Before After Change
B/op 193813 156882 19.1% lower
allocs/op 258 257 0.4% lower

Workload: steady-state embedded cross-node GetRangeStream of a 256 KiB range

Metric Before After Change
B/op 349977 314531 10.1% lower
allocs/op 291 290 0.3% lower

Workload: CPU profile of a 64 KiB embedded cross-node GetRangeStream

Metric Before After Change
grpcStreamReader.Read cumulative cpu seconds 0.255 0 100% lower
Checks: 3 passed.

Generated by Perfloop. Measurements and checks.


Note

Cursor Bugbot is generating a summary for commit ac61071. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR optimizes remote range streaming by implementing io.WriterTo on the gRPC stream reader, allowing peer chunks to be written directly while preserving bounded write sizes, ordering, error propagation, and cancellation.

  • Adds unit and cross-node integration coverage for direct chunk writes, short writes, stream errors, byte ordering, and cleanup.
  • Adds a reusable integration benchmark fixture and compile target.
  • Aligns the benchmark target with integration-test prerequisites and documents the compiled binary’s runtime timeout requirement.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
Makefile Adds the integration benchmark compilation target with protobuf generation, required output validation, inherited native build flags, and explicit runtime-timeout guidance.
server/operations/get.go Adds a bounded WriterTo fast path that directly relays pending and received peer chunks while preserving errors and stream cleanup.
server/operations/get_test.go Covers direct chunk forwarding, 32 KiB write bounds, short-write remainder handling, terminal errors, and cancellation.
tests/integration/embedded_stream_bench_test.go Adds cross-node correctness coverage and steady-state benchmarks for remote range streaming.
tests/integration/test_cluster_harness.go Generalizes the harness to testing.TB for benchmark reuse and binds memberlist to loopback in isolated runners.

Reviews (2): Last reviewed commit: "build: align bench-integration with sibl..." | Re-trigger Greptile

Comment thread Makefile Resolved
Add the proto prerequisite (matching test-integration / test-storage) so the
benchmark binary is never compiled against stale generated code, and document
that -timeout cannot be baked into a compiled test binary — the runner must
pass -test.timeout or a hung benchmark blocks forever.

Addresses the Greptile review note on the new target.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YCoN4Him5ZY4hZovVp37ra
Signed-off-by: Ovais Tariq <[email protected]>
@ovaistariq

Copy link
Copy Markdown
Contributor

@greptile

@ovaistariq
ovaistariq merged commit 3f0817a into main Aug 17, 2026
11 checks passed
@ovaistariq
ovaistariq deleted the perfloop-pr-open-zmgx3kg7fw branch August 17, 2026 22:28
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.10.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants