Repository navigation
Conversation
Assisted-by: Codex:gpt-6
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughNative method definitions now retain boxed native functions. Native functions and descriptors use manual GC traversal. Descriptor binding passes the method-definition owner to bound native methods. ChangesNative method lifetime
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Suggested reviewers:
|
|
Thank you for contributing. about this patch, I investigated the topic and then I found #9004 approach looks better at the moment. |
|
@youknowone following #9004, I propose keeping the new type model and narrowing this change to dynamic callable lifetimes. If you support this focused ownership fix, I can prepare a new PR or remake the current. |
Assisted-by: Codex:gpt-6
Merging this PR will improve performance by 76.92%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | rustpython[10000] |
14 ms | 7.9 ms | +76.92% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing 1ndahous3:native_function_owner (b0c4ae4) with main (bd8fdb7)
Footnotes
-
4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
@codspeedbot explain why performance improved |
Why
|
main (bd8fdb7) |
PR (b0c4ae4) | |
|---|---|---|
| Total | 14 ms | 7.9 ms |
GcState::collect_inner (from eval_breaker_work) |
6.1 ms (43%) | not present |
Compile (compile_with_syntax_warning_handler) |
5.7 ms | 5.7 ms |
| Parse | ~1.0 ms | ~1.0 ms |
Everything except the GC pass costs the same. The ~6 ms difference is one collect_inner call: list/dict/tuple traversal via gc_extend_referent_ptrs, plus dropping the garbage it found. This also explains the odd baseline on main. There, rustpython[10000] (14 ms) is slower than rustpython[20000] and rustpython[30000] (7.9 / 7.8 ms), even though it runs fewer loops. The first pystone case was the one paying for the collection.
Why the PR moves the collection
The PR switches PyMethodDescriptor and PyClassMethodDescriptor to traverse = "manual". A payload with HAS_TRAVERSE gets GC-tracked when it's allocated (crates/vm/src/object/core.rs), so these descriptors are now tracked. Before, they weren't. I built main and this PR and checked a fresh interpreter:
main |
PR | |
|---|---|---|
gc.get_count() at startup |
(818, 3920, 0) |
(1130, 4618, 0) |
Tracked method_descriptor |
0 | 1025 |
Tracked classmethod_descriptor |
0 | 40 |
Each interpreter in benches/execution.rs now starts with ~1,000 more tracked objects. Generation counts are shared across the whole process, and the gen0 threshold is 2000, so the point where collections trigger moves. The collection that used to land in pystone's single measured iteration now runs outside the measured window (for example during interpreter setup). None of the other 61 benchmarks changed.
Takeaways
- Treat the +77% as a side effect of the benchmark setup, not a win from this PR. Any change in how many objects get tracked can move this result either way.
- The descriptors are now tracked on purpose: they hold
_method_def_ownerand need to be traversed. The real cost is small: each collection has ~1k more objects to scan. - To stop this benchmark from flipping on unrelated changes, the harness could call
gc.collect()(or disable automatic GC) before the measured loop inbench_rustpython_code, so no collection falls inside the timed section.
Flamegraphs: main · PR · comparison
Summary
- Warming up the performance wizard...
- Investigate pystone rustpython[10000] improvement — Cause: a GC collection no longer falls inside the measured iteration. Not a real speedup.
- Reply with explanation — Reply with explanation
- Handling comment — Comment handling finished successfully
Learnings updated. See what CodSpeed remembers about this repository.
Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot.
Summary
Extracted from #8944 as an independent fix.
AI assistance
Written with Codex (GPT-6), reviewed by a human before submission.
Summary by CodeRabbit