| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Sorry, something went wrong.
@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.
|
Sorry, something went wrong.
|
What is the performance impact for lists of various size? |
Sorry, something went wrong.
@picnixz Hi, I have run sortperf.py on a --disable-gil --enable-optimizations build
Random data (list_sort) across sizes
All input patterns at size = 16384 (default)
|
Sorry, something went wrong.
|
I think we can use a simpler approach, memcpy the ob_item to a newly allocated memory address, then do the in place sort normally, and swap the sorted array back into ob_item at the end. 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 ob_item directly won't see the inner state of the sort. The list_resize method has the same approach under the free-threaded build: Lines 141 to 171 in a528a24 |
Sorry, something went wrong.
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. |
Sorry, something went wrong.
|
Maybe I misunderstand, and I don't know how important it is now, but copying the entire array seems to go directly against what @tim-one once expressed here: Lines 17 to 30 in f4b1d3e There's also this section later: Line 512 in f4b1d3e |
Sorry, something went wrong.
|
@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:
|
Sorry, something went wrong.
|
benchmark result for copy-on-write implementation: Across sizes I see no meaningful regression
|
Sorry, something went wrong.
|
I don't see an RCU-based implementation in the commit history, but that wouldn't be necessary anyway. The stores in the sorting routines indeed produce undefined behaviour when running concurrently with a lock-free reader, and that needs to be fixed. There is no necessity for release ordering, though. Relaxed ordering will be sufficient to remove the UB, and should have negligible performance impact. |
Sorry, something went wrong.
|
@dpdani Hi, thanks for your reminder, let me upload the RCU-based code.
Yes, I also think so :) |
Sorry, something went wrong.
|
TBC, I don't think an RCU implementation is needed here. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR try to fix #154756, it uses RCU (read-copy-update) method:
Testing