32#ifndef detail_ut_alloc_h
33#define detail_ut_alloc_h
74 template <
bool Zero_initialized>
75 static inline void *
alloc(std::size_t size)
noexcept {
76 return Alloc_fn::alloc<Zero_initialized>(size);
87 static inline void *
realloc(
void *ptr, std::size_t size)
noexcept {
153 "metadata_len must be divisible by alignof(max_align_t)");
161 template <
bool Zero_initialized>
162 static inline void *
alloc(std::size_t size)
noexcept {
164 auto mem = Alloc_fn::alloc<Zero_initialized>(total_len);
173 static inline void free(
void *ptr)
noexcept {
192 static inline void *
deduce(
void *ptr)
noexcept {
271 template <
bool Zero_initialized>
272 static inline void *
alloc(std::size_t size,
275 auto mem = Alloc_fn::alloc<Zero_initialized>(total_len);
278#ifdef HAVE_PSI_MEMORY_INTERFACE
316 return Alloc_pfs::alloc<false>(size,
key);
325#ifdef HAVE_PSI_MEMORY_INTERFACE
332 (key_curr, datalen_curr, owner_curr);
340#ifdef HAVE_PSI_MEMORY_INTERFACE
367#ifdef HAVE_PSI_MEMORY_INTERFACE
405template <
bool Pfs_memory_instrumentation_on,
bool Array_specialization>
419template <
bool Array_specialization>
425template <
bool Pfs_memory_instrumentation_on,
bool Array_specialization>
428 Array_specialization>
::type;
433template <
typename Impl>
435 template <
bool Zero_initialized,
typename T = Impl>
438 return Impl::template alloc<Zero_initialized>(size,
key);
440 template <
bool Zero_initialized,
typename T = Impl>
443 return Impl::template alloc<Zero_initialized>(size);
445 template <
typename T = Impl>
450 template <
typename T = Impl>
456 static inline size_t datalen(
void *ptr) {
return Impl::datalen(ptr); }
457 template <
typename T = Impl>
462 template <
typename T = Impl>
#define PSI_MEMORY_CALL(M)
Definition: psi_memory.h:35
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
Header for compiler-dependent features.
constexpr bool unlikely(bool expr)
Definition: my_compiler.h:57
Instrumentation helpers for memory allocation.
Definition: ut0tuple.h:56
static PSI_memory_key memory_alloc(PSI_memory_key, size_t, struct PSI_thread **owner)
Definition: psi_memory_v2_empty.cc:34
static void memory_free(PSI_memory_key, size_t, struct PSI_thread *)
Definition: psi_memory_v2_empty.cc:52
constexpr size_t calc_align(size_t n, size_t m)
Calculates the smallest multiple of m that is not smaller than n when m is a power of two.
Definition: helper.h:44
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
This file contains a set of libraries providing overloads for regular dynamic allocation routines whi...
Definition: aligned_alloc.h:47
required string key
Definition: replication_asynchronous_connection_failover.proto:59
required string type
Definition: replication_group_member_actions.proto:33
static MEM_ROOT mem
Definition: sql_servers.cc:99
Implementation bits and pieces for PFS metadata handling.
Small wrapper which utilizes SFINAE to dispatch the call to appropriate allocator implementation.
Definition: alloc.h:434
static void free(void *ptr)
Definition: alloc.h:455
static std::enable_if<!T::is_pfs_instrumented_v, void * >::type alloc(size_t size, PSI_memory_key)
Definition: alloc.h:442
static std::enable_if<!T::is_pfs_instrumented_v, void * >::type realloc(void *ptr, size_t size, PSI_memory_key)
Definition: alloc.h:452
static std::enable_if< T::is_pfs_instrumented_v, size_t >::type pfs_overhead()
Definition: alloc.h:459
static std::enable_if< T::is_pfs_instrumented_v, void * >::type realloc(void *ptr, size_t size, PSI_memory_key key)
Definition: alloc.h:447
static std::enable_if< T::is_pfs_instrumented_v, void * >::type alloc(size_t size, PSI_memory_key key)
Definition: alloc.h:437
static std::enable_if<!T::is_pfs_instrumented_v, size_t >::type pfs_overhead()
Definition: alloc.h:464
static size_t datalen(void *ptr)
Definition: alloc.h:456
Specialization of allocation routines for non-extended alignment types but which in comparison to All...
Definition: alloc.h:136
static void * deduce(void *ptr) noexcept
Helper function which deduces the original pointer returned by Alloc_arr::alloc() from a pointer whic...
Definition: alloc.h:192
static constexpr auto metadata_len
This is how much the metadata (ALLOC-ARR-META) segment will be big.
Definition: alloc.h:138
static void * alloc(std::size_t size) noexcept
Sanity check so that we can be sure that our metadata segment can fit the datalen_t.
Definition: alloc.h:162
size_t datalen_t
This is the type we will be using to store the size of an array.
Definition: alloc.h:141
static void free(void *ptr) noexcept
Releases storage dynamically allocated through Alloc_arr::alloc().
Definition: alloc.h:173
static datalen_t datalen(void *ptr)
Returns the size of an array in bytes.
Definition: alloc.h:184
static void free(void *ptr)
Definition: allocator_traits.h:104
static void * realloc(void *ptr, size_t nbytes)
Definition: allocator_traits.h:100
Allocation routines for non-extended alignment types, as opposed to Aligned_alloc_pfs for example,...
Definition: alloc.h:254
static void * realloc(PFS_metadata::data_segment_ptr data, std::size_t size, pfs_metadata::pfs_memory_key_t key)
Reallocates the given area of memory, which if not nullptr, must be previously allocated by Alloc_pfs...
Definition: alloc.h:311
static void free(PFS_metadata::data_segment_ptr data) noexcept
Releases storage dynamically allocated through Alloc_pfs::alloc().
Definition: alloc.h:364
static constexpr auto metadata_len
This is how much the metadata (PFS-META | VARLEN | PFS-META-OFFSET) segment will be big.
Definition: alloc.h:260
static size_t datalen(PFS_metadata::data_segment_ptr data)
Returns the number of bytes requested to be allocated.
Definition: alloc.h:389
static void * deduce(PFS_metadata::data_segment_ptr data) noexcept
Helper function which deduces the original pointer returned by Alloc_pfs::alloc() from a pointer whic...
Definition: alloc.h:397
static void * alloc(std::size_t size, pfs_metadata::pfs_memory_key_t key)
Dynamically allocates storage of given size at the address aligned to the requested alignment.
Definition: alloc.h:272
Allocation routines for non-extended alignment types, as opposed to Aligned_alloc for example.
Definition: alloc.h:67
static void * alloc(std::size_t size) noexcept
Dynamically allocates storage of given size.
Definition: alloc.h:75
static void free(void *ptr) noexcept
Releases storage dynamically allocated through Alloc::alloc() or Alloc::realloc().
Definition: alloc.h:97
static void * realloc(void *ptr, std::size_t size) noexcept
Reallocates the given area of memory.
Definition: alloc.h:87
Simple allocator traits.
Definition: allocator_traits.h:81
Simple utility metafunction which selects appropriate allocator variant (implementation) depending on...
Definition: alloc.h:406