test: Improve tracking of slow tests (#10429)

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
This commit is contained in:
Andy LeisersonandConnor Fitzgerald authored and GitHub committed 2026-09-27 21:09:48 +00:00
1 parent babefc0d26
commit 2c3e503258
14 files changed
+122 -7

No files matched your search

+14 -2
View File
@@ -1,11 +1,23 @@
# None of our tests should take longer than 45s, and if they've gone 2x that,
# terminate them to prevent infinite run-on.
#
# The period is 15s rather than 45s only so that the log gets a liveness
# heartbeat every 15s; nextest prints a `SLOW` line once per period, and CI
# hosts that stall are hard to distinguish from slow tests without one.
# See <https://github.com/gfx-rs/wgpu/issues/9248>.
[profile.default]
default-filter = "!test(~oom_test)"
slow-timeout = { period = "45s", terminate-after = 2 }
slow-timeout = { period = "15s", terminate-after = 6 }
fail-fast = false
retries = 0
# Per-test start times and durations, kept as a CI artifact so that
# intermittent timeouts can be analyzed after the run logs expire (#9248).
[profile.default.junit]
path = "junit.xml"
store-success-output = false
store-failure-output = false
# Use two threads for tests with "2 threads" in their name
[[profile.default.overrides]]
filter = 'test(~2_threads) | test(~2 threads)'
@@ -50,7 +62,7 @@ filter = 'test(clear_texture) | test(clear_buffer_range_respected) | test(compil
[profile.wasm]
default-filter = "test([wasm])"
slow-timeout = { period = "45s", terminate-after = 2 }
slow-timeout = { period = "15s", terminate-after = 6 }
fail-fast = false
retries = 0
@@ -0,0 +1,20 @@
name: "Sample host metrics"
description: "Start a background sampler that records host performance counters to a CSV."
inputs:
output:
description: "Path of the CSV file to write."
required: true
runs:
using: "composite"
steps:
- shell: pwsh
env:
INPUTS_OUTPUT: ${{ inputs.output }}
run: |
Start-Process pwsh -WindowStyle Hidden -ArgumentList @(
"-NoProfile"
"-File"
"${{ github.action_path }}/sample.ps1"
"-Output"
$env:INPUTS_OUTPUT
)
@@ -0,0 +1,37 @@
# Appends one line of host performance counters to a CSV every few seconds
# until the sample budget runs out or the job ends and the runner kills us.
#
# Windows CI intermittently stops making progress for a minute or more at a
# time, which kills whichever tests happen to be running. These samples let a
# timeout be correlated with CPU, memory or disk pressure on the host.
# https://github.com/gfx-rs/wgpu/issues/9248
param(
[Parameter(Mandatory = $true)] [string] $Output,
[int] $IntervalSeconds = 5,
[int] $Samples = 400
)
$ErrorActionPreference = "Continue"
$counters = @(
"\Processor(_Total)\% Processor Time"
"\Memory\Available MBytes"
"\Memory\Pages/sec"
"\PhysicalDisk(_Total)\Current Disk Queue Length"
"\System\Processes"
)
Set-Content -Path $Output -Encoding ascii `
-Value "time,cpu_pct,avail_mb,pages_per_sec,disk_queue,processes"
for ($i = 0; $i -lt $Samples; $i++) {
$now = (Get-Date).ToUniversalTime().ToString("o")
try {
$values = (Get-Counter -Counter $counters -ErrorAction Stop).CounterSamples |
ForEach-Object { [math]::Round($_.CookedValue, 1) }
Add-Content -Path $Output -Value "$now,$($values -join ',')"
} catch {
Add-Content -Path $Output -Value "$now,,,,,"
}
Start-Sleep -Seconds $IntervalSeconds
}
+22
View File
@@ -746,6 +746,16 @@ jobs:
# Delete snapshots so we can ensure there aren't any excess output files.
rm -r naga/tests/out
# Windows CI intermittently stops making progress for a minute or more at
# a time, which kills whichever tests happen to be running. Sample the
# host counters so that a timeout can be correlated with CPU, memory or
# disk pressure. https://github.com/gfx-rs/wgpu/issues/9248
- name: (Windows) Start host metrics sampler
if: matrix.os == 'windows-2022'
uses: $/.github/actions/sample-host-metrics
with:
output: host-metrics.csv
- name: Run tests
shell: bash
run: |
@@ -766,6 +776,18 @@ jobs:
**/*-actual.png
**/*-difference.png
# Per-test timings and the host counter samples outlive the run logs,
# which is what we need to chase intermittent timeouts (#9248).
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
name: Upload test timings
if: always() # We want timings even if the tests fail.
with:
name: test-timings-${{ matrix.os }}
path: |
**/nextest/*/junit.xml
host-metrics.csv
if-no-files-found: warn
# Print GPU configuration so we can see what features were available during the test.
- name: Print GPU configurations
if: always() # We want this information even if the tests fail.
Generated
+1
View File
@@ -4816,6 +4816,7 @@ dependencies = [
"anyhow",
"bincode 2.0.1",
"bytemuck",
"env_logger",
"naga",
"naga-test",
"nanorand",
+3 -1
View File
@@ -135,7 +135,9 @@ codespan-reporting = { version = "0.13", default-features = false }
diff = "0.1"
document-features = "0.2.10"
encase = "0.13"
env_logger = { version = "0.11", default-features = false }
env_logger = { version = "0.11", default-features = false, features = [
"humantime",
] }
exhaust = "0.2"
fern = "0.7"
flume = "0.12"
+1
View File
@@ -26,6 +26,7 @@ unexpected_cfgs = { level = "warn", check-cfg = [
anyhow.workspace = true
bincode = { workspace = true, features = ["serde"] }
bytemuck.workspace = true
env_logger.workspace = true
naga = { workspace = true, features = [
"deserialize",
"serialize",
+5
View File
@@ -115,6 +115,11 @@ Other:
";
pub fn main(benchmarks: Vec<Benchmark>) {
// The benchmarks run as tests in CI, where they occasionally time out with
// no output at all to say where the time went. See
// <https://github.com/gfx-rs/wgpu/issues/9248>.
let _ = env_logger::builder().format_timestamp_millis().try_init();
let mut args = Arguments::from_env();
let help = args.contains(["-h", "--help"]);
+3
View File
@@ -76,6 +76,9 @@ fn init_logger() {
// of these default filters.
env_logger::builder()
.filter_level(log::LevelFilter::Info)
// Millisecond timestamps; see
// <https://github.com/gfx-rs/wgpu/issues/9248>.
.format_timestamp_millis()
.parse_default_env()
.init();
}
+2 -1
View File
@@ -212,7 +212,8 @@ impl Corpus {
#[cfg_attr(miri, ignore)]
#[test]
fn test_api() {
env_logger::init();
// Millisecond timestamps; see <https://github.com/gfx-rs/wgpu/issues/9248>.
env_logger::builder().format_timestamp_millis().init();
Corpus::run_from(PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/player/data/all.ron"))
}
+5 -1
View File
@@ -16,9 +16,13 @@ fn default_device_lost_callback(reason: wgpu::DeviceLostReason, message: String)
/// Initialize the logger for the test runner.
pub fn init_logger() {
// Millisecond timestamps, because second resolution is not enough to tell
// where the time goes when CI stalls. See
// <https://github.com/gfx-rs/wgpu/issues/9248>.
//
// We don't actually care if it fails
#[cfg(not(target_arch = "wasm32"))]
let _ = env_logger::try_init();
let _ = env_logger::builder().format_timestamp_millis().try_init();
#[cfg(target_arch = "wasm32")]
let _ = console_log::init_with_level(log::Level::Info);
}
+1 -1
View File
@@ -21,7 +21,7 @@ pub use init::initialize_html_canvas;
pub use self::image::ComparisonType;
pub use config::{GpuTestConfiguration, GpuTestInitializer};
pub use expectations::{FailureApplicationReasons, FailureBehavior, FailureCase, FailureReason};
pub use init::{initialize_adapter, initialize_device, initialize_instance};
pub use init::{init_logger, initialize_adapter, initialize_device, initialize_instance};
pub use macro_rules_attribute::apply;
pub use params::TestParameters;
pub use run::{execute_test, TestingContext};
+1 -1
View File
@@ -21,7 +21,7 @@ mod multi_instance {
#[test]
pub fn multi_instance() {
{
env_logger::init();
wgpu_test::init_logger();
// Sequential instances.
for _ in 0..3 {
+7
View File
@@ -87,6 +87,13 @@ pub fn run_tests(
&["nextest", "run"]
};
// Test concurrency, and therefore how much contention the tests see, follows
// the CPU count. See <https://github.com/gfx-rs/wgpu/issues/9248>.
match std::thread::available_parallelism() {
Ok(n) => log::info!("Host reports {n} logical CPUs"),
Err(e) => log::info!("Could not determine the host CPU count: {e}"),
}
log::info!("Generating .gpuconfig file based on gpus on the system");
// We use a test to generate the .gpuconfig file instead of using the cli directly