Skip to content

Commit 07e2f47

Browse files
fulmicotonguilload
andauthored
Wal allocated into inflight data (#4728)
* Moving WAL memory usage into in flight data so we can get a break down per label. * Added counter for split builders * Apply suggestions from code review Co-authored-by: Adrien Guillo <[email protected]> --------- Co-authored-by: Adrien Guillo <[email protected]>
1 parent 83d8d9e commit 07e2f47

File tree

5 files changed

+29
-17
lines changed

5 files changed

+29
-17
lines changed

quickwit/quickwit-common/src/metrics.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,13 @@ impl Default for MemoryMetrics {
252252

253253
#[derive(Clone)]
254254
pub struct InFlightDataGauges {
255-
pub doc_processor_mailbox: IntGauge,
256-
pub index_writer: IntGauge,
257-
pub indexer_mailbox: IntGauge,
258-
pub ingest_router: IntGauge,
259255
pub rest_server: IntGauge,
256+
pub ingest_router: IntGauge,
257+
pub wal: IntGauge,
260258
pub sources: InFlightDataSourceGauges,
259+
pub doc_processor_mailbox: IntGauge,
260+
pub indexer_mailbox: IntGauge,
261+
pub index_writer: IntGauge,
261262
}
262263

263264
impl Default for InFlightDataGauges {
@@ -270,12 +271,13 @@ impl Default for InFlightDataGauges {
270271
["component"],
271272
);
272273
Self {
273-
doc_processor_mailbox: in_flight_gauge_vec.with_label_values(["doc_processor_mailbox"]),
274-
index_writer: in_flight_gauge_vec.with_label_values(["index_writer"]),
275-
indexer_mailbox: in_flight_gauge_vec.with_label_values(["indexer_mailbox"]),
276-
ingest_router: in_flight_gauge_vec.with_label_values(["ingest_router"]),
277274
rest_server: in_flight_gauge_vec.with_label_values(["rest_server"]),
275+
ingest_router: in_flight_gauge_vec.with_label_values(["ingest_router"]),
276+
wal: in_flight_gauge_vec.with_label_values(["wal"]),
278277
sources: InFlightDataSourceGauges::new(&in_flight_gauge_vec),
278+
doc_processor_mailbox: in_flight_gauge_vec.with_label_values(["doc_processor_mailbox"]),
279+
indexer_mailbox: in_flight_gauge_vec.with_label_values(["indexer_mailbox"]),
280+
index_writer: in_flight_gauge_vec.with_label_values(["index_writer"]),
279281
}
280282
}
281283
}

quickwit/quickwit-indexing/src/actors/indexer.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ impl IndexerState {
225225
let publish_lock = self.publish_lock.clone();
226226
let publish_token_opt = self.publish_token_opt.clone();
227227

228+
let mut split_builders_guard =
229+
GaugeGuard::from_gauge(&crate::metrics::INDEXER_METRICS.split_builders);
230+
split_builders_guard.add(1);
231+
228232
let workbench = IndexingWorkbench {
229233
workbench_id,
230234
create_instant: Instant::now(),
@@ -242,6 +246,7 @@ impl IndexerState {
242246
.in_flight_data
243247
.index_writer,
244248
),
249+
split_builders_guard,
245250
};
246251
Ok(workbench)
247252
}
@@ -364,6 +369,7 @@ struct IndexingWorkbench {
364369
last_delete_opstamp: u64,
365370
// Number of bytes declared as used by tantivy.
366371
memory_usage: GaugeGuard,
372+
split_builders_guard: GaugeGuard,
367373
}
368374

369375
pub struct Indexer {
@@ -635,6 +641,7 @@ impl Indexer {
635641
batch_parent_span,
636642
indexing_permit,
637643
memory_usage,
644+
split_builders_guard,
638645
..
639646
}) = self.indexing_workbench_opt.take()
640647
else {
@@ -687,6 +694,7 @@ impl Indexer {
687694
commit_trigger,
688695
batch_parent_span,
689696
memory_usage,
697+
_split_builders_guard: split_builders_guard,
690698
},
691699
)
692700
.await?;

quickwit/quickwit-indexing/src/metrics.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub struct IndexerMetrics {
2727
pub processed_bytes: IntCounterVec<2>,
2828
pub backpressure_micros: IntCounterVec<1>,
2929
pub available_concurrent_upload_permits: IntGaugeVec<1>,
30+
pub split_builders: IntGauge,
3031
pub ongoing_merge_operations: IntGauge,
3132
pub pending_merge_operations: IntGauge,
3233
pub pending_merge_bytes: IntGauge,
@@ -66,6 +67,12 @@ impl Default for IndexerMetrics {
6667
&[],
6768
["component"],
6869
),
70+
split_builders: new_gauge(
71+
"split_builders",
72+
"Number of existing index writer instances.",
73+
"indexing",
74+
&[],
75+
),
6976
ongoing_merge_operations: new_gauge(
7077
"ongoing_merge_operations",
7178
"Number of ongoing merge operations",

quickwit/quickwit-indexing/src/models/indexed_split.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ pub struct IndexedSplitBatchBuilder {
185185
pub commit_trigger: CommitTrigger,
186186
pub batch_parent_span: Span,
187187
pub memory_usage: GaugeGuard,
188+
pub _split_builders_guard: GaugeGuard,
188189
}
189190

190191
/// Sends notifications to the Publisher that the last batch of splits was emtpy.

quickwit/quickwit-ingest/src/ingest_v2/metrics.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ pub(super) struct IngestV2Metrics {
3131
pub wal_acquire_lock_requests_in_flight: IntGaugeVec<2>,
3232
pub wal_acquire_lock_request_duration_secs: HistogramVec<2>,
3333
pub wal_disk_used_bytes: IntGauge,
34-
pub wal_memory_allocated_bytes: IntGauge,
3534
pub wal_memory_used_bytes: IntGauge,
3635
}
3736

@@ -77,12 +76,6 @@ impl Default for IngestV2Metrics {
7776
"ingest",
7877
&[],
7978
),
80-
wal_memory_allocated_bytes: new_gauge(
81-
"wal_memory_allocated_bytes",
82-
"WAL memory allocated in bytes.",
83-
"ingest",
84-
&[],
85-
),
8679
wal_memory_used_bytes: new_gauge(
8780
"wal_memory_used_bytes",
8881
"WAL memory used in bytes.",
@@ -97,8 +90,9 @@ pub(super) fn report_wal_usage(wal_usage: ResourceUsage) {
9790
INGEST_V2_METRICS
9891
.wal_disk_used_bytes
9992
.set(wal_usage.disk_used_bytes as i64);
100-
INGEST_V2_METRICS
101-
.wal_memory_allocated_bytes
93+
quickwit_common::metrics::MEMORY_METRICS
94+
.in_flight_data
95+
.wal
10296
.set(wal_usage.memory_allocated_bytes as i64);
10397
INGEST_V2_METRICS
10498
.wal_memory_used_bytes

0 commit comments

Comments
 (0)