-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tokio: Add initial io driver metrics
- Loading branch information
1 parent
43c224f
commit ffa5add
Showing
11 changed files
with
191 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
target | ||
Cargo.lock | ||
|
||
.cargo/config.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#![cfg_attr(not(feature = "net"), allow(dead_code))] | ||
|
||
use std::sync::atomic::{AtomicU64, Ordering::Relaxed}; | ||
|
||
#[derive(Default)] | ||
pub(crate) struct IoDriverMetrics { | ||
pub(super) fd_count: AtomicU64, | ||
pub(super) ready_count: AtomicU64, | ||
} | ||
|
||
impl IoDriverMetrics { | ||
pub(crate) fn incr_fd_count(&self) { | ||
let prev = self.fd_count.load(Relaxed); | ||
let new = prev.wrapping_add(1); | ||
self.fd_count.store(new, Relaxed); | ||
} | ||
|
||
pub(crate) fn dec_fd_count(&self) { | ||
let prev = self.fd_count.load(Relaxed); | ||
let new = prev.wrapping_sub(1); | ||
self.fd_count.store(new, Relaxed); | ||
} | ||
|
||
pub(crate) fn incr_ready_count_by(&self, amt: u64) { | ||
let prev = self.fd_count.load(Relaxed); | ||
let new = prev.wrapping_add(amt); | ||
self.ready_count.store(new, Relaxed); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters