-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tokio: Add initial io driver metrics #4507
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
target | ||
Cargo.lock | ||
|
||
.cargo/config.toml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//! This file contains mocks of the metrics types used in the I/O driver. | ||
//! | ||
//! The reason these mocks don't live in `src/runtime/mock.rs` is because | ||
//! these need to be available in the case when `net` is enabled but | ||
//! `rt` is not. | ||
|
||
cfg_not_rt_and_metrics! { | ||
#[derive(Default)] | ||
pub(crate) struct IoDriverMetrics {} | ||
|
||
impl IoDriverMetrics { | ||
pub(crate) fn incr_fd_count(&self) {} | ||
pub(crate) fn dec_fd_count(&self) {} | ||
pub(crate) fn incr_ready_count_by(&self, _amt: u64) {} | ||
} | ||
} | ||
|
||
cfg_rt! { | ||
cfg_metrics! { | ||
pub(crate) use crate::runtime::IoDriverMetrics; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -483,7 +483,7 @@ pub(crate) use self::doc::winapi; | |
|
||
#[cfg(all(not(docsrs), windows, feature = "net"))] | ||
#[allow(unused)] | ||
pub(crate) use ::winapi; | ||
pub(crate) use winapi; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think rustfmt did it? I didn't manually change it but I don't think it affects anything since this got updated in 2018 edition iirc |
||
|
||
cfg_macros! { | ||
/// Implementation detail of the `select!` macro. This macro is **not** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#![cfg_attr(not(feature = "net"), allow(dead_code))] | ||
|
||
use std::sync::atomic::{AtomicU64, Ordering::Relaxed}; | ||
|
||
#[derive(Default)] | ||
pub(crate) struct IoDriverMetrics { | ||
pub(super) fd_registered_count: AtomicU64, | ||
pub(super) fd_deregistered_count: AtomicU64, | ||
pub(super) ready_count: AtomicU64, | ||
} | ||
|
||
impl IoDriverMetrics { | ||
pub(crate) fn incr_fd_count(&self) { | ||
let prev = self.fd_registered_count.load(Relaxed); | ||
let new = prev.wrapping_add(1); | ||
self.fd_registered_count.store(new, Relaxed); | ||
} | ||
|
||
pub(crate) fn dec_fd_count(&self) { | ||
let prev = self.fd_deregistered_count.load(Relaxed); | ||
let new = prev.wrapping_add(1); | ||
self.fd_deregistered_count.store(new, Relaxed); | ||
} | ||
|
||
pub(crate) fn incr_ready_count_by(&self, amt: u64) { | ||
let prev = self.ready_count.load(Relaxed); | ||
let new = prev.wrapping_add(amt); | ||
self.ready_count.store(new, Relaxed); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fwiw, calling
self.inner()
does an arc bump anyway. I probably wouldn't bother w/ the closure, but it isn't a bit deal.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, plan to refactor with removal of weak from io driver handle.