internal: schedule buffer to release later instead of leaking - #6344
internal: schedule buffer to release later instead of leaking#6344Person-93 wants to merge 3 commits into
Conversation
Merging this PR will improve performance by 17.61%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | extract_i128_small_pos |
2.6 µs | 2.2 µs | +18.16% |
| ⚡ | Simulation | extract_i128_zero |
2.6 µs | 2.2 µs | +17.63% |
| ⚡ | Simulation | extract_i128_small_neg |
2.7 µs | 2.3 µs | +17.04% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing Person-93:fix-leak-pybuffer (b409b76) with main (34f08c3)
Footnotes
-
6 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. ↩
davidhewitt
left a comment
There was a problem hiding this comment.
Crafty solution! I'm a little wary about Py_AddPendingCall being safe to call from within GC traverse, I think it should be possible to write a test so we can verify.
I would also be quite happy with getting #6330 done and ultimately declaring GC traversal functions unsafe to implement and completely throw away any check from this Drop impl.
I think you're right about this. |
If a buffer is dropped during gc traversal, use
Py_AddPendingCallto release it later instead of leaking it.Hopefully this can also unblock #6261.