Repository navigation
Support import timing and cached import diagnostics - #9190
Conversation
Support -X importtime and PYTHONPROFILEIMPORTTIME, including mode 2 cached imports. Track nested timing separately in each VM thread and share the output header per interpreter. Assisted-by: OpenAI Codex:model version unavailable
Retire only test_import_time expectedFailure after the independent runtime passes its canonical assertions. Preserve other cmd-line markers and align environment range errors with CPython. Assisted-by: OpenAI Codex:model version unavailable
Keep CPython cached-import minimum width semantics for UTF-8 and backslash-replaced surrogate names. Scope the diagnostic blank line to importtime without changing CPU-count errors. Assisted-by: OpenAI Codex:model version unavailable
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
⛔ Files ignored due to path filters: 1
📒 Files selected for processing: 6
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: :4: SyntaxWarning: invalid decimal literal dependencies: dependent tests: (no tests depend on cmd_line) Legend:
|
Merging this PR will not alter performance
Comparing Footnotes
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4fae3992c8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Some(Self { | ||
| state: &vm.import_timing, | ||
| parent, | ||
| start: Instant::now(), |
There was a problem hiding this comment.
Gate import timing's clock on wasm32-unknown-unknown
When an embedder builds rustpython_vm for wasm32-unknown-unknown and sets the new public Settings::import_time field to 1 or 2, interpreter startup reaches Instant::now() on the first uncached import; Rust's standard-library implementation panics on that target because no monotonic clock is available. This makes enabling the diagnostic abort execution instead of reporting timings, so this path needs a wasm clock implementation or a target-specific graceful fallback.
AGENTS.md reference: AGENTS.md:L11-L12
Useful? React with 👍 / 👎.
Summary
Extract import-time diagnostics from the Python 3.15 upgrade work (#8954):
-X importtime/PYTHONPROFILEIMPORTTIME, including mode 2 cached-import reporting, first-Xoccurrence, environment override, and invalid numeric-value diagnostics.CmdLineTest.test_import_timeexpected-failure marker throughscripts/update_lib; canonical assertions and all other markers are unchanged.This stays independent of frozen-module selection, startup initialization, and unrelated import exception changes.
Reference
CPython
d220409a13b77de7a6c30abe16ea90db01528edc:Python/import.c(import_ensure_initializedandimport_find_and_load_with_name) andPython/initconfig.c(config_init_import_time).Validation
Final source
4fae3992validated on Linux:test_import_time,test_xoptions, circular import/from-import, repeated failed import, and thread creation. These are focused regression checks, not fulltest_cmd_line/test_import/test_threadsuite passes.cargo testfromcrates/capi, including doc tests.cargo clippy --all-targets -- -D warningsfor the same workspace and separate CAPI scopes.-E/-I, and nested cached imports. The one known difference is documented below. All four invalid-range fatal diagnostics match exactly, as does nested cached UTF-8/surrogate output.Normal commit hooks passed. No new Python behavioral snippets or replacement tests were added.
Known boundary
CPython's wide-character
-Xnumeric parser inherits its startup locale. UnderC.UTF-8, leading U+2003 whitespace selects mode 2 there, while this parser falls back to mode 1. Byte-based environment parsing agrees. This PR does not change process locale initialization or claim complete locale-sensitive numeric parsing parity. The existing unencodable-module-name expected-failure remains: its combined missing-module/surrogate case still reports expected failure on this independent Linux runtime, while pinned CPython passes. Cached UTF-8 and escaped-surrogate formatting matches the pinned oracle.Assisted-by: OpenAI Codex:model version unavailable