Files
RustPython/tests/benchmark_scripts.rs
T
Jeong, YunWon 0c5a47bae5 Unskip MP tests and shrink the flaky MP CI list (#8731)
* Unskip multiprocessing RLock repr test

Assisted-by: Grok:4.6

* Drop stable modules from the flaky MP CI list

Assisted-by: Grok:4.6

* Keep only multiprocessing fork on the flaky MP list

Assisted-by: Grok:4.6

* Drop gc_collect bench and unbreak two CI jobs

Remove benches/benchmarks/gc_collect.py so CodSpeed no longer
includes that execution benchmark.

On Windows, run test_multiprocessing_spawn serially; the
parallel snippets job hit a regrtest worker temp-dir error
while that suite was still running.

Install cargo-shear from a pinned prebuilt binary so the job
does not fall back to compiling 1.13.4 from source.

Assisted-by: Grok:4.6

* Unskip hang tests that now pass under -m test

Drop the RustPython hang skips on interpreter shutdown,
submit-after-shutdown, and connection pickling after they
passed with rustpython -m test.

Remove the unused expectedFailureIf around killpg on the
resource tracker deadlock test; os.killpg is present.

Pass matrix flaky-MP extras through the job environment
instead of interpolating them into the run script.

Assisted-by: Grok:4.6

* Restore hang skips and isolate spawn on CI

Put test_multiprocessing_spawn and
test_multiprocessing_forkserver back on the serial flaky MP
list. Ubuntu timed out in spawn test_notify_all under -j, and
forkserver.test_processes needed a rerun.

Restore the hang skips on interpreter shutdown, submit-after
shutdown, and connection pickling.

Assisted-by: Grok:4.6
2026-09-19 10:38:05 +09:00

84 lines
2.5 KiB
Rust

// cspell:ignore pyperformance nqueens pidigits
use rustpython::{InterpreterBuilder, InterpreterBuilderExt};
use std::{fs, path::Path};
const PYPERFORMANCE_BENCHMARKS: &[&str] = &[
"base64.py",
"decimal_factorial.py",
"deepcopy.py",
"deltablue.py",
"float.py",
"gc_traversal.py",
"generators.py",
"json_dumps.py",
"nqueens.py",
"pickle.py",
"pidigits.py",
"regex_effbot.py",
"richards.py",
"unpickle.py",
];
#[test]
fn pyperformance_benchmarks_run_in_rustpython() {
let benchmark_dir = Path::new("benches/benchmarks");
for name in PYPERFORMANCE_BENCHMARKS {
let path = benchmark_dir.join(name);
let source = fs::read_to_string(&path)
.unwrap_or_else(|err| panic!("failed to read {}: {err}", path.display()));
let source_path = path.to_string_lossy();
InterpreterBuilder::new()
.init_stdlib()
.interpreter()
.enter(|vm| {
let code = vm
.compile(&source, rustpython::vm::compiler::Mode::Exec, &*source_path)
.unwrap_or_else(|err| panic!("failed to compile {}: {err}", path.display()));
let scope = vm.new_scope_with_builtins();
if let Err(err) = vm.run_code_obj(code, scope) {
vm.print_exception(err);
panic!("failed to execute {}", path.display());
}
});
}
}
#[test]
fn pyperformance_benchmarks_restore_interpreter_state() {
let source = r#"
import decimal
import pickle
import sys
missing = object()
pickle_module = sys.modules.get("pickle", missing)
pickle_accelerator = sys.modules.get("_pickle", missing)
decimal_precision = decimal.getcontext().prec
for path in (
"benches/benchmarks/pickle.py",
"benches/benchmarks/unpickle.py",
"benches/benchmarks/decimal_factorial.py",
):
with open(path) as benchmark_file:
benchmark_source = benchmark_file.read()
exec(compile(benchmark_source, path, "exec"), {})
assert sys.modules.get("pickle", missing) is pickle_module
assert sys.modules.get("_pickle", missing) is pickle_accelerator
assert decimal.getcontext().prec == decimal_precision
"#;
InterpreterBuilder::new()
.init_stdlib()
.interpreter()
.enter(|vm| {
if let Err(err) = vm.run_simple_string(source) {
vm.print_exception(err);
panic!("pyperformance benchmarks leaked interpreter state");
}
});
}