tokio-rs / async-backtrace Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
see title
Shall there be some compile-time knob that renders all async_backtrace::framed
annotations no-ops? (and makes backtrace
and other functions return dummy values).
Something like log's or tracing's max_level_off
/ release_max_level_off
.
Right now, this crate uses fine-grained locking. A distinct mutex is locked and released twice for each distinct backtraced future in its tree. This approach easily supports dumping traces from within backtraced tasks; e.g.:
#[tokio::main]
async fn main() {
dump().await;
}
#[backtrace]
async fn dump() {
async_backtrace::dump()
}
With a bit of refactoring, I can make it so only one mutex is locked and released once, for the entire future tree, but it comes at the cost of easily supporting the above scenario deadlocking.
The following code generates a clippy warning when run with Rust 1.70:
#[async_backtrace::framed]
pub async fn test() -> impl Stream<Item = T> {
stream::empty()
}
output:
warning: variable declared with type underscore
--> zettaobject/src/object_based_log.rs:317:28
|
317 | pub async fn test() -> impl Stream<Item = T> {
| ^^^^
|
help: remove the explicit type `_` declaration
--> zettaobject/src/object_based_log.rs:317:32
|
317 | pub async fn test() -> impl Stream<Item = T> {
| ^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_with_type_underscore
The warning doesn't make any sense because it's talking about code generated by the framed
macro:
pub async fn test() -> impl Stream<Item = T> {
async_backtrace::frame!(async move {
{
#[allow(
unreachable_code,
clippy::diverging_sub_expression,
clippy::let_unit_value,
clippy::empty_loop
)]
if false {
let __backtrace_attr_fake_return: _ = loop {}; // <= type is _
return __backtrace_attr_fake_return;
}
{
stream::empty()
}
}
})
.await
}
Maybe the macro needs to suppress the new warning?
Hi, thanks for creating this lib! OpenDAL is working on for adding native integration with this lib to allow users to dump the async backtrace: apache/opendal#2765.
But we met a problem that we have some trait like AsyncRead
returns Poll<T>
. Can we add frame for them?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.