127#include <type_traits>
128#include <unordered_map>
129#include <unordered_set>
243#ifdef UNIV_PFS_MEMORY
452#if defined(__GNUG__) && (__GNUG__ == 5)
462 return (index == b_len || (a[index] == b[index] &&
472 return ((
file[index] ==
'\0' ||
file[index] ==
'.')
501#define UT_NEW_THIS_FILE_PSI_KEY ut_new_get_key_by_file(MY_BASENAME)
512 for (
size_t i = 0; i < b_len; ++i) {
524 for (
size_t i = 0;; ++i) {
525 if (
file[i] ==
'\0' ||
file[i] ==
'.') {
537 for (
size_t i = 0; i <
n_auto; ++i) {
539 return static_cast<int>(i);
561#define UT_NEW_THIS_FILE_PSI_INDEX \
562 (force_constexpr<ut_new_get_key_by_file(MY_BASENAME)>::value)
564#define UT_NEW_THIS_FILE_PSI_KEY \
565 (UT_NEW_THIS_FILE_PSI_INDEX == -1 \
566 ? ut::make_psi_memory_key(PSI_NOT_INSTRUMENTED) \
567 : ut::make_psi_memory_key(auto_event_keys[UT_NEW_THIS_FILE_PSI_INDEX]))
573#define UT_NEW_THIS_FILE_PSI_KEY ut::make_psi_memory_key(PSI_NOT_INSTRUMENTED)
579#ifdef HAVE_PSI_MEMORY_INTERFACE
599 return malloc_impl::alloc<false>(size,
key());
617inline void *
malloc(std::size_t size)
noexcept {
635 return malloc_impl::alloc<true>(size,
key());
653inline void *
zalloc(std::size_t size)
noexcept {
676 std::size_t size)
noexcept {
703inline void *
realloc(
void *ptr, std::size_t size)
noexcept {
717inline void free(
void *ptr)
noexcept {
750template <
typename T,
typename... Args>
755 new (
mem) T(std::forward<Args>(args)...);
760 return static_cast<T *
>(
mem);
793template <
typename T,
typename... Args>
794inline T *
new_(Args &&... args) {
796 std::forward<Args>(args)...);
873template <
typename T,
typename... Args>
877 auto mem = malloc_impl::alloc<false>(
sizeof(T) *
sizeof...(args),
key());
883 detail::construct<T>(
mem,
sizeof(T) * idx++, std::forward<Args>(args)));
885 for (
size_t offset = (idx - 1) *
sizeof(T); offset != 0;
886 offset -=
sizeof(T)) {
887 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(
mem) + offset -
894 return static_cast<T *
>(
mem);
958template <
typename T,
typename... Args>
961 std::forward<Args>(args)...);
1026template <
typename T>
1030 auto mem = malloc_impl::alloc<false>(
sizeof(T) *
count(),
key());
1035 for (; offset <
sizeof(T) *
count(); offset +=
sizeof(T)) {
1036 new (
reinterpret_cast<uint8_t *
>(
mem) + offset) T{};
1039 for (; offset != 0; offset -=
sizeof(T)) {
1040 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(
mem) + offset -
1047 return static_cast<T *
>(
mem);
1093template <
typename T>
1108template <
typename T>
1113 const auto data_len = malloc_impl::datalen(ptr);
1114 for (
size_t offset = 0; offset < data_len; offset +=
sizeof(T)) {
1115 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(ptr) + offset)->~T();
1149 std::size_t size)
noexcept {
1152 return page_alloc_impl::alloc(size,
key());
1198 return page_alloc_impl::datalen(ptr);
1212 return page_alloc_impl::low_level_info(ptr);
1248 std::size_t size)
noexcept {
1251 return large_page_alloc_impl::alloc(size,
key());
1296 return large_page_alloc_impl::datalen(ptr);
1310 return large_page_alloc_impl::low_level_info(ptr);
1358 void *large_page_mem =
nullptr;
1359 if (large_pages_enabled) {
1457 if (!ptr)
return false;
1463 ut_a(large_page_alloc_impl::page_type(ptr) ==
1485 std::size_t alignment)
noexcept {
1488 return aligned_alloc_impl::alloc<false>(size, alignment,
key());
1527 std::size_t alignment)
noexcept {
1530 return aligned_alloc_impl::alloc<true>(size, alignment,
key());
1593template <
typename T,
typename... Args>
1599 new (
mem) T(std::forward<Args>(args)...);
1604 return static_cast<T *
>(
mem);
1634template <
typename T,
typename... Args>
1637 alignment, std::forward<Args>(args)...);
1649template <
typename T>
1714template <
typename T,
typename... Args>
1723 detail::construct<T>(
mem,
sizeof(T) * idx++, std::forward<Args>(args)));
1725 for (
size_t offset = (idx - 1) *
sizeof(T); offset != 0;
1726 offset -=
sizeof(T)) {
1727 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(
mem) + offset -
1734 return static_cast<T *
>(
mem);
1778template <
typename T>
1786 for (; offset <
sizeof(T) *
count(); offset +=
sizeof(T)) {
1787 new (
reinterpret_cast<uint8_t *
>(
mem) + offset) T{};
1790 for (; offset != 0; offset -=
sizeof(T)) {
1791 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(
mem) + offset -
1798 return static_cast<T *
>(
mem);
1837template <
typename T,
typename... Args>
1840 alignment, std::forward<Args>(args)...);
1879template <
typename T>
1894template <
typename T>
1898 const auto data_len = aligned_alloc_impl::datalen(ptr);
1899 for (
size_t offset = 0; offset < data_len; offset +=
sizeof(T)) {
1900 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(ptr) + offset)->~T();
1922template <
typename T,
size_t Alignment>
1944 template <
typename... Args>
1961 template <
typename... Args>
1965 ut::aligned_new_withkey<T>(
key,
Alignment, std::forward<Args>(args)...);
1980 operator T *()
const {
2016template <
typename T,
size_t Alignment>
2056 template <
typename... Args>
2059 ptr = ut::aligned_new_arr<T>(
Alignment, std::forward<Args>(args)...);
2094 template <
typename... Args>
2098 std::forward<Args>(args)...);
2113 operator T *()
const {
2120template <
typename T>
2124 template <
typename U>
2130template <
typename T>
2134 template <
typename U>
2178template <
typename T,
typename Allocator_base = std::conditional_t<
2191 static_assert(
alignof(T) <=
alignof(std::max_align_t),
2192 "ut::allocator does not support over-aligned types. Use "
2193 "ut::aligned_* API to handle such types.");
2213 template <
typename U>
2215 : Allocator_base(other) {}
2222 template <
typename U>
2233 return !(*
this == other);
2241 const size_type s_max = std::numeric_limits<size_type>::max();
2260 throw std::bad_array_new_length();
2263 auto ptr = Allocator_base::allocate_impl(n_elements *
sizeof(T));
2266 throw std::bad_alloc();
2269 return static_cast<pointer>(ptr);
2285template <
typename T>
2290template <
typename T, std::
size_t N>
2295template <
typename T, std::
size_t N>
2298template <
typename T>
2303template <
typename T>
2308template <
typename T>
2313template <
typename T>
2335template <
typename T,
typename Deleter = detail::Deleter<T>,
typename... Args>
2336std::enable_if_t<!std::is_array<T>::value, std::unique_ptr<T, Deleter>>
2338 return std::unique_ptr<T, Deleter>(ut::new_<T>(std::forward<Args>(args)...));
2354template <
typename T,
typename Deleter = detail::Deleter<T>,
typename... Args>
2355std::enable_if_t<!std::is_array<T>::value, std::unique_ptr<T, Deleter>>
2357 return std::unique_ptr<T, Deleter>(
2358 ut::new_withkey<T>(
key, std::forward<Args>(args)...));
2376template <
typename T,
2377 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2378std::enable_if_t<detail::is_unbounded_array_v<T>, std::unique_ptr<T, Deleter>>
2380 return std::unique_ptr<T, Deleter>(
2396template <
typename T,
2397 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2398std::enable_if_t<detail::is_unbounded_array_v<T>, std::unique_ptr<T, Deleter>>
2400 return std::unique_ptr<T, Deleter>(
2409template <
typename T,
typename... Args>
2410std::enable_if_t<detail::is_bounded_array_v<T>>
make_unique(Args &&...) =
2419template <
typename T,
typename... Args>
2432template <
typename T>
2434 !std::is_array<T>::value, std::unique_ptr<T, detail::Deleter<T>>,
2436 detail::is_unbounded_array_v<T>,
2437 std::unique_ptr<T, detail::Array_deleter<std::remove_extent_t<T>>>,
2456template <
typename T,
typename Deleter = detail::Aligned_deleter<T>,
2458std::enable_if_t<!std::is_array<T>::value, std::unique_ptr<T, Deleter>>
2460 return std::unique_ptr<T, Deleter>(
2461 ut::aligned_new<T>(alignment, std::forward<Args>(args)...));
2479template <
typename T,
typename Deleter = detail::Aligned_deleter<T>,
2481std::enable_if_t<!std::is_array<T>::value, std::unique_ptr<T, Deleter>>
2483 return std::unique_ptr<T, Deleter>(
2484 ut::aligned_new_withkey<T>(
key, alignment, std::forward<Args>(args)...));
2505template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2506 std::remove_extent_t<T>>>
2507std::enable_if_t<detail::is_unbounded_array_v<T>, std::unique_ptr<T, Deleter>>
2509 return std::unique_ptr<T, Deleter>(
2529template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2530 std::remove_extent_t<T>>>
2531std::enable_if_t<detail::is_unbounded_array_v<T>, std::unique_ptr<T, Deleter>>
2533 return std::unique_ptr<T, Deleter>(
2543template <
typename T,
typename... Args>
2545 Args &&...) =
delete;
2553template <
typename T,
typename... Args>
2566template <
typename T>
2568 !std::is_array<T>::value, std::unique_ptr<T, detail::Aligned_deleter<T>>,
2569 std::conditional_t<detail::is_unbounded_array_v<T>,
2571 std::remove_extent_t<T>>>,
2589template <
typename T,
typename Deleter = detail::Deleter<T>,
typename... Args>
2590std::enable_if_t<!std::is_array<T>::value, std::shared_ptr<T>>
make_shared(
2592 return std::shared_ptr<T>(ut::new_<T>(std::forward<Args>(args)...),
2609template <
typename T,
typename Deleter = detail::Deleter<T>,
typename... Args>
2610std::enable_if_t<!std::is_array<T>::value, std::shared_ptr<T>>
make_shared(
2612 return std::shared_ptr<T>(
2613 ut::new_withkey<T>(
key, std::forward<Args>(args)...),
Deleter{});
2632template <
typename T,
2633 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2634std::enable_if_t<detail::is_unbounded_array_v<T>, std::shared_ptr<T>>
2636 return std::shared_ptr<T>(
2655template <
typename T,
2656 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2657std::enable_if_t<detail::is_unbounded_array_v<T>, std::shared_ptr<T>>
2659 return std::shared_ptr<T>(
2679template <
typename T,
2680 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2681std::enable_if_t<detail::is_bounded_array_v<T>, std::shared_ptr<T>>
2683 return std::shared_ptr<T>(
ut::new_arr<std::remove_extent_t<T>>(
2684 ut::Count{detail::bounded_array_size_v<T>}),
2701template <
typename T,
2702 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2703std::enable_if_t<detail::is_bounded_array_v<T>, std::shared_ptr<T>>
make_shared(
2705 return std::shared_ptr<T>(
2727template <
typename T,
typename Deleter = detail::Aligned_deleter<T>,
2729std::enable_if_t<!std::is_array<T>::value, std::shared_ptr<T>>
2731 return std::shared_ptr<T>(
2732 ut::aligned_new<T>(alignment, std::forward<Args>(args)...),
Deleter{});
2750template <
typename T,
typename Deleter = detail::Aligned_deleter<T>,
2752std::enable_if_t<!std::is_array<T>::value, std::shared_ptr<T>>
2754 return std::shared_ptr<T>(
2755 ut::aligned_new_withkey<T>(
key, alignment, std::forward<Args>(args)...),
2777template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2778 std::remove_extent_t<T>>>
2779std::enable_if_t<detail::is_unbounded_array_v<T>, std::shared_ptr<T>>
2781 return std::shared_ptr<T>(
2802template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2803 std::remove_extent_t<T>>>
2804std::enable_if_t<detail::is_unbounded_array_v<T>, std::shared_ptr<T>>
2806 return std::shared_ptr<T>(
2829template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2830 std::remove_extent_t<T>>>
2831std::enable_if_t<detail::is_bounded_array_v<T>, std::shared_ptr<T>>
2833 return std::shared_ptr<T>(
2835 alignment,
ut::Count{detail::bounded_array_size_v<T>}),
2854template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2855 std::remove_extent_t<T>>>
2856std::enable_if_t<detail::is_bounded_array_v<T>, std::shared_ptr<T>>
2858 return std::shared_ptr<T>(
2860 key, alignment,
ut::Count{detail::bounded_array_size_v<T>}),
2873template <
typename T>
2874using vector = std::vector<T, ut::allocator<T>>;
2877template <
typename T>
2878using list = std::list<T, ut::allocator<T>>;
2881template <
typename Key,
typename Compare = std::less<Key>>
2882using set = std::set<Key, Compare, ut::allocator<Key>>;
2884template <
typename Key>
2886 std::unordered_set<Key, std::hash<Key>, std::equal_to<Key>,
2890template <
typename Key,
typename Value,
typename Compare = std::less<Key>>
2892 std::map<Key, Value, Compare, ut::allocator<std::pair<const Key, Value>>>;
2894template <
typename Key,
typename Value,
typename Hash = std::hash<Key>,
2895 typename Key_equal = std::equal_to<Key>>
Definition: tls_cipher.cc:37
a nullable SQL value.
Definition: sql_value.h:40
Lightweight convenience wrapper which manages a dynamically allocated array of over-aligned types.
Definition: ut0new.h:2017
void dealloc()
Invokes destructors of instances of type T, if applicable.
Definition: ut0new.h:2105
void alloc(Count count)
Allocates sufficiently large memory of dynamic storage duration to fit the array of size number of el...
Definition: ut0new.h:2039
T * ptr
Definition: ut0new.h:2018
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:2075
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:2095
~aligned_array_pointer()
Destructor.
Definition: ut0new.h:2025
void alloc(Args &&... args)
Allocates sufficiently large memory of dynamic storage duration to fit the array of size number of el...
Definition: ut0new.h:2057
Lightweight convenience wrapper which manages dynamically allocated over-aligned type.
Definition: ut0new.h:1923
~aligned_pointer()
Destructor.
Definition: ut0new.h:1931
void alloc(Args &&... args)
Allocates sufficiently large memory of dynamic storage duration to fit the instance of type T at the ...
Definition: ut0new.h:1945
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:1962
T * ptr
Definition: ut0new.h:1924
void dealloc()
Invokes the destructor of instance of type T, if applicable.
Definition: ut0new.h:1971
Allocator that allows std::* containers to manage their memory through ut::malloc* and ut::free libra...
Definition: ut0new.h:2181
T & reference
Definition: ut0new.h:2185
void deallocate(pointer ptr, size_type n_elements=0)
Releases the memory allocated through ut::allocator<T>::allocate().
Definition: ut0new.h:2277
const T * const_pointer
Definition: ut0new.h:2184
ptrdiff_t difference_type
Definition: ut0new.h:2189
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:2187
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:2214
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:2257
size_type max_size() const
Return the maximum number of objects that can be allocated by this allocator.
Definition: ut0new.h:2240
const T & const_reference
Definition: ut0new.h:2186
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:2232
allocator(PSI_memory_key key=mem_key_std)
Default constructor.
Definition: ut0new.h:2198
allocator(const allocator< T, Allocator_base > &)=default
size_t size_type
Definition: ut0new.h:2188
bool operator==(const ut::allocator< T, Allocator_base > &) const
Equality of allocators instantiated with same types T.
Definition: ut0new.h:2228
T * pointer
Definition: ut0new.h:2183
Implementation bits and pieces of include/ut0new.h.
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
#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:56
static int count
Definition: myisam_ftdump.cc:43
Instrumentation helpers for memory allocation.
std::atomic< Type > N
Definition: ut0counter.h:225
Definition: ut0tuple.h:57
std::string_view Key
The key type for the hash structure in HashJoinRowBuffer.
Definition: hash_join_buffer.h:102
Definition: authentication.cc:36
Alignment
Enum class describing alignment-requirements.
Definition: lock_free_type.h:75
constexpr bool is_unbounded_array_v< T[]>
Definition: ut0new.h:2286
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:691
constexpr size_t bounded_array_size_v< T[N]>
Definition: ut0new.h:2296
constexpr bool is_bounded_array_v
Definition: ut0new.h:2289
constexpr bool is_unbounded_array_v
Definition: ut0new.h:2284
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:367
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:428
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:429
constexpr size_t bounded_array_size_v
Definition: ut0new.h:2294
constexpr bool is_bounded_array_v< T[N]>
Definition: ut0new.h:2291
This file contains a set of libraries providing overloads for regular dynamic allocation routines whi...
Definition: aligned_alloc.h:48
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:1526
std::unordered_map< Key, Value, Hash, Key_equal, ut::allocator< std::pair< const Key, Value > > > unordered_map
Definition: ut0new.h:2898
T * new_arr_withkey(PSI_memory_key_t key, Args &&... args)
Dynamically allocates storage for an array of T's.
Definition: ut0new.h:874
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:1125
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:1594
void * zalloc_withkey(PSI_memory_key_t key, std::size_t size) noexcept
Dynamically allocates zero-initialized storage of given size.
Definition: ut0new.h:632
void * malloc_withkey(PSI_memory_key_t key, std::size_t size) noexcept
Dynamically allocates storage of given size.
Definition: ut0new.h:596
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:2337
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:1838
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:1549
void * malloc_large_page(std::size_t size) noexcept
Dynamically allocates memory backed up by large (huge) pages.
Definition: ut0new.h:1271
std::unordered_set< Key, std::hash< Key >, std::equal_to< Key >, ut::allocator< Key > > unordered_set
Definition: ut0new.h:2887
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2870
T * new_(Args &&... args)
Dynamically allocates storage for an object of type T.
Definition: ut0new.h:794
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:1209
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2874
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:1895
void delete_(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::new*() variants.
Definition: ut0new.h:809
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2882
void * malloc_page(std::size_t size) noexcept
Dynamically allocates system page-aligned storage of given size.
Definition: ut0new.h:1175
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:675
T * new_withkey(PSI_memory_key_t key, Args &&... args)
Dynamically allocates storage for an object of type T.
Definition: ut0new.h:751
void delete_arr(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::new_arr*() variants.
Definition: ut0new.h:1109
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:1307
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:2459
T * new_arr(Args &&... args)
Dynamically allocates storage for an array of T's.
Definition: ut0new.h:959
bool free_page(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc_page*() variants.
Definition: ut0new.h:1225
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:1247
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:1293
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:2730
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2892
void * malloc(std::size_t size) noexcept
Dynamically allocates storage of given size.
Definition: ut0new.h:617
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:2438
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:1635
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2878
void free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc*(),...
Definition: ut0new.h:717
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:190
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:1484
constexpr bool WITH_PFS_MEMORY
Definition: ut0new.h:580
void aligned_delete(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the aligned_new_*() variants.
Definition: ut0new.h:1650
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:1148
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:2572
void * realloc(void *ptr, std::size_t size) noexcept
Upsizes or downsizes already dynamically allocated storage to the new size.
Definition: ut0new.h:703
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:2590
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:1195
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:1324
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:1715
void aligned_free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the aligned_alloc_*() or aligned...
Definition: ut0new.h:1563
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:1507
void * zalloc(std::size_t size) noexcept
Dynamically allocates zero-initialized storage of given size.
Definition: ut0new.h:653
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:51
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:60
static MEM_ROOT mem
Definition: sql_servers.cc:99
Memory instrument information.
Definition: psi_memory_bits.h:58
static constexpr int value
Definition: ut0new.h:558
Light-weight and type-safe wrapper which serves a purpose of being able to select proper ut::new_arr*...
Definition: ut0new.h:981
Count(size_t count)
Definition: ut0new.h:982
size_t m_count
Definition: ut0new.h:984
size_t operator()() const
Definition: ut0new.h:983
Light-weight and type-safe wrapper around the PSI_memory_key that eliminates the possibility of intro...
Definition: ut0new.h:178
PSI_memory_key operator()() const
Definition: ut0new.h:180
PSI_memory_key m_key
Definition: ut0new.h:181
PSI_memory_key_t(PSI_memory_key key)
Definition: ut0new.h:179
Can be used to extract pointer and size of the allocation provided by the OS.
Definition: ut0new.h:140
void * base_ptr
A pointer returned by the OS allocator.
Definition: ut0new.h:142
size_t allocation_size
The size of allocation that OS performed.
Definition: ut0new.h:144
Definition: ut0new.h:2223
Small wrapper which utilizes SFINAE to dispatch the call to appropriate aligned allocator implementat...
Definition: aligned_alloc.h:697
Definition: ut0new.h:2314
void operator()(T *ptr)
Definition: ut0new.h:2315
Definition: ut0new.h:2309
void operator()(T *ptr)
Definition: ut0new.h:2310
Small wrapper which utilizes SFINAE to dispatch the call to appropriate allocator implementation.
Definition: alloc.h:435
Definition: ut0new.h:2304
void operator()(T *ptr)
Definition: ut0new.h:2305
Definition: ut0new.h:2299
void operator()(T *ptr)
Definition: ut0new.h:2300
Small wrapper which utilizes SFINAE to dispatch the call to appropriate aligned allocator implementat...
Definition: large_page_alloc.h:373
Small wrapper which utilizes SFINAE to dispatch the call to appropriate aligned allocator implementat...
Definition: page_alloc.h:434
Definition: ut0new.h:2131
void * allocate_impl(size_t n_bytes)
Definition: ut0new.h:2140
const PSI_memory_key m_key
Definition: ut0new.h:2145
PSI_memory_key get_mem_key() const
Definition: ut0new.h:2138
allocator_base_pfs(PSI_memory_key key)
Definition: ut0new.h:2132
allocator_base_pfs(const allocator_base_pfs< U > &other)
Definition: ut0new.h:2135
Definition: ut0new.h:2121
void * allocate_impl(size_t n_bytes)
Definition: ut0new.h:2127
allocator_base(const allocator_base< U > &other)
Definition: ut0new.h:2125
allocator_base(PSI_memory_key)
Definition: ut0new.h:2122
Definition: ut0new.h:1331
Version control for database, common definitions, and include files.
#define UT_ARR_SIZE(a)
Definition: univ.i:524
Utilities for byte operations.
Utilities related to CPU cache.
Debug utilities for Innobase.
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:69
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:57
PSI_memory_key mem_key_ddl
Definition: ut0new.cc:60
void ut_new_boot_safe()
Setup the internal objects needed for ut::*_withkey() to operate.
Definition: ut0new.cc:137
PSI_memory_key mem_key_redo_log_archive_queue_element
PSI_memory_key mem_key_dict_stats_index_map_t
Definition: ut0new.cc:54
PSI_memory_key mem_key_buf_stat_per_index_t
Definition: ut0new.cc:50
PSI_memory_key mem_key_other
Definition: ut0new.cc:57
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:536
PSI_memory_key mem_key_fil_space_t
Definition: ut0new.cc:56
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:510
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:549
PSI_memory_key mem_key_ahi
Keys for registering allocations with performance schema.
Definition: ut0new.cc:47
void ut_new_boot()
Setup the internal objects needed for ut::*_withkey() to operate.
Definition: ut0new.cc:118
PSI_memory_key mem_key_partitioning
Definition: ut0new.cc:58
PSI_memory_key mem_key_archive
Definition: ut0new.cc:48
static constexpr const char * auto_event_names[]
List of filenames that allocate memory and are instrumented via PFS.
Definition: ut0new.h:246
PSI_memory_key mem_key_std
Definition: ut0new.cc:61
const size_t alloc_max_retries
Maximum number of retries to allocate memory.
Definition: ut0new.cc:43
PSI_memory_key mem_key_row_log_buf
Definition: ut0new.cc:59
PSI_memory_key mem_key_trx_sys_t_rw_trx_ids
Definition: ut0new.cc:62
static constexpr size_t n_auto
Definition: ut0new.h:447
PSI_memory_key mem_key_buf_buf_pool
Definition: ut0new.cc:49
constexpr size_t ut_len_without_extension(const char *file)
Find the length of the filename without its file extension.
Definition: ut0new.h:523
PSI_memory_key mem_key_undo_spaces
Definition: ut0new.cc:63
PSI_memory_key mem_key_ut_lock_free_hash_t
Definition: ut0new.cc:64
PSI_memory_key mem_key_clone
Memory key for clone.
Definition: ut0new.cc:52
PSI_memory_key mem_key_dict_stats_n_diff_on_level
Definition: ut0new.cc:55
PSI_memory_key mem_key_dict_stats_bg_recalc_pool_t
Definition: ut0new.cc:53
#define PSI_NOT_INSTRUMENTED
Definition: validate_password_imp.cc:42