Skip to content

Commit f84dfe6

Browse files
committed
perf(metrics): reduce prefetch I/O metrics overhead
1 parent dd2a597 commit f84dfe6

11 files changed

Lines changed: 187 additions & 73 deletions

File tree

docs/source/user_guide/metrics.rst

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,12 @@ Prefetch I/O
8787
------------
8888

8989
``PrefetchIoMetrics`` describes only I/O that passes through the prefetch reader's instrumented
90-
input streams. It is not a whole-query or whole-table I/O total. All counters and histograms
91-
accumulate for the reader lifetime and are retained across ``SetReadSchema()`` and cache reset.
90+
input streams. It is not a whole-query or whole-table I/O total. All counters accumulate for the
91+
reader lifetime and are retained across ``SetReadSchema()`` and cache reset. Latency uses relaxed
92+
atomic count, sum, minimum, and maximum counters instead of per-I/O histograms to reduce hot-path
93+
cost. Collection is disabled by default; set ``prefetch.io-metrics.enabled`` to ``true`` in the
94+
read options to enable it. When disabled, these per-I/O metrics are absent and the input streams
95+
have no metrics instrumentation.
9296
``io.async.pending`` is current state and returns to zero when all callbacks complete.
9397
These metrics are C++-only and have no counterparts in Java Paimon.
9498

@@ -100,11 +104,17 @@ These metrics are C++-only and have no counterparts in Java Paimon.
100104
"io.read.requested-bytes", "counter", "bytes", "Bytes requested by synchronous reads"
101105
"io.read.physical-bytes", "counter", "bytes", "Bytes returned by successful synchronous reads"
102106
"io.read.failed", "counter", "requests", "Failed synchronous reads"
103-
"io.read.latency-us", "histogram", "microseconds", "Synchronous read latency"
107+
"io.read.latency.count", "counter", "requests", "Completed synchronous read latency samples"
108+
"io.read.latency.sum-us", "counter", "microseconds", "Sum of synchronous read latency"
109+
"io.read.latency.min-us", "counter", "microseconds", "Minimum synchronous read latency; 0 without samples"
110+
"io.read.latency.max-us", "counter", "microseconds", "Maximum synchronous read latency; 0 without samples"
104111
"io.async.requests", "counter", "requests", "Asynchronous read requests"
105112
"io.async.requested-bytes", "counter", "bytes", "Bytes requested by asynchronous reads"
106113
"io.async.physical-bytes", "counter", "bytes", "Bytes attributed to successful asynchronous reads"
107114
"io.async.completed", "counter", "requests", "Successful asynchronous reads"
108115
"io.async.failed", "counter", "requests", "Failed asynchronous reads"
109116
"io.async.pending", "gauge", "requests", "Asynchronous callbacks not yet completed"
110-
"io.async.latency-us", "histogram", "microseconds", "Asynchronous callback latency"
117+
"io.async.latency.count", "counter", "requests", "Completed asynchronous callback latency samples"
118+
"io.async.latency.sum-us", "counter", "microseconds", "Sum of asynchronous callback latency"
119+
"io.async.latency.min-us", "counter", "microseconds", "Minimum asynchronous callback latency; 0 without samples"
120+
"io.async.latency.max-us", "counter", "microseconds", "Maximum asynchronous callback latency; 0 without samples"

include/paimon/defs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ struct PAIMON_EXPORT Options {
204204
/// for the target bucket when rebuilding the cache. Default value is true.
205205
static const char SCAN_MANIFEST_ENTRY_LAZY_DECODE_ENABLED[];
206206

207+
/// "prefetch.io-metrics.enabled" - Whether to collect per-I/O metrics for prefetch reads.
208+
/// Default value is false.
209+
static const char PREFETCH_IO_METRICS_ENABLED[];
210+
207211
/// "read.batch-size" - Read batch size for any file format if it supports.
208212
/// The default value is 1024.
209213
static const char READ_BATCH_SIZE[];

include/paimon/reader/prefetch_file_batch_reader.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,20 @@ class PAIMON_EXPORT PrefetchIoMetrics {
5656
static constexpr char READ_REQUESTED_BYTES[] = "io.read.requested-bytes";
5757
static constexpr char READ_PHYSICAL_BYTES[] = "io.read.physical-bytes";
5858
static constexpr char READ_FAILED[] = "io.read.failed";
59-
static constexpr char READ_LATENCY_US[] = "io.read.latency-us";
59+
static constexpr char READ_LATENCY_COUNT[] = "io.read.latency.count";
60+
static constexpr char READ_LATENCY_SUM_US[] = "io.read.latency.sum-us";
61+
static constexpr char READ_LATENCY_MIN_US[] = "io.read.latency.min-us";
62+
static constexpr char READ_LATENCY_MAX_US[] = "io.read.latency.max-us";
6063
static constexpr char ASYNC_REQUESTS[] = "io.async.requests";
6164
static constexpr char ASYNC_REQUESTED_BYTES[] = "io.async.requested-bytes";
6265
static constexpr char ASYNC_PHYSICAL_BYTES[] = "io.async.physical-bytes";
6366
static constexpr char ASYNC_COMPLETED[] = "io.async.completed";
6467
static constexpr char ASYNC_FAILED[] = "io.async.failed";
6568
static constexpr char ASYNC_PENDING[] = "io.async.pending";
66-
static constexpr char ASYNC_LATENCY_US[] = "io.async.latency-us";
69+
static constexpr char ASYNC_LATENCY_COUNT[] = "io.async.latency.count";
70+
static constexpr char ASYNC_LATENCY_SUM_US[] = "io.async.latency.sum-us";
71+
static constexpr char ASYNC_LATENCY_MIN_US[] = "io.async.latency.min-us";
72+
static constexpr char ASYNC_LATENCY_MAX_US[] = "io.async.latency.max-us";
6773
};
6874

6975
/// The prefetch file batch reader extends the basic FileBatchReader interface for prefetch read,

src/paimon/common/defs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const char Options::SCAN_MANIFEST_ENTRY_CACHE_MAX_SNAPSHOTS[] =
6161
"scan.manifest-entry-cache.max-snapshots";
6262
const char Options::SCAN_MANIFEST_ENTRY_LAZY_DECODE_ENABLED[] =
6363
"scan.manifest-entry.lazy-decode.enabled";
64+
const char Options::PREFETCH_IO_METRICS_ENABLED[] = "prefetch.io-metrics.enabled";
6465
const char Options::READ_BATCH_SIZE[] = "read.batch-size";
6566
const char Options::WRITE_BATCH_SIZE[] = "write.batch-size";
6667
const char Options::WRITE_BUFFER_SIZE[] = "write-buffer-size";

0 commit comments

Comments
 (0)