mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
Merge tag 'tokio-1.45.1'
This commit is contained in:
commit
98f527f42d
@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
tokio = { version = "1.45.0", features = ["full"] }
|
||||
tokio = { version = "1.45.1", features = ["full"] }
|
||||
```
|
||||
Then, on your main.rs:
|
||||
|
||||
|
@ -1,3 +1,15 @@
|
||||
# 1.45.1 (May 24th, 2025)
|
||||
|
||||
This fixes a regression on the wasm32-unknown-unknown target, where code that
|
||||
previously did not panic due to calls to `Instant::now()` started failing. This
|
||||
is due to the stabilization of the first time-based metric.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Disable time-based metrics on wasm32-unknown-unknown ([#7322])
|
||||
|
||||
[#7322]: https://github.com/tokio-rs/tokio/pull/7322
|
||||
|
||||
# 1.45.0 (May 5th, 2025)
|
||||
|
||||
### Added
|
||||
|
@ -6,7 +6,7 @@ name = "tokio"
|
||||
# - README.md
|
||||
# - Update CHANGELOG.md.
|
||||
# - Create "v1.x.y" git tag.
|
||||
version = "1.45.0"
|
||||
version = "1.45.1"
|
||||
edition = "2021"
|
||||
rust-version = "1.70"
|
||||
authors = ["Tokio Contributors <team@tokio.rs>"]
|
||||
|
@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
tokio = { version = "1.45.0", features = ["full"] }
|
||||
tokio = { version = "1.45.1", features = ["full"] }
|
||||
```
|
||||
Then, on your main.rs:
|
||||
|
||||
|
@ -12,7 +12,7 @@ pub(crate) struct MetricsBatch {
|
||||
busy_duration_total: u64,
|
||||
|
||||
/// Instant at which work last resumed (continued after park).
|
||||
processing_scheduled_tasks_started_at: Instant,
|
||||
processing_scheduled_tasks_started_at: Option<Instant>,
|
||||
|
||||
/// Number of times the worker parked.
|
||||
park_count: u64,
|
||||
@ -67,17 +67,17 @@ cfg_unstable_metrics! {
|
||||
|
||||
impl MetricsBatch {
|
||||
pub(crate) fn new(worker_metrics: &WorkerMetrics) -> MetricsBatch {
|
||||
let now = Instant::now();
|
||||
Self::new_unstable(worker_metrics, now)
|
||||
let maybe_now = now();
|
||||
Self::new_unstable(worker_metrics, maybe_now)
|
||||
}
|
||||
|
||||
cfg_metrics_variant! {
|
||||
stable: {
|
||||
#[inline(always)]
|
||||
fn new_unstable(_worker_metrics: &WorkerMetrics, now: Instant) -> MetricsBatch {
|
||||
fn new_unstable(_worker_metrics: &WorkerMetrics, maybe_now: Option<Instant>) -> MetricsBatch {
|
||||
MetricsBatch {
|
||||
busy_duration_total: 0,
|
||||
processing_scheduled_tasks_started_at: now,
|
||||
processing_scheduled_tasks_started_at: maybe_now,
|
||||
park_count: 0,
|
||||
park_unpark_count: 0,
|
||||
}
|
||||
@ -85,7 +85,16 @@ impl MetricsBatch {
|
||||
},
|
||||
unstable: {
|
||||
#[inline(always)]
|
||||
fn new_unstable(worker_metrics: &WorkerMetrics, now: Instant) -> MetricsBatch {
|
||||
fn new_unstable(worker_metrics: &WorkerMetrics, maybe_now: Option<Instant>) -> MetricsBatch {
|
||||
let poll_timer = maybe_now.and_then(|now| {
|
||||
worker_metrics
|
||||
.poll_count_histogram
|
||||
.as_ref()
|
||||
.map(|worker_poll_counts| PollTimer {
|
||||
poll_counts: HistogramBatch::from_histogram(worker_poll_counts),
|
||||
poll_started_at: now,
|
||||
})
|
||||
});
|
||||
MetricsBatch {
|
||||
park_count: 0,
|
||||
park_unpark_count: 0,
|
||||
@ -97,13 +106,8 @@ impl MetricsBatch {
|
||||
local_schedule_count: 0,
|
||||
overflow_count: 0,
|
||||
busy_duration_total: 0,
|
||||
processing_scheduled_tasks_started_at: now,
|
||||
poll_timer: worker_metrics.poll_count_histogram.as_ref().map(
|
||||
|worker_poll_counts| PollTimer {
|
||||
poll_counts: HistogramBatch::from_histogram(worker_poll_counts),
|
||||
poll_started_at: now,
|
||||
},
|
||||
),
|
||||
processing_scheduled_tasks_started_at: maybe_now,
|
||||
poll_timer,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -186,14 +190,18 @@ impl MetricsBatch {
|
||||
|
||||
/// Start processing a batch of tasks
|
||||
pub(crate) fn start_processing_scheduled_tasks(&mut self) {
|
||||
self.processing_scheduled_tasks_started_at = Instant::now();
|
||||
self.processing_scheduled_tasks_started_at = now();
|
||||
}
|
||||
|
||||
/// Stop processing a batch of tasks
|
||||
pub(crate) fn end_processing_scheduled_tasks(&mut self) {
|
||||
let busy_duration = self.processing_scheduled_tasks_started_at.elapsed();
|
||||
if let Some(processing_scheduled_tasks_started_at) =
|
||||
self.processing_scheduled_tasks_started_at
|
||||
{
|
||||
let busy_duration = processing_scheduled_tasks_started_at.elapsed();
|
||||
self.busy_duration_total += duration_as_u64(busy_duration);
|
||||
}
|
||||
}
|
||||
|
||||
cfg_metrics_variant! {
|
||||
stable: {
|
||||
@ -279,3 +287,17 @@ cfg_rt_multi_thread! {
|
||||
pub(crate) fn duration_as_u64(dur: Duration) -> u64 {
|
||||
u64::try_from(dur.as_nanos()).unwrap_or(u64::MAX)
|
||||
}
|
||||
|
||||
/// Gate unsupported time metrics for `wasm32-unknown-unknown`
|
||||
/// <https://github.com/tokio-rs/tokio/issues/7319>
|
||||
fn now() -> Option<Instant> {
|
||||
if cfg!(all(
|
||||
target_arch = "wasm32",
|
||||
target_os = "unknown",
|
||||
target_vendor = "unknown"
|
||||
)) {
|
||||
None
|
||||
} else {
|
||||
Some(Instant::now())
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user