Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions doc/user/data/metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,20 @@ metrics:
help: Time checking trace frontiers.
source: src/compute/src/metrics.rs
visibility: internal
- name: mz_index_peek_result_sort_rows_bucket
help: Number of intermediate result rows sorted during peek collection, summed across sort operations.
labels:
- le
source: src/compute/src/metrics.rs
visibility: internal
- name: mz_index_peek_result_sort_rows_count
help: Number of intermediate result rows sorted during peek collection, summed across sort operations.
source: src/compute/src/metrics.rs
visibility: internal
- name: mz_index_peek_result_sort_rows_sum
help: Number of intermediate result rows sorted during peek collection, summed across sort operations.
source: src/compute/src/metrics.rs
visibility: internal
- name: mz_index_peek_result_sort_seconds_bucket
help: Time sorting intermediate results during peek collection.
labels:
Expand Down Expand Up @@ -1060,6 +1074,20 @@ metrics:
help: Time constructing RowCollection from peek results.
source: src/compute/src/metrics.rs
visibility: internal
- name: mz_index_peek_row_iteration_rows_bucket
help: Number of arrangement rows evaluated by the index peek result iterator.
labels:
- le
source: src/compute/src/metrics.rs
visibility: internal
- name: mz_index_peek_row_iteration_rows_count
help: Number of arrangement rows evaluated by the index peek result iterator.
source: src/compute/src/metrics.rs
visibility: internal
- name: mz_index_peek_row_iteration_rows_sum
help: Number of arrangement rows evaluated by the index peek result iterator.
source: src/compute/src/metrics.rs
visibility: internal
- name: mz_index_peek_row_iteration_seconds_bucket
help: Time iterating rows and evaluating MFP.
labels:
Expand Down
18 changes: 18 additions & 0 deletions src/compute/src/compute_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,9 @@ impl<'a> ActiveComputeState<'a> {
.compute_state
.metrics
.index_peek_row_iteration_seconds,
row_iteration_rows: &self.compute_state.metrics.index_peek_row_iteration_rows,
result_sort_seconds: &self.compute_state.metrics.index_peek_result_sort_seconds,
result_sort_rows: &self.compute_state.metrics.index_peek_result_sort_rows,
row_collection_seconds: &self
.compute_state
.metrics
Expand Down Expand Up @@ -1567,7 +1569,9 @@ pub(crate) struct IndexPeekMetrics<'a> {
pub error_scan_seconds: &'a prometheus::Histogram,
pub cursor_setup_seconds: &'a prometheus::Histogram,
pub row_iteration_seconds: &'a prometheus::Histogram,
pub row_iteration_rows: &'a prometheus::Histogram,
pub result_sort_seconds: &'a prometheus::Histogram,
pub result_sort_rows: &'a prometheus::Histogram,
pub row_collection_seconds: &'a prometheus::Histogram,
}

Expand Down Expand Up @@ -1738,6 +1742,7 @@ impl IndexPeek {
// Row iteration timing
let row_iteration_start = Instant::now();
let mut sort_time_accum = Duration::ZERO;
let mut rows_sorted = 0usize;

while let Some(row) = peek_iterator.next() {
let row: (Row, _) = match row {
Expand Down Expand Up @@ -1774,9 +1779,15 @@ impl IndexPeek {
metrics
.row_iteration_seconds
.observe(row_iteration_start.elapsed().as_secs_f64());
metrics
.row_iteration_rows
.observe(f64::cast_lossy(peek_iterator.rows_processed()));
metrics
.result_sort_seconds
.observe(sort_time_accum.as_secs_f64());
metrics
.result_sort_rows
.observe(f64::cast_lossy(rows_sorted));
let row_collection_start = Instant::now();
let collection = RowCollection::new(results, &peek.finishing.order_by);
metrics
Expand All @@ -1793,6 +1804,7 @@ impl IndexPeek {
// inner test (as we prefer not to maintain `Vec<Datum>`
// in the other case).
let sort_start = Instant::now();
rows_sorted = rows_sorted.saturating_add(results.len());
results.sort_by(|left, right| {
comparator.compare_rows(&left.0, &right.0, || left.0.cmp(&right.0))
});
Expand All @@ -1815,9 +1827,15 @@ impl IndexPeek {
metrics
.row_iteration_seconds
.observe(row_iteration_start.elapsed().as_secs_f64());
metrics
.row_iteration_rows
.observe(f64::cast_lossy(peek_iterator.rows_processed()));
metrics
.result_sort_seconds
.observe(sort_time_accum.as_secs_f64());
metrics
.result_sort_rows
.observe(f64::cast_lossy(rows_sorted));

let row_collection_start = Instant::now();
let collection = RowCollection::new(results, &peek.finishing.order_by);
Expand Down
8 changes: 8 additions & 0 deletions src/compute/src/compute_state/peek_result_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ where
row_builder: Row,
datum_vec: DatumVec,
literals: Option<Literals<Tr>>,
rows_processed: usize,
}

/// Helper to handle literals in peeks
Expand Down Expand Up @@ -140,9 +141,15 @@ where
row_builder: Row::default(),
datum_vec: DatumVec::new(),
literals,
rows_processed: 0,
}
}

/// Returns the number of rows evaluated by the iterator.
pub fn rows_processed(&self) -> usize {
self.rows_processed
}

/// Returns `true` if the iterator has no more literals to process, or if there are no literals at all.
fn literals_exhausted(&self) -> bool {
self.literals.as_ref().map_or(false, Literals::is_exhausted)
Expand Down Expand Up @@ -192,6 +199,7 @@ where
}
}

self.rows_processed = self.rows_processed.saturating_add(1);
match self.extract_current_row() {
Ok(Some(row)) => break Ok(row),
Ok(None) => {
Expand Down
23 changes: 23 additions & 0 deletions src/compute/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ pub struct ComputeMetrics {
index_peek_error_scan_seconds: Histogram,
index_peek_cursor_setup_seconds: Histogram,
index_peek_row_iteration_seconds: Histogram,
index_peek_row_iteration_rows: Histogram,
index_peek_result_sort_seconds: Histogram,
index_peek_result_sort_rows: Histogram,
index_peek_frontier_check_seconds: Histogram,
index_peek_row_collection_seconds: Histogram,

Expand All @@ -86,6 +88,9 @@ pub struct ComputeMetrics {
impl ComputeMetrics {
pub fn register_with(registry: &MetricsRegistry) -> Self {
let workload_class = Arc::new(Mutex::new(None));
let mut index_peek_row_buckets =
prometheus::exponential_buckets(1.0, 2.0, 25).expect("valid parameters");
index_peek_row_buckets.insert(0, 0.0);

// Apply a `workload_class` label to all metrics in the registry when we
// have a known workload class.
Expand Down Expand Up @@ -203,11 +208,21 @@ impl ComputeMetrics {
help: "Time iterating rows and evaluating MFP.",
buckets: mz_ore::stats::histogram_seconds_buckets(0.000_128, 8.0),
)),
index_peek_row_iteration_rows: registry.register(metric!(
name: "mz_index_peek_row_iteration_rows",
help: "Number of arrangement rows evaluated by the index peek result iterator.",
buckets: index_peek_row_buckets.clone(),
)),
index_peek_result_sort_seconds: registry.register(metric!(
name: "mz_index_peek_result_sort_seconds",
help: "Time sorting intermediate results during peek collection.",
buckets: mz_ore::stats::histogram_seconds_buckets(0.000_128, 8.0),
)),
index_peek_result_sort_rows: registry.register(metric!(
name: "mz_index_peek_result_sort_rows",
help: "Number of intermediate result rows sorted during peek collection, summed across sort operations.",
buckets: index_peek_row_buckets,
)),
index_peek_frontier_check_seconds: registry.register(metric!(
name: "mz_index_peek_frontier_check_seconds",
help: "Time checking trace frontiers.",
Expand Down Expand Up @@ -268,7 +283,9 @@ impl ComputeMetrics {
let index_peek_error_scan_seconds = self.index_peek_error_scan_seconds.clone();
let index_peek_cursor_setup_seconds = self.index_peek_cursor_setup_seconds.clone();
let index_peek_row_iteration_seconds = self.index_peek_row_iteration_seconds.clone();
let index_peek_row_iteration_rows = self.index_peek_row_iteration_rows.clone();
let index_peek_result_sort_seconds = self.index_peek_result_sort_seconds.clone();
let index_peek_result_sort_rows = self.index_peek_result_sort_rows.clone();
let index_peek_frontier_check_seconds = self.index_peek_frontier_check_seconds.clone();
let index_peek_row_collection_seconds = self.index_peek_row_collection_seconds.clone();
let replica_expiration_timestamp_seconds = self
Expand All @@ -295,7 +312,9 @@ impl ComputeMetrics {
index_peek_error_scan_seconds,
index_peek_cursor_setup_seconds,
index_peek_row_iteration_seconds,
index_peek_row_iteration_rows,
index_peek_result_sort_seconds,
index_peek_result_sort_rows,
index_peek_frontier_check_seconds,
index_peek_row_collection_seconds,
replica_expiration_timestamp_seconds,
Expand Down Expand Up @@ -337,8 +356,12 @@ pub struct WorkerMetrics {
pub(crate) index_peek_cursor_setup_seconds: Histogram,
/// Histogram of index peek row iteration durations.
pub(crate) index_peek_row_iteration_seconds: Histogram,
/// Histogram of index peek rows processed by the result iterator.
pub(crate) index_peek_row_iteration_rows: Histogram,
/// Histogram of index peek result sort durations.
pub(crate) index_peek_result_sort_seconds: Histogram,
/// Histogram of index peek rows sorted across all result sort operations.
pub(crate) index_peek_result_sort_rows: Histogram,
/// Histogram of index peek frontier check durations.
pub(crate) index_peek_frontier_check_seconds: Histogram,
/// Histogram of index peek row collection construction durations.
Expand Down
Loading