Uh oh!
There was an error while loading. Please reload this page.
gh-154756: Fix data race in list.sort() - #154572
Conversation
brijkapadia
commented
Jul 24, 2026
|
weixlu
commented
Jul 27, 2026
@brijkapadia Thanks for your review. Sure, I’ve created a separate issue. You’re right that this PR introduces quite a few release atomic stores. However, I think most of them are necessary to preserve the required atomicity.
|
picnixz
commented
Jul 27, 2026
What is the performance impact for lists of various size? |
weixlu
commented
Jul 28, 2026
@picnixz Hi, I have run
Random data (
All input patterns at size = 16384 (default)
|
aisk
commented
Jul 29, 2026
I think we can use a simpler approach, This keeps the code not too complicated, and should have better performance because we don't need to call atomic operations multiple times. And during the sort process, other threads which may access the old The Lines 141 to 171 in a528a24 |
weixlu
commented
Jul 30, 2026
Great idea! This sounds like RCU (read-copy-update) in Linux kernel. I'll re-implement it and re-run the benchmarks. I expect the numbers to be much better. |
pochmann
commented
Jul 30, 2026
weixlu
commented
Jul 30, 2026
@pochmann Thanks for pointing this out. When designing a sort algorithm, space complexity really is something you have to think about carefully — it's a trade-off between performance and memory footprint, and this PR is no exception:
Personally I'm open to either approach Two small notes on the current copy-on-write implementation:
|
weixlu
commented
Jul 30, 2026
benchmark result for copy-on-write implementation: Across sizes I see no meaningful regression
|
This PR try to fix#154756, it uses RCU (read-copy-update) method:
ob_itemto a newly allocated memory addressob_itemat the end.Testing
sortperf.pyshows no perf regression