Skip to content

Commit f6c55e5

Browse files
BugenZhaozwang28
authored andcommitted
feat: enable verbose await-tree by default in production (#10144)
Signed-off-by: Bugen Zhao <[email protected]>
1 parent 2996b9a commit f6c55e5

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
@@ -417,12 +417,27 @@ pub struct FileCacheConfig {
417417
pub unrecognized: Unrecognized<Self>,
418418
}
419419

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

428443
serde_with::with_prefix!(streaming_prefix "stream_");
@@ -716,7 +731,7 @@ mod default {
716731
}
717732

718733
pub fn async_stack_trace() -> AsyncStackTraceOption {
719-
AsyncStackTraceOption::On
734+
AsyncStackTraceOption::default()
720735
}
721736

722737
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
@@ -36,7 +36,7 @@ batch_chunk_size = 1024
3636
[streaming]
3737
in_flight_barrier_nums = 10000
3838
enable_jaeger_tracing = false
39-
async_stack_trace = "On"
39+
async_stack_trace = "ReleaseVerbose"
4040
unique_user_stream_errors = 10
4141

4242
[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};
@@ -36,6 +37,7 @@ pub struct UdfExpression {
3637
arg_schema: SchemaRef,
3738
client: Arc<ArrowFlightUdfClient>,
3839
identifier: String,
40+
span: await_tree::Span,
3941
}
4042

4143
#[cfg(not(madsim))]
@@ -81,7 +83,11 @@ impl UdfExpression {
8183
let input =
8284
arrow_array::RecordBatch::try_new_with_options(self.arg_schema.clone(), columns, &opts)
8385
.expect("failed to build record batch");
84-
let output = self.client.call(&self.identifier, input).await?;
86+
let output = self
87+
.client
88+
.call(&self.identifier, input)
89+
.instrument_await(self.span.clone())
90+
.await?;
8591
if output.num_rows() != vis.len() {
8692
bail!(
8793
"UDF returned {} rows, but expected {}",
@@ -124,6 +130,7 @@ impl<'a> TryFrom<&'a ExprNode> for UdfExpression {
124130
arg_schema,
125131
client,
126132
identifier: udf.identifier.clone(),
133+
span: format!("expr_udf_call ({})", udf.identifier).into(),
127134
})
128135
}
129136
}

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)