-
Notifications
You must be signed in to change notification settings - Fork 622
[server] Expose KV WAL memory pool metrics for primary key tables #4248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -250,6 +250,16 @@ public class MetricNames { | |
| public static final String ROCKSDB_SHARED_WRITE_BUFFER_CAPACITY = | ||
| "rocksdbSharedWriteBufferCapacity"; | ||
|
|
||
| // Server-level WAL memory pool metrics for primary key tables | ||
| /** Memory used by the WAL memory pool for primary key tables in this server (bytes). */ | ||
| public static final String WAL_MEMORY_POOL_USAGE = "walMemoryPoolUsage"; | ||
|
|
||
| /** Total capacity of the WAL memory pool for primary key tables in this server (bytes). */ | ||
| public static final String WAL_MEMORY_POOL_CAPACITY = "walMemoryPoolCapacity"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we name these kvWalMemoryPoolUsage and kvWalMemoryPoolCapacity? This pool serves the KV write path, while the tabletserver metric group contains both Log and KV metrics. A kv prefix would make that distinction explicit and align with names such as kvFlushPerSecond and kvBackpressureMaxPressure. The Usage/Capacity suffixes already match the existing memory metrics. |
||
|
|
||
| /** Number of threads currently waiting for pages from the WAL memory pool. */ | ||
| public static final String WAL_MEMORY_POOL_WAITING_THREADS = "walMemoryPoolWaitingThreads"; | ||
|
|
||
| // Table-level RocksDB memory metrics (Sum aggregation) | ||
| /** Total memtable memory usage across all buckets of this table. */ | ||
| public static final String ROCKSDB_MEMTABLE_MEMORY_USAGE_TOTAL = | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
|
|
||
| package org.apache.fluss.server.metrics.group; | ||
|
|
||
| import org.apache.fluss.memory.LazyMemorySegmentPool; | ||
| import org.apache.fluss.metadata.PhysicalTablePath; | ||
| import org.apache.fluss.metadata.TableBucket; | ||
| import org.apache.fluss.metadata.TablePath; | ||
|
|
@@ -215,6 +216,19 @@ public void setSharedWriteBufferMetrics(LongSupplier usageSupplier, long capacit | |
| this.sharedWriteBufferCapacity = capacity; | ||
| } | ||
|
|
||
| /** | ||
| * Registers gauges for the server-wide WAL memory pool used by primary key tables. Called once | ||
| * by KvManager when creating the server buffer pool. | ||
| * | ||
| * @param walMemoryPool the server-wide WAL memory segment pool | ||
| */ | ||
| public void setWalMemoryPoolMetrics(LazyMemorySegmentPool walMemoryPool) { | ||
| LazyMemorySegmentPool pool = checkNotNull(walMemoryPool, "walMemoryPool must not be null"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we narrow this to |
||
| gauge(MetricNames.WAL_MEMORY_POOL_USAGE, () -> (long) pool.usedPages() * pool.pageSize()); | ||
| gauge(MetricNames.WAL_MEMORY_POOL_CAPACITY, pool::totalSize); | ||
| gauge(MetricNames.WAL_MEMORY_POOL_WAITING_THREADS, pool::queued); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep this PR focused on WAL pool usage and capacity and omit |
||
| } | ||
|
|
||
| @Override | ||
| protected final void putVariables(Map<String, String> variables) { | ||
| variables.put("cluster_id", clusterId); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make this accessor a lock-free read? The new gauge takes the same exclusive lock as page allocation and return, and allocation also performs heap allocation while holding that lock. This couples metric collection to the production allocation path in both directions: collection can contend with writers, and allocation can delay collection. An instantaneous usage value is sufficient here; we do not need a consistent snapshot across gauges. Please make
pageUsagevolatile and read it directly inusedPages(), while retaining the existing lock around accounting updates. The accessor should remain safe after pool closure so an in-flight collection can finish without throwing. Do not reset the accounting counter merely for monitoring during close, since pages can still be returned afterward.