airborne12 commented on PR #69811:
URL: https://github.com/apache/doris/pull/69811#issuecomment-6489766698

   > C++20 provides std::atomic<std::weak_ptr<T>>, which could replace the 
explicit mutex here
   
   Thanks, done in 36327d6a82: `_footer_pb` is now 
`atomic_weak_ptr<SegmentFooterPB>`, loaded with acquire and stored with 
release, and the two accessors and the mutex are gone.
   
   `atomic_weak_ptr` is new in `common/atomic_shared_ptr.h`, next to 
`atomic_shared_ptr`. With libstdc++ it is exactly 
`std::atomic<std::weak_ptr<T>>`. The macOS build uses libc++, which rejects 
`std::atomic<std::weak_ptr<T>>` (libc++ 20.1: "std::atomic<T> requires that 'T' 
be a trivially copyable type") and has no `std::atomic_load` overload for 
`weak_ptr`, so there it falls back to a `weak_ptr` behind a mutex, as 
`atomic_shared_ptr` does for `shared_ptr`. With libstdc++ the member is back to 
the 16 bytes of a plain `weak_ptr`, so `Segment` no longer carries a 40-byte 
mutex.
   
   The branch is rebased on the current master, and all six 
SegmentFooterCacheTest cases pass 20 of 20 repeats under ASAN with no report.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to