Skip to content

Commit 7988f99

Browse files
committed
chore(cubestore): Upgrade DF: Add planning metrics
1 parent 164afff commit 7988f99

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

rust/cubestore/cubestore/src/app_metrics.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ pub static DATA_QUERIES_CACHE_SIZE: Gauge = metrics::gauge("cs.sql.query.data.ca
1515
// Approximate total weighted size of entries in this cache.
1616
pub static DATA_QUERIES_CACHE_WEIGHT: Gauge = metrics::gauge("cs.sql.query.data.cache.weight");
1717
pub static DATA_QUERY_TIME_MS: Histogram = metrics::histogram("cs.sql.query.data.ms");
18+
pub static DATA_QUERY_LOGICAL_PLAN_OPTIMIZE_TIME_MS: Histogram = metrics::histogram("cs.sql.query.data.planning.logical_plan_optimize.ms");
19+
pub static DATA_QUERY_CHOOSE_INDEX_AND_WORKERS_TIME_MS: Histogram = metrics::histogram("cs.sql.query.data.planning.choose_index_and_workers.ms");
20+
pub static DATA_QUERY_CREATE_ROUTER_PHYSICAL_PLAN_MS: Histogram = metrics::histogram("cs.sql.query.data.planning.router_plan.ms");
21+
pub static DATA_QUERY_CREATE_WORKER_PHYSICAL_PLAN_MS: Histogram = metrics::histogram("cs.sql.query.data.planning.worker_plan.ms");
22+
1823
/// Incoming SQL queries that only read metadata or do trivial computations.
1924
pub static META_QUERIES: Counter = metrics::counter("cs.sql.query.meta");
2025
pub static META_QUERY_TIME_MS: Histogram = metrics::histogram("cs.sql.query.meta.ms");

rust/cubestore/cubestore/src/queryplanner/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ impl QueryPlanner for QueryPlannerImpl {
168168
)
169169
);
170170

171+
let logical_plan_optimize_time = SystemTime::now();
171172
logical_plan = state.optimize(&logical_plan)?;
173+
app_metrics::DATA_QUERY_LOGICAL_PLAN_OPTIMIZE_TIME_MS.report(logical_plan_optimize_time.elapsed()?.as_millis() as i64);
172174
trace!(
173175
"Logical Plan: {}",
174176
pp_plan_ext(
@@ -185,6 +187,7 @@ impl QueryPlanner for QueryPlannerImpl {
185187
);
186188

187189
let plan = if SerializedPlan::is_data_select_query(&logical_plan) {
190+
let choose_index_ext_start = SystemTime::now();
188191
let (logical_plan, meta) = choose_index_ext(
189192
logical_plan,
190193
&self.meta_store.as_ref(),
@@ -196,6 +199,7 @@ impl QueryPlanner for QueryPlannerImpl {
196199
&logical_plan,
197200
&meta.multi_part_subtree,
198201
)?;
202+
app_metrics::DATA_QUERY_CHOOSE_INDEX_AND_WORKERS_TIME_MS.report(choose_index_ext_start.elapsed()?.as_millis() as i64);
199203
QueryPlan::Select(
200204
PreSerializedPlan::try_new(logical_plan, meta, trace_obj)?,
201205
workers,

rust/cubestore/cubestore/src/queryplanner/query_executor.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,14 @@ impl QueryExecutor for QueryExecutorImpl {
171171
) -> Result<(SchemaRef, Vec<RecordBatch>), CubeError> {
172172
let collect_span = tracing::span!(tracing::Level::TRACE, "collect_physical_plan");
173173
let trace_obj = plan.trace_obj();
174+
let create_router_physical_plan_time = SystemTime::now();
174175
let (physical_plan, logical_plan) = self.router_plan(plan, cluster).await?;
176+
app_metrics::DATA_QUERY_CREATE_ROUTER_PHYSICAL_PLAN_MS.report(create_router_physical_plan_time.elapsed()?.as_millis() as i64);
175177
let split_plan = physical_plan;
176178

177179
trace!(
178180
"Router Query Physical Plan: {}",
179-
pp_phys_plan(split_plan.as_ref())
181+
pp_phys_plan_ext(split_plan.as_ref(), &PPOptions{ traverse_past_clustersend: true, ..PPOptions::show_most() })
180182
);
181183

182184
let flags = PhysicalPlanFlags::with_execution_plan(split_plan.as_ref());
@@ -237,6 +239,7 @@ impl QueryExecutor for QueryExecutorImpl {
237239
chunk_id_to_record_batches: HashMap<u64, Vec<RecordBatch>>,
238240
) -> Result<(SchemaRef, Vec<RecordBatch>, usize), CubeError> {
239241
let data_loaded_size = DataLoadedSize::new();
242+
let create_worker_physical_plan_time = SystemTime::now();
240243
let (physical_plan, logical_plan) = self
241244
.worker_plan(
242245
plan,
@@ -246,6 +249,8 @@ impl QueryExecutor for QueryExecutorImpl {
246249
Some(data_loaded_size.clone()),
247250
)
248251
.await?;
252+
app_metrics::DATA_QUERY_CREATE_WORKER_PHYSICAL_PLAN_MS.report(create_worker_physical_plan_time.elapsed()?.as_millis() as i64);
253+
249254
let worker_plan;
250255
let max_batch_rows;
251256
if let Some((p, s)) = get_worker_plan(&physical_plan) {
@@ -260,7 +265,7 @@ impl QueryExecutor for QueryExecutorImpl {
260265

261266
trace!(
262267
"Partition Query Physical Plan: {}",
263-
pp_phys_plan(worker_plan.as_ref())
268+
pp_phys_plan_ext(worker_plan.as_ref(), &PPOptions::show_most())
264269
);
265270

266271
let execution_time = SystemTime::now();

0 commit comments

Comments
 (0)