metrics: fix worker_steal_count test hanging (#6327)

This commit is contained in:
Alice Ryhl 2024-02-05 16:59:04 +01:00 committed by GitHub
parent fbdf539ac2
commit 47a5fe3a12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -181,7 +181,7 @@ fn worker_steal_count() {
// We use a blocking channel to backup one worker thread.
use std::sync::mpsc::channel;
let rt = threaded();
let rt = threaded_no_lifo();
let metrics = rt.metrics();
rt.block_on(async {
@ -190,14 +190,12 @@ fn worker_steal_count() {
// Move to the runtime.
tokio::spawn(async move {
// Spawn the task that sends to the channel
//
// Since the lifo slot is disabled, this task is stealable.
tokio::spawn(async move {
tx.send(()).unwrap();
});
// Spawn a task that bumps the previous task out of the "next
// scheduled" slot.
tokio::spawn(async {});
// Blocking receive on the channel.
rx.recv().unwrap();
})
@ -729,6 +727,15 @@ fn threaded() -> Runtime {
.unwrap()
}
fn threaded_no_lifo() -> Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.disable_lifo_slot()
.enable_all()
.build()
.unwrap()
}
fn us(n: u64) -> Duration {
Duration::from_micros(n)
}