curvine icon indicating copy to clipboard operation
curvine copied to clipboard

[FEATURE] Add FUSE read queue latency and backlog metrics

Open wsq2333 opened this issue 3 weeks ago • 1 comments

Is your feature request related to a problem? Please describe.

Under concurrent reads, FUSE request latency can increase while backend read latency remains low. Existing dispatch and backend IO metrics do not separately expose read-channel capacity waits, queued-task residence, or reply-channel capacity waits.

Unbounded channels can also accumulate pending reads without exhibiting capacity backpressure, making read backlog visibility necessary.

Describe the solution you'd like

Add:

  • curvine_fuse_io_wait_duration_us{io_type,stage,outcome}
    • io_type=read
    • stage=enqueue|queue|reply_enqueue
    • outcome=success|error|cancelled
  • curvine_fuse_stream_read_queue_depth

For bounded channels, measure capacity acquisition separately from queue residence. For unbounded channels, enqueue metrics measure synchronous send overhead.

Count only Read tasks awaiting dequeue in the backlog gauge. Release the count on dequeue, failed publication, or task drop. Emit queue latency only for tasks actually dequeued.

Wait outcomes describe the measured stage, not the backend read result. Preserve existing metrics-disabled, cancellation, and reply semantics.

Describe alternatives you've considered

  • Dispatch latency alone mixes several kinds of work and waiting.
  • Backend IO latency does not capture time spent awaiting a reader worker.
  • Queue depth alone shows backlog but not its latency distribution.
  • Per-request logging adds volume and does not directly provide aggregate latency histograms.

Additional context

This is read-path observability only. It is independent of the write-queue budget proposal in #1993.

The new waits overlap existing dispatch/request timings and must not be summed with them. Pre-enqueue locks, backend IO, reply queue residence, and kernel response writes remain separate phases.

Goal

Sub-requirement Problem solved
Separate enqueue, queue, and reply_enqueue timings Locate read-path waiting
Read-only backlog gauge with automatic cleanup Observe accumulation without leaked counts
Success/error/cancelled wait outcomes Distinguish completed waits from failed or abandoned attempts
Metrics-disabled fast path Avoid creating new timers or queue guards when disabled

Not Goal

  • Instrument or change the write path.
  • Change queue capacities, defaults, IO ordering, or cache policy.
  • Add metadata/GetAttr instrumentation.
  • Infer cache hits or OSS fallback from queue metrics.
  • Measure reply queue residence or change the FUSE protocol.

Test Plan

Test case Test objective Modules involved
Bounded channel fills, blocks, and resumes Separate capacity waiting from queued tasks fuse_reader
Cancellation while waiting for capacity Record cancellation without publishing a task fuse_reader, fuse_response
Unbounded and closed channels Preserve send behavior and error accounting fuse_reader, fuse_response
Dequeue, failed send, and task discard Balance backlog and avoid fake queue samples fuse_metrics, fuse_reader
Error read reply successfully enqueues Separate wait outcome from backend result fuse_response
Metrics disabled and non-Read operations Exclude unrelated operations and new instrumentation All changed modules
Existing metrics, reader, and reply tests Preserve existing behavior curvine-fuse

wsq2333 avatar Nov 09 '26 13:11 wsq2333

Summary

Add FUSE read-path wait histograms and queue-depth metrics to distinguish channel capacity waits, queued-read latency, and backend IO latency under concurrent reads.

This change adds read-path observability without changing queue capacities, IO ordering, cache policy, or write-path instrumentation.

Issue Describe / Design

Closes #2007.

Metrics

Metric | Labels | Meaning -- | -- | -- curvine_fuse_io_wait_duration_us | io_type="read", stage, outcome | Read-path wait duration in microseconds curvine_fuse_stream_queue_depth | io_type="read" | Read tasks awaiting dequeue across reader channels

Coverage includes:

  • Bounded-channel backpressure, cancellation, and retry.
  • Unbounded-channel exclusions for capacity-wait observations.
  • Exactly one queue-success sample through the actual FuseReader::read → worker dequeue path, with backlog returning to zero.
  • Closed channels and failed-reserve timing frozen before error bookkeeping.
  • Disabled metrics, non-Read replies, and duplicate-reply suppression.
  • Reserved publication after receiver closure or destruction.
  • Independent metric instances and exact assertions that remain reliable under parallel tests.

Real-mount load testing, instrumentation-overhead benchmarking, and Grafana dashboard updates are outside this validation.

Dependencies

  • Related issue: #2007.
  • Related PRs: None.
  • Blocks / blocked by: None.
  • Independent of the write-queue budget proposal in #1993.

wsq2333 avatar Nov 10 '26 08:11 wsq2333