126#include <type_traits>
127#include <unordered_set>
241#ifdef UNIV_PFS_MEMORY
450#if defined(__GNUG__) && (__GNUG__ == 5)
460 return (index == b_len || (a[index] == b[index] &&
470 return ((
file[index] ==
'\0' ||
file[index] ==
'.')
499#define UT_NEW_THIS_FILE_PSI_KEY ut_new_get_key_by_file(MY_BASENAME)
510 for (
size_t i = 0; i < b_len; ++i) {
522 for (
size_t i = 0;; ++i) {
523 if (
file[i] ==
'\0' ||
file[i] ==
'.') {
535 for (
size_t i = 0; i <
n_auto; ++i) {
537 return static_cast<int>(i);
559#define UT_NEW_THIS_FILE_PSI_INDEX \
560 (force_constexpr<ut_new_get_key_by_file(MY_BASENAME)>::value)
562#define UT_NEW_THIS_FILE_PSI_KEY \
563 (UT_NEW_THIS_FILE_PSI_INDEX == -1 \
564 ? ut::make_psi_memory_key(PSI_NOT_INSTRUMENTED) \
565 : ut::make_psi_memory_key(auto_event_keys[UT_NEW_THIS_FILE_PSI_INDEX]))
571#define UT_NEW_THIS_FILE_PSI_KEY ut::make_psi_memory_key(PSI_NOT_INSTRUMENTED)
577#ifdef HAVE_PSI_MEMORY_INTERFACE
597 return malloc_impl::alloc<false>(size,
key());
615inline void *
malloc(std::size_t size)
noexcept {
633 return malloc_impl::alloc<true>(size,
key());
651inline void *
zalloc(std::size_t size)
noexcept {
674 std::size_t size)
noexcept {
701inline void *
realloc(
void *ptr, std::size_t size)
noexcept {
715inline void free(
void *ptr)
noexcept {
748template <
typename T,
typename... Args>
753 new (
mem) T(std::forward<Args>(args)...);
758 return static_cast<T *
>(
mem);
791template <
typename T,
typename... Args>
792inline T *
new_(Args &&... args) {
794 std::forward<Args>(args)...);
871template <
typename T,
typename... Args>
875 auto mem = malloc_impl::alloc<false>(
sizeof(T) *
sizeof...(args),
key());
881 detail::construct<T>(
mem,
sizeof(T) * idx++, std::forward<Args>(args)));
883 for (
size_t offset = (idx - 1) *
sizeof(T); offset != 0;
884 offset -=
sizeof(T)) {
885 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(
mem) + offset -
892 return static_cast<T *
>(
mem);
956template <
typename T,
typename... Args>
959 std::forward<Args>(args)...);
1024template <
typename T>
1028 auto mem = malloc_impl::alloc<false>(
sizeof(T) *
count(),
key());
1033 for (; offset <
sizeof(T) *
count(); offset +=
sizeof(T)) {
1034 new (
reinterpret_cast<uint8_t *
>(
mem) + offset) T{};
1037 for (; offset != 0; offset -=
sizeof(T)) {
1038 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(
mem) + offset -
1045 return static_cast<T *
>(
mem);
1091template <
typename T>
1106template <
typename T>
1111 const auto data_len = malloc_impl::datalen(ptr);
1112 for (
size_t offset = 0; offset < data_len; offset +=
sizeof(T)) {
1113 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(ptr) + offset)->~T();
1147 std::size_t size)
noexcept {
1150 return page_alloc_impl::alloc(size,
key());
1196 return page_alloc_impl::datalen(ptr);
1210 return page_alloc_impl::low_level_info(ptr);
1246 std::size_t size)
noexcept {
1249 return large_page_alloc_impl::alloc(size,
key());
1294 return large_page_alloc_impl::datalen(ptr);
1308 return large_page_alloc_impl::low_level_info(ptr);
1356 void *large_page_mem =
nullptr;
1357 if (large_pages_enabled) {
1455 if (!ptr)
return false;
1461 ut_a(large_page_alloc_impl::page_type(ptr) ==
1483 std::size_t alignment)
noexcept {
1486 return aligned_alloc_impl::alloc<false>(size, alignment,
key());
1525 std::size_t alignment)
noexcept {
1528 return aligned_alloc_impl::alloc<true>(size, alignment,
key());
1591template <
typename T,
typename... Args>
1597 new (
mem) T(std::forward<Args>(args)...);
1602 return static_cast<T *
>(
mem);
1632template <
typename T,
typename... Args>
1635 alignment, std::forward<Args>(args)...);
1647template <
typename T>
1712template <
typename T,
typename... Args>
1721 detail::construct<T>(
mem,
sizeof(T) * idx++, std::forward<Args>(args)));
1723 for (
size_t offset = (idx - 1) *
sizeof(T); offset != 0;
1724 offset -=
sizeof(T)) {
1725 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(
mem) + offset -
1732 return static_cast<T *
>(
mem);
1776template <
typename T>
1784 for (; offset <
sizeof(T) *
count(); offset +=
sizeof(T)) {
1785 new (
reinterpret_cast<uint8_t *
>(
mem) + offset) T{};
1788 for (; offset != 0; offset -=
sizeof(T)) {
1789 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(
mem) + offset -
1796 return static_cast<T *
>(
mem);
1835template <
typename T,
typename... Args>
1838 alignment, std::forward<Args>(args)...);
1877template <
typename T>
1892template <
typename T>
1896 const auto data_len = aligned_alloc_impl::datalen(ptr);
1897 for (
size_t offset = 0; offset < data_len; offset +=
sizeof(T)) {
1898 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(ptr) + offset)->~T();
1920template <
typename T,
size_t Alignment>
1942 template <
typename... Args>
1959 template <
typename... Args>
1963 ut::aligned_new_withkey<T>(
key,
Alignment, std::forward<Args>(args)...);
1978 operator T *()
const {
2014template <
typename T,
size_t Alignment>
2054 template <
typename... Args>
2057 ptr = ut::aligned_new_arr<T>(
Alignment, std::forward<Args>(args)...);
2092 template <
typename... Args>
2096 std::forward<Args>(args)...);
2111 operator T *()
const {
2118template <
typename T>
2122 template <
typename U>
2128template <
typename T>
2132 template <
typename U>
2176template <
typename T,
typename Allocator_base = std::conditional_t<
2189 static_assert(
alignof(T) <=
alignof(std::max_align_t),
2190 "ut::allocator does not support over-aligned types. Use "
2191 "ut::aligned_* API to handle such types.");
2211 template <
typename U>
2213 : Allocator_base(other) {}
2220 template <
typename U>
2231 return !(*
this == other);
2239 const size_type s_max = std::numeric_limits<size_type>::max();
2258 throw std::bad_array_new_length();
2261 auto ptr = Allocator_base::allocate_impl(n_elements *
sizeof(T));
2264 throw std::bad_alloc();
2267 return static_cast<pointer>(ptr);
2283template <
typename T>
2288template <
typename T, std::
size_t N>
2293template <
typename T, std::
size_t N>
2296template <
typename T>
2301template <
typename T>
2306template <
typename T>
2311template <
typename T>
2333template <
typename T,
typename Deleter = detail::Deleter<T>,
typename... Args>
2334std::enable_if_t<!std::is_array<T>::value, std::unique_ptr<T, Deleter>>
2336 return std::unique_ptr<T, Deleter>(ut::new_<T>(std::forward<Args>(args)...));
2352template <
typename T,
typename Deleter = detail::Deleter<T>,
typename... Args>
2353std::enable_if_t<!std::is_array<T>::value, std::unique_ptr<T, Deleter>>
2355 return std::unique_ptr<T, Deleter>(
2356 ut::new_withkey<T>(
key, std::forward<Args>(args)...));
2374template <
typename T,
2375 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2376std::enable_if_t<detail::is_unbounded_array_v<T>, std::unique_ptr<T, Deleter>>
2378 return std::unique_ptr<T, Deleter>(
2394template <
typename T,
2395 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2396std::enable_if_t<detail::is_unbounded_array_v<T>, std::unique_ptr<T, Deleter>>
2398 return std::unique_ptr<T, Deleter>(
2407template <
typename T,
typename... Args>
2408std::enable_if_t<detail::is_bounded_array_v<T>>
make_unique(Args &&...) =
2417template <
typename T,
typename... Args>
2430template <
typename T>
2432 !std::is_array<T>::value, std::unique_ptr<T, detail::Deleter<T>>,
2434 detail::is_unbounded_array_v<T>,
2435 std::unique_ptr<T, detail::Array_deleter<std::remove_extent_t<T>>>,
2454template <
typename T,
typename Deleter = detail::Aligned_deleter<T>,
2456std::enable_if_t<!std::is_array<T>::value, std::unique_ptr<T, Deleter>>
2458 return std::unique_ptr<T, Deleter>(
2459 ut::aligned_new<T>(alignment, std::forward<Args>(args)...));
2477template <
typename T,
typename Deleter = detail::Aligned_deleter<T>,
2479std::enable_if_t<!std::is_array<T>::value, std::unique_ptr<T, Deleter>>
2481 return std::unique_ptr<T, Deleter>(
2482 ut::aligned_new_withkey<T>(
key, alignment, std::forward<Args>(args)...));
2503template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2504 std::remove_extent_t<T>>>
2505std::enable_if_t<detail::is_unbounded_array_v<T>, std::unique_ptr<T, Deleter>>
2507 return std::unique_ptr<T, Deleter>(
2527template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2528 std::remove_extent_t<T>>>
2529std::enable_if_t<detail::is_unbounded_array_v<T>, std::unique_ptr<T, Deleter>>
2531 return std::unique_ptr<T, Deleter>(
2541template <
typename T,
typename... Args>
2543 Args &&...) =
delete;
2551template <
typename T,
typename... Args>
2564template <
typename T>
2566 !std::is_array<T>::value, std::unique_ptr<T, detail::Aligned_deleter<T>>,
2567 std::conditional_t<detail::is_unbounded_array_v<T>,
2569 std::remove_extent_t<T>>>,
2587template <
typename T,
typename Deleter = detail::Deleter<T>,
typename... Args>
2588std::enable_if_t<!std::is_array<T>::value, std::shared_ptr<T>>
make_shared(
2590 return std::shared_ptr<T>(ut::new_<T>(std::forward<Args>(args)...),
2607template <
typename T,
typename Deleter = detail::Deleter<T>,
typename... Args>
2608std::enable_if_t<!std::is_array<T>::value, std::shared_ptr<T>>
make_shared(
2610 return std::shared_ptr<T>(
2611 ut::new_withkey<T>(
key, std::forward<Args>(args)...),
Deleter{});
2630template <
typename T,
2631 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2632std::enable_if_t<detail::is_unbounded_array_v<T>, std::shared_ptr<T>>
2634 return std::shared_ptr<T>(
2653template <
typename T,
2654 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2655std::enable_if_t<detail::is_unbounded_array_v<T>, std::shared_ptr<T>>
2657 return std::shared_ptr<T>(
2677template <
typename T,
2678 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2679std::enable_if_t<detail::is_bounded_array_v<T>, std::shared_ptr<T>>
2681 return std::shared_ptr<T>(
ut::new_arr<std::remove_extent_t<T>>(
2682 ut::Count{detail::bounded_array_size_v<T>}),
2699template <
typename T,
2700 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2701std::enable_if_t<detail::is_bounded_array_v<T>, std::shared_ptr<T>>
make_shared(
2703 return std::shared_ptr<T>(
2725template <
typename T,
typename Deleter = detail::Aligned_deleter<T>,
2727std::enable_if_t<!std::is_array<T>::value, std::shared_ptr<T>>
2729 return std::shared_ptr<T>(
2730 ut::aligned_new<T>(alignment, std::forward<Args>(args)...),
Deleter{});
2748template <
typename T,
typename Deleter = detail::Aligned_deleter<T>,
2750std::enable_if_t<!std::is_array<T>::value, std::shared_ptr<T>>
2752 return std::shared_ptr<T>(
2753 ut::aligned_new_withkey<T>(
key, alignment, std::forward<Args>(args)...),
2775template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2776 std::remove_extent_t<T>>>
2777std::enable_if_t<detail::is_unbounded_array_v<T>, std::shared_ptr<T>>
2779 return std::shared_ptr<T>(
2800template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2801 std::remove_extent_t<T>>>
2802std::enable_if_t<detail::is_unbounded_array_v<T>, std::shared_ptr<T>>
2804 return std::shared_ptr<T>(
2827template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2828 std::remove_extent_t<T>>>
2829std::enable_if_t<detail::is_bounded_array_v<T>, std::shared_ptr<T>>
2831 return std::shared_ptr<T>(
2833 alignment,
ut::Count{detail::bounded_array_size_v<T>}),
2852template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2853 std::remove_extent_t<T>>>
2854std::enable_if_t<detail::is_bounded_array_v<T>, std::shared_ptr<T>>
2856 return std::shared_ptr<T>(
2858 key, alignment,
ut::Count{detail::bounded_array_size_v<T>}),
2871template <
typename T>
2872using vector = std::vector<T, ut::allocator<T>>;
2875template <
typename T>
2876using list = std::list<T, ut::allocator<T>>;
2879template <
typename Key,
typename Compare = std::less<Key>>
2880using set = std::set<Key, Compare, ut::allocator<Key>>;
2882template <
typename Key>
2884 std::unordered_set<Key, std::hash<Key>, std::equal_to<Key>,
2888template <
typename Key,
typename Value,
typename Compare = std::less<Key>>
2890 std::map<Key, Value, Compare, ut::allocator<std::pair<const Key, Value>>>;
Definition: tls_cipher.cc:36
Lightweight convenience wrapper which manages a dynamically allocated array of over-aligned types.
Definition: ut0new.h:2015
void dealloc()
Invokes destructors of instances of type T, if applicable.
Definition: ut0new.h:2103
void alloc(Count count)
Allocates sufficiently large memory of dynamic storage duration to fit the array of size number of el...
Definition: ut0new.h:2037
T * ptr
Definition: ut0new.h:2016
void alloc_withkey(PSI_memory_key_t key, Count count)
Allocates sufficiently large memory of dynamic storage duration to fit the array of size number of el...
Definition: ut0new.h:2073
void alloc_withkey(PSI_memory_key_t key, Args &&... args)
Allocates sufficiently large memory of dynamic storage duration to fit the array of size number of el...
Definition: ut0new.h:2093
~aligned_array_pointer()
Destructor.
Definition: ut0new.h:2023
void alloc(Args &&... args)
Allocates sufficiently large memory of dynamic storage duration to fit the array of size number of el...
Definition: ut0new.h:2055
Lightweight convenience wrapper which manages dynamically allocated over-aligned type.
Definition: ut0new.h:1921
~aligned_pointer()
Destructor.
Definition: ut0new.h:1929
void alloc(Args &&... args)
Allocates sufficiently large memory of dynamic storage duration to fit the instance of type T at the ...
Definition: ut0new.h:1943
void alloc_withkey(PSI_memory_key_t key, Args &&... args)
Allocates sufficiently large memory of dynamic storage duration to fit the instance of type T at the ...
Definition: ut0new.h:1960
T * ptr
Definition: ut0new.h:1922
void dealloc()
Invokes the destructor of instance of type T, if applicable.
Definition: ut0new.h:1969
Allocator that allows std::* containers to manage their memory through ut::malloc* and ut::free libra...
Definition: ut0new.h:2179
T & reference
Definition: ut0new.h:2183
void deallocate(pointer ptr, size_type n_elements=0)
Releases the memory allocated through ut::allocator<T>::allocate().
Definition: ut0new.h:2275
const T * const_pointer
Definition: ut0new.h:2182
ptrdiff_t difference_type
Definition: ut0new.h:2187
allocator< T, Allocator_base > & operator=(const allocator< T, Allocator_base > &)=default
allocator< T, Allocator_base > & operator=(allocator< T, Allocator_base > &&)=default
T value_type
Definition: ut0new.h:2185
allocator(const allocator< U, Allocator_base > &other)
Copy-construct a new instance of allocator with type T by using existing instance of allocator constr...
Definition: ut0new.h:2212
pointer allocate(size_type n_elements, const_pointer hint=nullptr)
Allocates chunk of memory that can hold n_elements objects of type T.
Definition: ut0new.h:2255
size_type max_size() const
Return the maximum number of objects that can be allocated by this allocator.
Definition: ut0new.h:2238
const T & const_reference
Definition: ut0new.h:2184
allocator(allocator< T, Allocator_base > &&)=default
bool operator!=(const ut::allocator< T, Allocator_base > &other) const
Non-equality of allocators instantiated with same types T.
Definition: ut0new.h:2230
allocator(PSI_memory_key key=mem_key_std)
Default constructor.
Definition: ut0new.h:2196
allocator(const allocator< T, Allocator_base > &)=default
size_t size_type
Definition: ut0new.h:2186
bool operator==(const ut::allocator< T, Allocator_base > &) const
Equality of allocators instantiated with same types T.
Definition: ut0new.h:2226
T * pointer
Definition: ut0new.h:2181
Implementation bits and pieces of include/ut0new.h.
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:48
#define realloc(P, A)
Definition: lexyy.cc:916
#define free(A)
Definition: lexyy.cc:915
A macro that gives FILE without the directory name (e.g.
constexpr bool unlikely(bool expr)
Definition: my_compiler.h:55
static int count
Definition: myisam_ftdump.cc:42
Instrumentation helpers for memory allocation.
std::atomic< Type > N
Definition: ut0counter.h:224
Definition: ut0tuple.h:56
Definition: authentication.cc:35
Alignment
Enum class describing alignment-requirements.
Definition: lock_free_type.h:74
constexpr bool is_unbounded_array_v< T[]>
Definition: ut0new.h:2284
typename select_alloc_impl< Pfs_memory_instrumentation_on >::type select_alloc_impl_t
Just a small helper type which saves us some keystrokes.
Definition: aligned_alloc.h:690
constexpr size_t bounded_array_size_v< T[N]>
Definition: ut0new.h:2294
constexpr bool is_bounded_array_v
Definition: ut0new.h:2287
constexpr bool is_unbounded_array_v
Definition: ut0new.h:2282
typename select_large_page_alloc_impl< Pfs_memory_instrumentation_on >::type select_large_page_alloc_impl_t
Just a small helper type which saves us some keystrokes.
Definition: large_page_alloc.h:366
typename select_page_alloc_impl< Pfs_memory_instrumentation_on >::type select_page_alloc_impl_t
Just a small helper type which saves us some keystrokes.
Definition: page_alloc.h:427
typename select_malloc_impl< Pfs_memory_instrumentation_on, Array_specialization >::type select_malloc_impl_t
Just a small helper type which saves us some keystrokes.
Definition: alloc.h:428
constexpr size_t bounded_array_size_v
Definition: ut0new.h:2292
constexpr bool is_bounded_array_v< T[N]>
Definition: ut0new.h:2289
This file contains a set of libraries providing overloads for regular dynamic allocation routines whi...
Definition: aligned_alloc.h:47
void * aligned_zalloc_withkey(PSI_memory_key_t key, std::size_t size, std::size_t alignment) noexcept
Dynamically allocates zero-initialized storage of given size and at the address aligned to the reques...
Definition: ut0new.h:1524
T * new_arr_withkey(PSI_memory_key_t key, Args &&... args)
Dynamically allocates storage for an array of T's.
Definition: ut0new.h:872
size_t pfs_overhead() noexcept
Returns number of bytes that ut::malloc_*, ut::zalloc_*, ut::realloc_* and ut::new_* variants will be...
Definition: ut0new.h:1123
T * aligned_new_withkey(PSI_memory_key_t key, std::size_t alignment, Args &&... args)
Dynamically allocates storage for an object of type T at address aligned to the requested alignment.
Definition: ut0new.h:1592
void * zalloc_withkey(PSI_memory_key_t key, std::size_t size) noexcept
Dynamically allocates zero-initialized storage of given size.
Definition: ut0new.h:630
void * malloc_withkey(PSI_memory_key_t key, std::size_t size) noexcept
Dynamically allocates storage of given size.
Definition: ut0new.h:594
std::enable_if_t<!std::is_array< T >::value, std::unique_ptr< T, Deleter > > make_unique(Args &&... args)
Dynamically allocates storage for an object of type T.
Definition: ut0new.h:2335
T * aligned_new_arr(std::size_t alignment, Args &&... args)
Dynamically allocates storage for an array of T's at address aligned to the requested alignment.
Definition: ut0new.h:1836
void * aligned_zalloc(std::size_t size, std::size_t alignment) noexcept
Dynamically allocates zero-initialized storage of given size and at the address aligned to the reques...
Definition: ut0new.h:1547
void * malloc_large_page(std::size_t size) noexcept
Dynamically allocates memory backed up by large (huge) pages.
Definition: ut0new.h:1269
std::unordered_set< Key, std::hash< Key >, std::equal_to< Key >, ut::allocator< Key > > unordered_set
Definition: ut0new.h:2885
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2868
T * new_(Args &&... args)
Dynamically allocates storage for an object of type T.
Definition: ut0new.h:792
allocation_low_level_info page_low_level_info(void *ptr) noexcept
Retrieves the pointer and size of the allocation provided by the OS.
Definition: ut0new.h:1207
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2872
void aligned_delete_arr(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the aligned_new_arr_*() variants...
Definition: ut0new.h:1893
void delete_(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::new*() variants.
Definition: ut0new.h:807
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2880
void * malloc_page(std::size_t size) noexcept
Dynamically allocates system page-aligned storage of given size.
Definition: ut0new.h:1173
void * realloc_withkey(PSI_memory_key_t key, void *ptr, std::size_t size) noexcept
Upsizes or downsizes already dynamically allocated storage to the new size.
Definition: ut0new.h:673
T * new_withkey(PSI_memory_key_t key, Args &&... args)
Dynamically allocates storage for an object of type T.
Definition: ut0new.h:749
void delete_arr(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::new_arr*() variants.
Definition: ut0new.h:1107
allocation_low_level_info large_page_low_level_info(void *ptr) noexcept
Retrieves the pointer and size of the allocation provided by the OS.
Definition: ut0new.h:1305
std::enable_if_t<!std::is_array< T >::value, std::unique_ptr< T, Deleter > > make_unique_aligned(size_t alignment, Args &&... args)
Dynamically allocates storage for an object of type T at address aligned to the requested alignment.
Definition: ut0new.h:2457
T * new_arr(Args &&... args)
Dynamically allocates storage for an array of T's.
Definition: ut0new.h:957
bool free_page(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc_page*() variants.
Definition: ut0new.h:1223
void * malloc_large_page_withkey(PSI_memory_key_t key, std::size_t size) noexcept
Dynamically allocates memory backed up by large (huge) pages.
Definition: ut0new.h:1245
size_t large_page_allocation_size(void *ptr) noexcept
Retrieves the total amount of bytes that are available for application code to use.
Definition: ut0new.h:1291
std::enable_if_t<!std::is_array< T >::value, std::shared_ptr< T > > make_shared_aligned(size_t alignment, Args &&... args)
Dynamically allocates storage for an object of type T at address aligned to the requested alignment.
Definition: ut0new.h:2728
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2890
void * malloc(std::size_t size) noexcept
Dynamically allocates storage of given size.
Definition: ut0new.h:615
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2436
T * aligned_new(std::size_t alignment, Args &&... args)
Dynamically allocates storage for an object of type T at address aligned to the requested alignment.
Definition: ut0new.h:1633
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2876
void free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc*(),...
Definition: ut0new.h:715
PSI_memory_key_t make_psi_memory_key(PSI_memory_key key)
Convenience helper function to create type-safe representation of PSI_memory_key.
Definition: ut0new.h:188
void * aligned_alloc_withkey(PSI_memory_key_t key, std::size_t size, std::size_t alignment) noexcept
Dynamically allocates storage of given size and at the address aligned to the requested alignment.
Definition: ut0new.h:1482
constexpr bool WITH_PFS_MEMORY
Definition: ut0new.h:578
void aligned_delete(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the aligned_new_*() variants.
Definition: ut0new.h:1648
void * malloc_page_withkey(PSI_memory_key_t key, std::size_t size) noexcept
Dynamically allocates system page-aligned storage of given size.
Definition: ut0new.h:1146
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Aligned_deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Aligned_array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr_aligned
The following is a common type that is returned by all the ut::make_unique_aligned (non-aligned) spec...
Definition: ut0new.h:2570
void * realloc(void *ptr, std::size_t size) noexcept
Upsizes or downsizes already dynamically allocated storage to the new size.
Definition: ut0new.h:701
std::enable_if_t<!std::is_array< T >::value, std::shared_ptr< T > > make_shared(Args &&... args)
Dynamically allocates storage for an object of type T.
Definition: ut0new.h:2588
size_t page_allocation_size(void *ptr) noexcept
Retrieves the total amount of bytes that are available for application code to use.
Definition: ut0new.h:1193
bool free_large_page(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc_large_page*() var...
Definition: ut0new.h:1322
T * aligned_new_arr_withkey(PSI_memory_key_t key, std::size_t alignment, Args &&... args)
Dynamically allocates storage for an array of T's at address aligned to the requested alignment.
Definition: ut0new.h:1713
void aligned_free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the aligned_alloc_*() or aligned...
Definition: ut0new.h:1561
void * aligned_alloc(std::size_t size, std::size_t alignment) noexcept
Dynamically allocates storage of given size and at the address aligned to the requested alignment.
Definition: ut0new.h:1505
void * zalloc(std::size_t size) noexcept
Dynamically allocates zero-initialized storage of given size.
Definition: ut0new.h:651
The interface to the operating system process control primitives.
bool os_use_large_pages
Whether to use large pages in the buffer pool.
Definition: os0proc.cc:50
The interface to the operating system process and thread control primitives.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
required string key
Definition: replication_asynchronous_connection_failover.proto:59
static MEM_ROOT mem
Definition: sql_servers.cc:98
Memory instrument information.
Definition: psi_memory_bits.h:57
static constexpr int value
Definition: ut0new.h:556
Light-weight and type-safe wrapper which serves a purpose of being able to select proper ut::new_arr*...
Definition: ut0new.h:979
Count(size_t count)
Definition: ut0new.h:980
size_t m_count
Definition: ut0new.h:982
size_t operator()() const
Definition: ut0new.h:981
Light-weight and type-safe wrapper around the PSI_memory_key that eliminates the possibility of intro...
Definition: ut0new.h:176
PSI_memory_key operator()() const
Definition: ut0new.h:178
PSI_memory_key m_key
Definition: ut0new.h:179
PSI_memory_key_t(PSI_memory_key key)
Definition: ut0new.h:177
Can be used to extract pointer and size of the allocation provided by the OS.
Definition: ut0new.h:138
void * base_ptr
A pointer returned by the OS allocator.
Definition: ut0new.h:140
size_t allocation_size
The size of allocation that OS performed.
Definition: ut0new.h:142
Definition: ut0new.h:2221
Small wrapper which utilizes SFINAE to dispatch the call to appropriate aligned allocator implementat...
Definition: aligned_alloc.h:696
Definition: ut0new.h:2312
void operator()(T *ptr)
Definition: ut0new.h:2313
Definition: ut0new.h:2307
void operator()(T *ptr)
Definition: ut0new.h:2308
Small wrapper which utilizes SFINAE to dispatch the call to appropriate allocator implementation.
Definition: alloc.h:434
Definition: ut0new.h:2302
void operator()(T *ptr)
Definition: ut0new.h:2303
Definition: ut0new.h:2297
void operator()(T *ptr)
Definition: ut0new.h:2298
Small wrapper which utilizes SFINAE to dispatch the call to appropriate aligned allocator implementat...
Definition: large_page_alloc.h:372
Small wrapper which utilizes SFINAE to dispatch the call to appropriate aligned allocator implementat...
Definition: page_alloc.h:433
Definition: ut0new.h:2129
void * allocate_impl(size_t n_bytes)
Definition: ut0new.h:2138
const PSI_memory_key m_key
Definition: ut0new.h:2143
PSI_memory_key get_mem_key() const
Definition: ut0new.h:2136
allocator_base_pfs(PSI_memory_key key)
Definition: ut0new.h:2130
allocator_base_pfs(const allocator_base_pfs< U > &other)
Definition: ut0new.h:2133
Definition: ut0new.h:2119
void * allocate_impl(size_t n_bytes)
Definition: ut0new.h:2125
allocator_base(const allocator_base< U > &other)
Definition: ut0new.h:2123
allocator_base(PSI_memory_key)
Definition: ut0new.h:2120
Definition: ut0new.h:1329
Version control for database, common definitions, and include files.
#define UT_ARR_SIZE(a)
Definition: univ.i:523
Utilities for byte operations.
Utilities related to CPU cache.
Debug utilities for Innobase.
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:68
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:56
PSI_memory_key mem_key_ddl
Definition: ut0new.cc:59
void ut_new_boot_safe()
Setup the internal objects needed for ut::*_withkey() to operate.
Definition: ut0new.cc:136
PSI_memory_key mem_key_redo_log_archive_queue_element
PSI_memory_key mem_key_dict_stats_index_map_t
Definition: ut0new.cc:53
PSI_memory_key mem_key_buf_stat_per_index_t
Definition: ut0new.cc:49
PSI_memory_key mem_key_other
Definition: ut0new.cc:56
PSI_memory_info pfs_info_auto[n_auto]
PSI_memory_key auto_event_keys[n_auto]
constexpr int ut_new_get_key_by_base_file(const char *file, size_t len)
Retrieve a memory key (registered with PFS), given the file name of the caller.
Definition: ut0new.h:534
PSI_memory_key mem_key_fil_space_t
Definition: ut0new.cc:55
constexpr bool ut_string_begins_with(const char *a, const char *b, size_t b_len)
gcc 5 fails to evaluate costexprs at compile time.
Definition: ut0new.h:508
constexpr int ut_new_get_key_by_file(const char *file)
Retrieve a memory key (registered with PFS), given the file name of the caller.
Definition: ut0new.h:547
PSI_memory_key mem_key_ahi
Keys for registering allocations with performance schema.
Definition: ut0new.cc:46
void ut_new_boot()
Setup the internal objects needed for ut::*_withkey() to operate.
Definition: ut0new.cc:117
PSI_memory_key mem_key_partitioning
Definition: ut0new.cc:57
PSI_memory_key mem_key_archive
Definition: ut0new.cc:47
static constexpr const char * auto_event_names[]
List of filenames that allocate memory and are instrumented via PFS.
Definition: ut0new.h:244
PSI_memory_key mem_key_std
Definition: ut0new.cc:60
const size_t alloc_max_retries
Maximum number of retries to allocate memory.
Definition: ut0new.cc:42
PSI_memory_key mem_key_row_log_buf
Definition: ut0new.cc:58
PSI_memory_key mem_key_trx_sys_t_rw_trx_ids
Definition: ut0new.cc:61
static constexpr size_t n_auto
Definition: ut0new.h:445
PSI_memory_key mem_key_buf_buf_pool
Definition: ut0new.cc:48
constexpr size_t ut_len_without_extension(const char *file)
Find the length of the filename without its file extension.
Definition: ut0new.h:521
PSI_memory_key mem_key_undo_spaces
Definition: ut0new.cc:62
PSI_memory_key mem_key_ut_lock_free_hash_t
Definition: ut0new.cc:63
PSI_memory_key mem_key_clone
Memory key for clone.
Definition: ut0new.cc:51
PSI_memory_key mem_key_dict_stats_n_diff_on_level
Definition: ut0new.cc:54
PSI_memory_key mem_key_dict_stats_bg_recalc_pool_t
Definition: ut0new.cc:52
#define PSI_NOT_INSTRUMENTED
Definition: validate_password_imp.cc:39