tokio-rs / tokio

A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ...
https://tokio.rs
MIT License
26.49k stars 2.44k forks source link

Some unstable runtime metrics show up as stable in docs.rs #6745

Open xd009642 opened 1 month ago

xd009642 commented 1 month ago

In the tokio RuntimeMetrics docs the majority of metrics require --cfg=tokio_unstable. Howver, some also require a target architecture with 64 bit atomics. For metrics which require both of these features rustdoc only shows one of them. Linked is an example: docs.rs/tokio/latest/tokio/runtime/struct.RuntimeMetrics.html#method.spawned_tasks_count

Here it says "Available on target_has_atomic="64" only." But it should say something like "Only available with target_has_atomic="64" and tokio_unstable."

This is a replica of the issue I raised in rust doc https://github.com/rust-lang/rust/issues/128563 . This is also extra misleading as number of workers has been stabilised so it's no longer the case that all metrics are unstable.

xd009642 commented 1 month ago

So there was a response on the rust issue, it's an issue tokio side because the nested config macros apply to the inner macro not the definitions inside

SarthakPaandey commented 1 month ago

As a newcomer looking to contribute to the project, I am interested in working on this issue.

I believe I can help clarify and update the documentation to accurately reflect the stability requirements for metrics that depend on both --cfg=tokio_unstable and target_has_atomic="64".

Could @Darksonn please assign me this task and guide me on how I can get started with this task? Any pointers on where to look for relevant code or documentation files would be greatly appreciated.

Darksonn commented 1 month ago

The relevant file is tokio/src/runtime/metrics/runtime.rs. The cfg_* macros are defined in tokio/src/macros/cfg.rs.

The problem seems to be that combining multiple cfg_* macros does not work properly in the docs. Anything inside cfg_a! { cfg_b! { ... } } will appear in the documentation as-if it only requires b and not a.

You are very welcome to reach out to me on the Tokio discord to discuss further.

SarthakPaandey commented 1 month ago

what is the Tokio discord channel link?

SarthakPaandey commented 1 month ago

In the documentation of runtime.rs I am not able to see the Available portion where would i be able to find that @Darksonn . Could you please guide?

Darksonn commented 1 month ago

The link is: https://discord.gg/tokio

SarthakPaandey commented 1 month ago

@Darksonn, I’ve created a PR to address the documentation issue by adding comments to runtime.rs to describe the dependencies more clearly. You can find the PR [here.] The comments provide additional context regarding the dependencies required for certain metrics and how they should be represented in the documentation. Please review the PR and let me know if there are any further adjustments needed. Kindly merge it for now so that users can understand that it requires both. Thanks!