Repository navigation
Reduce GCS QPS on ArrayRecordReader open via ReadLast. - #212
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
copybara-service
Bot
force-pushed
the
test_992624347
branch
3 times, most recently
from
October 5, 2026 19:57
96b3852 to
1c4bdee
Compare
Previously, opening a `gs://` ArrayRecord shard constructed a new `google::cloud::storage::Client` instance and issued 3 separate GCS HTTP GET requests: 1. An unbounded GET at offset 0 during `GcsReader` construction solely to obtain the object size (and then aborted mid-stream). 2. A GET via `reader->NewReader(size - 64KB)` to read the Riegeli postscript. 3. A GET via `reader->NewReader(footer_offset)` to read the ArrayRecord footer (and in `OffloadedChunkOffset::operator[]` when `index_storage_option` is `offloaded`). This change: 1. Shares a process-wide `google::cloud::storage::Client` singleton across `ArrayRecordReader` instances in `array_record_module.cc`. 2. Opens `riegeli::GcsReader` with `google::cloud::storage::ReadLast(1 MiB)` so the initial HTTP GET retrieves the total object size (`Content-Range`) and prefetches the last 1 MiB of the shard. 3. In `ArrayRecordReaderBase::Initialize()`, pulls the prefetched tail into `reader`'s buffer (resetting the cursor to `limit()` so `available() == 0` on close) and reads the postscript and footer (including offloaded chunk index lookups in `OffloadedChunkOffset::operator[]`) directly from `reader`'s buffered tail via `ReadChunk` when `footer_offset >= reader->start_pos()`. PiperOrigin-RevId: 992624347
copybara-service
Bot
force-pushed
the
test_992624347
branch
from
October 5, 2026 20:10
1c4bdee to
88b11c1
Compare
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Reduce GCS QPS on ArrayRecordReader open via ReadLast.
Previously, opening a
gs://ArrayRecord shard constructed a newgoogle::cloud::storage::Clientinstance and issued 3 separate GCS HTTP GETrequests:
GcsReaderconstruction solely to obtainthe object size (and then aborted mid-stream).
reader->NewReader(size - 64KB)to read the Riegeli postscript.reader->NewReader(footer_offset)to read the ArrayRecord footer(and in
OffloadedChunkOffset::operator[]whenindex_storage_optionisoffloaded).This change:
google::cloud::storage::Clientsingleton acrossArrayRecordReaderinstances inarray_record_module.cc.riegeli::GcsReaderwithgoogle::cloud::storage::ReadLast(1 MiB)sothe initial HTTP GET retrieves the total object size (
Content-Range) andprefetches the last 1 MiB of the shard.
ArrayRecordReaderBase::Initialize(), pulls the prefetched tail intoreader's buffer (resetting the cursor tolimit()soavailable() == 0onclose) and reads the postscript and footer (including offloaded chunk index
lookups in
OffloadedChunkOffset::operator[]) directly fromreader'sbuffered tail via
ReadChunkwhenfooter_offset >= reader->start_pos().