Skip to content

Commit a504c40

Browse files
authored
feat: enable verbose await-tree by default in production (#10144)
Signed-off-by: Bugen Zhao <[email protected]>
1 parent 2e33fef commit a504c40

File tree

13 files changed

+46
-15
lines changed

13 files changed

+46
-15
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ license = "Apache-2.0"
5858
repository = "https://github.com/risingwavelabs/risingwave"
5959

6060
[workspace.dependencies]
61+
await-tree = "0.1.1"
6162
aws-config = { version = "0.51", default-features = false, features = ["rt-tokio", "native-tls"] }
6263
aws-sdk-kinesis = { version = "0.21", default-features = false, features = ["rt-tokio", "native-tls"] }
6364
aws-sdk-s3 = { version = "0.21", default-features = false, features = ["rt-tokio","native-tls"] }

src/common/src/config.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,27 @@ pub struct FileCacheConfig {
420420
pub unrecognized: Unrecognized<Self>,
421421
}
422422

423-
#[derive(Debug, Default, Clone, ValueEnum, Serialize, Deserialize)]
423+
#[derive(Debug, Default, Clone, Copy, ValueEnum, Serialize, Deserialize)]
424424
pub enum AsyncStackTraceOption {
425+
/// Disabled.
425426
Off,
426-
#[default]
427+
/// Enabled with basic instruments.
427428
On,
428-
Verbose,
429+
/// Enabled with extra verbose instruments in release build.
430+
/// Behaves the same as `on` in debug build due to performance concern.
431+
#[default]
432+
#[clap(alias = "verbose")]
433+
ReleaseVerbose,
434+
}
435+
436+
impl AsyncStackTraceOption {
437+
pub fn is_verbose(self) -> Option<bool> {
438+
match self {
439+
Self::Off => None,
440+
Self::On => Some(false),
441+
Self::ReleaseVerbose => Some(!cfg!(debug_assertions)),
442+
}
443+
}
429444
}
430445

431446
serde_with::with_prefix!(streaming_prefix "stream_");
@@ -723,7 +738,7 @@ mod default {
723738
}
724739

725740
pub fn async_stack_trace() -> AsyncStackTraceOption {
726-
AsyncStackTraceOption::On
741+
AsyncStackTraceOption::default()
727742
}
728743

729744
pub fn unique_user_stream_errors() -> usize {

src/compute/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ normal = ["workspace-hack"]
1616
[dependencies]
1717
anyhow = "1"
1818
async-trait = "0.1"
19-
await-tree = "0.1.1"
19+
await-tree = { workspace = true }
2020
clap = { version = "4", features = ["derive"] }
2121
either = "1"
2222
futures = { version = "0.3", default-features = false, features = ["alloc"] }

src/compute/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ pub async fn compute_node_serve(
263263
let await_tree_config = match &config.streaming.async_stack_trace {
264264
AsyncStackTraceOption::Off => None,
265265
c => await_tree::ConfigBuilder::default()
266-
.verbose(matches!(c, AsyncStackTraceOption::Verbose))
266+
.verbose(c.is_verbose().unwrap())
267267
.build()
268268
.ok(),
269269
};

src/config/example.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ batch_chunk_size = 1024
3737
[streaming]
3838
in_flight_barrier_nums = 10000
3939
enable_jaeger_tracing = false
40-
async_stack_trace = "On"
40+
async_stack_trace = "ReleaseVerbose"
4141
unique_user_stream_errors = 10
4242

4343
[streaming.developer]

src/expr/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ arrow-array = "36"
2121
arrow-schema = "36"
2222
async-trait = "0.1"
2323
auto_enums = "0.8"
24+
await-tree = { workspace = true }
2425
chrono = { version = "0.4", default-features = false, features = ["clock", "std"] }
2526
chrono-tz = { version = "0.7", features = ["case-insensitive"] }
2627
ctor = "0.1"

src/expr/src/expr/expr_udf.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::convert::TryFrom;
1717
use std::sync::{Arc, LazyLock, Mutex, Weak};
1818

1919
use arrow_schema::{Field, Schema, SchemaRef};
20+
use await_tree::InstrumentAwait;
2021
use risingwave_common::array::{ArrayImpl, ArrayRef, DataChunk};
2122
use risingwave_common::row::OwnedRow;
2223
use risingwave_common::types::{DataType, Datum};
@@ -35,6 +36,7 @@ pub struct UdfExpression {
3536
arg_schema: SchemaRef,
3637
client: Arc<ArrowFlightUdfClient>,
3738
identifier: String,
39+
span: await_tree::Span,
3840
}
3941

4042
#[cfg(not(madsim))]
@@ -80,7 +82,11 @@ impl UdfExpression {
8082
let input =
8183
arrow_array::RecordBatch::try_new_with_options(self.arg_schema.clone(), columns, &opts)
8284
.expect("failed to build record batch");
83-
let output = self.client.call(&self.identifier, input).await?;
85+
let output = self
86+
.client
87+
.call(&self.identifier, input)
88+
.instrument_await(self.span.clone())
89+
.await?;
8490
if output.num_rows() != vis.len() {
8591
bail!(
8692
"UDF returned {} rows, but expected {}",
@@ -121,6 +127,7 @@ impl<'a> TryFrom<&'a ExprNode> for UdfExpression {
121127
arg_schema,
122128
client,
123129
identifier: udf.identifier.clone(),
130+
span: format!("expr_udf_call ({})", udf.identifier).into(),
124131
})
125132
}
126133
}

src/object_store/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repository = { workspace = true }
1010

1111
[dependencies]
1212
async-trait = "0.1"
13-
await-tree = "0.1.1"
13+
await-tree = { workspace = true }
1414
aws-config = { workspace = true }
1515
aws-sdk-s3 = { version = "0.2.15", package = "madsim-aws-sdk-s3" }
1616
aws-smithy-http = { workspace = true }

src/storage/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ normal = ["workspace-hack"]
1717
arc-swap = "1"
1818
async-trait = "0.1"
1919
auto_enums = { version = "0.8", features = ["futures03"] }
20-
await-tree = "0.1.1"
20+
await-tree = { workspace = true }
2121
bytes = { version = "1", features = ["serde"] }
2222
crossbeam = "0.8.1"
2323
dashmap = { version = "5", default-features = false }

src/storage/src/monitor/monitored_store.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,11 @@ impl<S: LocalStateStore> LocalStateStore for MonitoredStateStore<S> {
185185
.may_exist_duration
186186
.with_label_values(&[table_id_label.as_str()])
187187
.start_timer();
188-
let res = self.inner.may_exist(key_range, read_options).await;
188+
let res = self
189+
.inner
190+
.may_exist(key_range, read_options)
191+
.verbose_instrument_await("store_may_exist")
192+
.await;
189193
timer.observe_duration();
190194
res
191195
}
@@ -217,7 +221,9 @@ impl<S: LocalStateStore> LocalStateStore for MonitoredStateStore<S> {
217221

218222
fn flush(&mut self, delete_ranges: Vec<(Bound<Bytes>, Bound<Bytes>)>) -> Self::FlushFuture<'_> {
219223
// TODO: collect metrics
220-
self.inner.flush(delete_ranges)
224+
self.inner
225+
.flush(delete_ranges)
226+
.verbose_instrument_await("store_flush")
221227
}
222228

223229
fn epoch(&self) -> u64 {
@@ -264,7 +270,7 @@ impl<S: StateStore> StateStore for MonitoredStateStore<S> {
264270
let sync_result = self
265271
.inner
266272
.sync(epoch)
267-
.instrument_await("store_await_sync")
273+
.instrument_await("store_sync")
268274
.await
269275
.inspect_err(|e| error!("Failed in sync: {:?}", e))?;
270276
timer.observe_duration();

src/stream/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ anyhow = "1"
1919
async-recursion = "1"
2020
async-stream = "0.3"
2121
async-trait = "0.1"
22-
await-tree = "0.1.1"
22+
await-tree = { workspace = true }
2323
bytes = "1"
2424
dyn-clone = "1"
2525
educe = "0.4"

src/utils/runtime/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ignored = ["workspace-hack"]
1515
normal = ["workspace-hack"]
1616

1717
[dependencies]
18-
await-tree = "0.1.1"
18+
await-tree = { workspace = true }
1919
console = "0.15"
2020
console-subscriber = "0.1.8"
2121
futures = { version = "0.3", default-features = false, features = ["alloc"] }

0 commit comments

Comments
 (0)