Skip to content

feat(storage): rationalize read path OTEL - #2831

Closed
levb wants to merge 17 commits into
mainfrom
lev-gcs-read-ttfb-metric
Closed

levb wants to merge 17 commits into
mainfrom
lev-gcs-read-ttfb-metric

Conversation

@levb

@levb levb commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Adds to #2570 which should be merged first.

Adds an orchestrator.read.* metric family with consistent attributes
(file_type/source/codec/outcome) covering each stage of a read, plus
per-layer chunker and build-file timers, so dashboards can attribute
latency end-to-end from sandbox-visible read to backend fetch.

Does not remove any of the prior metrics, this will be done separately
after the dashboards are updated.

Metrics:

  • orchestrator.file.read_at build.File.ReadAt - per-fault unit, aggregates all underlying mappings into one record
  • orchestrator.chunk.slice Chunker.Slice - per per-mapping unit, source=mmap on cache hit else the backend that served
  • orchestrator.read.open - OpenRangeReader (open / TTFB)
  • orchestrator.read.read - source-read wall time, raw bytes
  • orchestrator.read.decompress - decompress wall time + uncompressed bytes
  • orchestrator.read.fetch - total fetch wall time + uncompressed bytes delivered
  • orchestrator.read.writeback - NFS cache writeback wall + bytes
  • orchestrator.read.pipeline.efficiency - fetch / (open+read+decompress)
  • orchestrator.read.cache - NFS hit/miss/writeback events
  • orchestrator.read.inflight - concurrent fetches gauge

Spans:

  • chunk.fetch - runFetch goroutine span

@cla-bot cla-bot Bot added the cla-signed label May 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

@levb
levb force-pushed the lev-gcs-read-ttfb-metric branch from f1d1973 to f7a0b35 Compare May 28, 2026 14:31
@levb
levb marked this pull request as ready for review May 28, 2026 16:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a8b2cff410

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/shared/pkg/storage/storage_aws.go Outdated
Comment thread packages/orchestrator/pkg/sandbox/template/peerclient/storage.go Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2035d4a86c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/shared/pkg/storage/storage_cache_seekable_compressed.go Outdated
@levb
levb force-pushed the lev-storage-rationalize branch from 57dfa58 to d38984a Compare June 1, 2026 17:46
@levb
levb force-pushed the lev-gcs-read-ttfb-metric branch from 8b1aab0 to 8276414 Compare June 1, 2026 17:56

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 827641417b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/shared/pkg/storage/compress_decode.go Outdated
Lev Brouk added 2 commits June 8, 2026 11:23
Replace the OpenRangeReader return type io.ReadCloser with a context-aware
RangeReader and collapse scattered reader wrappers (offset/section/capture/
observable/decompress) into a single io_wrappers.go. Drops the
cacheWriteThroughReader in favor of a reusable captureReader with optional
drain-on-close for codecs that stop short of EOF on their source.
@levb
levb force-pushed the lev-storage-rationalize branch from d38984a to 082285c Compare June 8, 2026 21:05
@levb
levb force-pushed the lev-gcs-read-ttfb-metric branch from 8276414 to 605a3f5 Compare June 8, 2026 21:46
@levb
levb force-pushed the lev-gcs-read-ttfb-metric branch from 75f2087 to 506c3e7 Compare June 8, 2026 22:06
Lev Brouk added 8 commits June 9, 2026 10:45
When NewDecompressingReader fails, closing the captureReader drained the
raw stream into its buffer and persisted those bytes to NFS, poisoning
the .frm cache on a failed miss. Close raw directly on the error path
to bypass the drain+writeback side effect.
Adds an orchestrator.read.* metric family with consistent attributes
(file_type/source/codec/outcome) covering each stage of a read, plus
per-layer chunker and build-file timers, so dashboards can attribute
latency end-to-end from sandbox-visible read to backend fetch.

Does not remove any of the prior metrics, this will be done separately
after the dashboards are updated.

Metrics:
  - orchestrator.file.read_at               build.File.ReadAt — per-fault
                                            unit, aggregates all underlying
                                            mappings into one record
  - orchestrator.chunk.slice                Chunker.Slice — per per-mapping
                                            unit, source=mmap on cache hit
                                            else the backend that served
  - orchestrator.read.open                  OpenRangeReader (open / TTFB)
  - orchestrator.read.read                  source-read wall, compressed bytes
  - orchestrator.read.decompress            decompress CPU + uncompressed bytes
  - orchestrator.read.fetch                 total fetch wall + bytes delivered
  - orchestrator.read.writeback             NFS cache writeback wall + bytes
  - orchestrator.read.pipeline.efficiency   fetch / (open+read+decompress)
  - orchestrator.read.cache                 NFS hit/miss/writeback events
  - orchestrator.read.inflight              concurrent fetches gauge

Spans:
  - chunk.fetch                             runFetch goroutine span
@levb
levb force-pushed the lev-gcs-read-ttfb-metric branch from 506c3e7 to ba1e232 Compare June 16, 2026 22:50
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Base automatically changed from lev-storage-rationalize to main June 17, 2026 16:43
Comment thread packages/shared/pkg/telemetry/meters.go Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Comment on lines +98 to +102
func StartInflight(ctx context.Context, attrs metric.MeasurementOption) func() {
readInflight.Add(ctx, 1, attrs)

return func() { readInflight.Add(ctx, -1, attrs) }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just add the traditional warning here: gauges are rarely the right answer, and often misleading. It might be safer to record "reads begun" and "reads finished" as counters. Alternately, recording both would be reasonable.

TL;DR: gauges only show you a point-in-time every n seconds (30 or 60 by default, depending on system), no way to judge what happened in between.

As an example of what could be hidden by a gauge:

  • a process increments and decrements that gauge 1000 times in 5 seconds, in between two readings. The gauge reports 0 at each moment in time, no indication of the flurry of activity.
  • 50 reads are started/stopped every second. The gauge shows "50 concurrent reads" but what really happened was that there were 50 reads * 30 seconds = 1500 reads total; no way to differentiate that from "50 sustained reads over 30 seconds"

You can nearly always the gauge data from a counter; you can't get the counter data from the gauge. If point-in-time concurrency is valuable, let's keep it; otherwise increase(total_read_count[$__interval]) tells us "how many reads were started over this period, averaged per second"; not quite the same thing, but similar in terms of diagnostic value.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@levb levb closed this Jun 22, 2026
@ValentaTomas
ValentaTomas deleted the lev-gcs-read-ttfb-metric branch September 11, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants