You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default c'tor for polymorphic_allocator calls get_default_resource, so every default-constructed pmr container will acquire the lock, which is expensive:
It's extremely common /not/ to pass a fancy allocator to a pmr container at construction time. This is one of the key value propositions of std::pmr -- that it provides "vocabulary types" (such as pmr::vector), which are compile-time compatible and accept fancy allocators on specific instances at runtime.
The text was updated successfully, but these errors were encountered:
Pmr has the concept of a global "default resource", accessed via get_default_resource/set_default_resource. In the libstdc++ implementation, this is done with std::atomic:
https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/experimental/memory_resource#L537-L560
In Boost container we have a global lock:
https://github.com/boostorg/container/blob/develop/src/global_resource.cpp#L85-L86
The default c'tor for polymorphic_allocator calls get_default_resource, so every default-constructed pmr container will acquire the lock, which is expensive:
container/include/boost/container/pmr/polymorphic_allocator.hpp
Lines 45 to 46 in b7d48f1
It's extremely common /not/ to pass a fancy allocator to a pmr container at construction time. This is one of the key value propositions of std::pmr -- that it provides "vocabulary types" (such as pmr::vector), which are compile-time compatible and accept fancy allocators on specific instances at runtime.
The text was updated successfully, but these errors were encountered: