advanced24 min studyLesson 536 in Engineering

Measure bytes fetched per useful training byte

Connect record layout, range requests, compression boundaries, and locality to remote-read cost while preserving dataset identity and sampling policy.

On this page

What you’ll understand

  • Define read amplification with a consistent byte basis.
  • Explain how layout and compression constrain selective access.
  • Evaluate locality improvements alongside their sampling and cache effects.

A trainer uses one MiB of examples per step but retrieves sixty-four MiB from remote storage. Network throughput looks healthy while useful batch delivery is poor. The gap comes from the unit the reader must fetch or decompress, not merely the number of requested records. Read amplification measures those extra bytes against the bytes actually needed for the declared work. Diagnose the layout and request path before buying more bandwidth or changing the sampling policy to hide the problem.

Define the numerator and denominator carefully

Record remote bytes transferred, useful in-scope payload bytes, request count, and the observation window. Keep byte representations consistent: comparing compressed network bytes with uncompressed tensor bytes can produce a ratio that measures compression as well as unwanted reads. Metadata, retries, duplicated requests, and speculative prefetch may belong in the transferred total depending on the question. State that choice. An average over one epoch can hide short bursts where each random sample opens a different object. Collect enough identity and range information to attribute the extra traffic without exposing training data contents in diagnostics.

A range-capable object API can retrieve a specified byte interval, but the file and compression format must support meaningful selective decoding at that interval. Amazon S 3 GetObject documents byte ranges and version selection; it does not automatically build a record index inside an arbitrary compressed archive. Whole-stream compression may require reading earlier data before a desired record can be decoded. Indexed blocks or columnar layouts can reduce unnecessary reads under compatible access patterns. Verify what the reader actually requests and decodes, rather than infer one-record access cost from an API's support for ranges.

Aread=BfetchedBuseful,Buseful>0A_{\mathrm{read}}=\frac{B_{\mathrm{fetched}}}{B_{\mathrm{useful}}},\qquad B_{\mathrm{useful}}>0
Both byte totals use a declared consistent representation and observation window. A_read is dimensionless; zero useful payload needs an explicit no-useful-work outcome. Include or exclude metadata, retries, and prefetch consistently with the stated measurement.↔ Scroll wide equations horizontally.

Make layout and request granularity agree

Apache Parquet's format separates file metadata and column chunks, with row groups defining groups of rows. Readers can use metadata to locate relevant chunks rather than fetch every column, but actual pruning depends on the query, indexes, compression, and implementation. A training pipeline that needs only text and labels should not assume a reader automatically avoids unrelated image bytes. Likewise, a random individual-record pattern can defeat a layout designed for sequential scans. Measure the useful columns and rows obtained per physical read and preserve the file-version identity used to interpret offsets.

Larger sequential reads can amortize request latency while overfetching unused data; smaller reads can reduce bytes while multiplying operations and overhead. Coalescing nearby requests or caching blocks may improve both for a suitable workload. Batch-aware fetching can exploit known locality without changing the declared sample order if results are reassembled correctly. If changing shuffle or shard order is the optimization, record and validate that semantic change. A fast stream dominated by one source block may be statistically different from the intended global traversal even when every fetched byte is eventually useful.

Ruseful≤RnetworkAread,Aread>0R_{\mathrm{useful}}\leq\frac{R_{\mathrm{network}}}{A_{\mathrm{read}}},\qquad A_{\mathrm{read}}>0
For the same byte basis and sustained window, network bytes/s divided by dimensionless amplification bounds useful bytes/s when network transfer is the limiting resource. Latency, decoding, request limits, and contention can lower actual throughput further.↔ Scroll wide equations horizontally.

Separate cache reuse from changed source work

Compare cold and warm behavior, and record whether a hit returns an immutable block from the intended dataset snapshot. Reusing a stale block after an object is replaced can make a faster pipeline incorrect. Include request failures and retries in operational accounting, and distinguish fewer remote bytes from fewer decoded records. A decompression cache may save CPU without reducing the first remote transfer, while a remote block cache can reduce subsequent network traffic. The relevant optimization depends on which resource currently limits delivered batches and which reuse identities are trustworthy.

The cache lab isolates one locality effect. For each separate view, Reset, set both capacity C and request stride s=4, predict initial misses, then inspect. The sixteen requests cycle through four addresses. Capacity four gives four misses and twelve hits; capacity two misses all sixteen. This exact empty LRU trace does not know object sizes, byte ranges, compression, or training samples. If each abstract miss required a remote fetch, the counts would indicate different fetch demand, but actual byte amplification still requires the size and useful payload of each real read.

Convert apparent bandwidth into useful delivery

A fictional reader needs 1 MiB of encoded useful records for each request but must retrieve a 64 MiB encoded block each time. One hundred requests have no shared-block reuse. Assume network bandwidth is 1024 MiB/s and ignore all other costs for this bound.

  1. The useful total is 100 MiB while the transferred total is 6400 MiB. Amplification is 6400/100=64.

  2. The network-only useful-throughput ceiling is 1024/64=16 MiB/s. Transferring the 6400 MiB takes at least 6.25 seconds.

  3. An index, compatible block layout, or trustworthy block reuse might change the numerator, but the improvement must be measured without silently changing which records are trained on. The invented bandwidth is not a storage-service benchmark.

The result

The stated access path has 64-times read amplification and a 16 MiB/s network-only useful-data ceiling despite 1024 MiB/s of transfer bandwidth.

Explore the model

Interactive lab

Interactive lab · cache

Count repeat fetch opportunities in an explicit trace

For each view: Reset, set both C and s=4, predict, then inspect the initial sixteen requests. C=4 gives 4 misses and 12 hits; C=2 gives 16 misses. Play or Step only after predicting. This is a toy LRU address trace, not a remote object reader or byte-amplification calculator.

Count repeat fetch opportunities in an explicit traceA fully associative LRU cache starts empty and requests address (i·s) mod 16. Hits move an address to the newest position; misses evict the oldest when full. Playback starts with 16 requests and adds two per second, capped at 4096 explicitly simulated requests. This toy stream is not a processor-cache benchmark. Current readings: Hits / requests: 0 / 16; Hit rate: 0%; Address-stream period: 16 addresses. All parameters are adjustable with the labeled controls below.Fully associative LRU cache after 16 deterministic requests: 0 hits and 16 misses.Most recent 16 requestsaddress = i × 3 mod 160M3M6M9M12M15M2M5M8M11M14M1M4M7M10M13MCurrent cache order · oldest → newest471013Latest address 13 · miss: inserted as newestToy address stream · period 16 · starts empty
Cached addressMiss / evictionMost recent request
Hits / requests
0 / 16
Hit rate
0%
Address-stream period
16 addresses
t = 0 s

A fully associative LRU cache starts empty and requests address (i·s) mod 16. Hits move an address to the newest position; misses evict the oldest when full. Playback starts with 16 requests and adds two per second, capped at 4096 explicitly simulated requests. This toy stream is not a processor-cache benchmark. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA miss count becomes a byte cost only with actual fetch sizes and useful payloads. Cache reuse also needs correct snapshot and range identities.

Check your understanding

Why might a byte-range API fail to make random records in a compressed object cheap to read?

Try it yourself

A fictional observation transfers 240 MiB to deliver 30 MiB of useful encoded records on the same byte basis. Network capacity is 400 MiB/s. Compute amplification and its network-only useful-throughput ceiling.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Divide transferred bytes by useful bytes, then divide capacity by that ratio.

Compare with the solution

Amplification is 240/30=8. The network-only ceiling is 400/8=50 MiB/s of useful records. Request overhead, decoding, and contention can lower actual delivery; this calculation does not show that the dataset order or cache contents are correct.

Take it with you

  • Measure remote and useful bytes on a consistent basis.
  • Selective reads depend on both transport and actual file/codec structure.
  • Locality and caching improve a specific resource path while preserving identity and visitation rules.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.