MySQL 8.0.29
Source Code Documentation
ut::detail Namespace Reference

Classes

struct  Aligned_alloc
 Aligned allocation routines. More...
 
struct  Aligned_alloc_
 Small wrapper which utilizes SFINAE to dispatch the call to appropriate aligned allocator implementation. More...
 
struct  Aligned_alloc_impl
 
struct  Aligned_alloc_metadata
 Memory layout representation of metadata segment guaranteed by the inner workings of Aligned_alloc_impl. More...
 
struct  Aligned_alloc_pfs
 Aligned allocation routines which are instrumented through PFS (performance-schema). More...
 
struct  Aligned_array_deleter
 
struct  Aligned_deleter
 
struct  Alloc
 Allocation routines for non-extended alignment types, as opposed to Aligned_alloc for example. More...
 
struct  Alloc_
 Small wrapper which utilizes SFINAE to dispatch the call to appropriate allocator implementation. More...
 
struct  Alloc_arr
 Specialization of allocation routines for non-extended alignment types but which in comparison to Alloc are providing support for arrays. More...
 
struct  Alloc_fn
 Simple wrapping type around malloc, calloc and friends. More...
 
struct  Alloc_pfs
 Allocation routines for non-extended alignment types, as opposed to Aligned_alloc_pfs for example, but which are instrumented through PFS (performance-schema). More...
 
struct  allocator_base
 
struct  allocator_base_pfs
 
struct  allocator_traits
 Simple allocator traits. More...
 
struct  Array_deleter
 
struct  Deleter
 
struct  Large_alloc_
 Small wrapper which utilizes SFINAE to dispatch the call to appropriate aligned allocator implementation. More...
 
struct  Large_page_alloc
 Allocation routines which are purposed for allocating memory through the means of what is known as large (huge) pages. More...
 
struct  Large_page_alloc_pfs
 Allocation routines which are purposed for allocating memory through the means of what is known as large (huge) pages. More...
 
struct  Page_alloc
 Allocation routines which are purposed for allocating system page-aligned memory. More...
 
struct  Page_alloc_
 Small wrapper which utilizes SFINAE to dispatch the call to appropriate aligned allocator implementation. More...
 
struct  Page_alloc_metadata
 Helper struct implementing the type which represents the metadata for all types of page-aligned allocations, be it regular pages or huge-pages. More...
 
struct  Page_alloc_metadata_pfs
 Helper struct implementing the type which represents the metadata for all types of PFS-aware page-aligned allocations, be it regular pages or huge-pages. More...
 
struct  Page_alloc_pfs
 Allocation routines which are purposed for allocating system page-aligned memory. More...
 
struct  PFS_metadata
 Memory layout representation of PFS metadata segment that is used by the allocator variants which also want to trace the memory consumption through PFS (PSI) interface. More...
 
struct  select_alloc_impl
 Simple utility metafunction which selects appropriate allocator variant (implementation) depending on the input parameter(s). More...
 
struct  select_alloc_impl< true >
 
struct  select_large_page_alloc_impl
 Simple utility metafunction which selects appropriate allocator variant (implementation) depending on the input parameter(s). More...
 
struct  select_large_page_alloc_impl< true >
 
struct  select_malloc_impl
 Simple utility metafunction which selects appropriate allocator variant (implementation) depending on the input parameter(s). More...
 
struct  select_malloc_impl< false, false >
 
struct  select_malloc_impl< false, true >
 
struct  select_malloc_impl< true, Array_specialization >
 
struct  select_page_alloc_impl
 Simple utility meta-function which selects appropriate allocator variant (implementation) depending on the input parameter(s). More...
 
struct  select_page_alloc_impl< true >
 

Typedefs

template<bool Pfs_memory_instrumentation_on>
using select_alloc_impl_t = typename select_alloc_impl< Pfs_memory_instrumentation_on >::type
 Just a small helper type which saves us some keystrokes. More...
 
template<bool Pfs_memory_instrumentation_on, bool Array_specialization>
using select_malloc_impl_t = typename select_malloc_impl< Pfs_memory_instrumentation_on, Array_specialization >::type
 Just a small helper type which saves us some keystrokes. More...
 
template<bool Pfs_memory_instrumentation_on>
using select_large_page_alloc_impl_t = typename select_large_page_alloc_impl< Pfs_memory_instrumentation_on >::type
 Just a small helper type which saves us some keystrokes. More...
 
template<bool Pfs_memory_instrumentation_on>
using select_page_alloc_impl_t = typename select_page_alloc_impl< Pfs_memory_instrumentation_on >::type
 Just a small helper type which saves us some keystrokes. More...
 

Enumerations

enum class  Page_type { system_page = 0x10 , large_page = 0x20 }
 Types of pages currently supported by ut:: library functions. More...
 

Functions

void * malloc (size_t nbytes)
 
void * calloc (size_t nbytes)
 
void * realloc (void *ptr, size_t nbytes)
 
void free (void *ptr)
 
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. More...
 
constexpr size_t pow2_round (size_t n, size_t m)
 Calculates the biggest multiple of m that is not bigger than n when m is a power of two. More...
 
constexpr size_t round_to_next_multiple (size_t n, size_t m)
 Calculates the next multiple of m that is bigger or equal to n. More...
 
void * large_page_aligned_alloc (size_t n_bytes)
 Allocates memory backed by large (huge) pages. More...
 
bool large_page_aligned_free (void *ptr, size_t n_bytes)
 Releases memory backed by large (huge) pages. More...
 
size_t large_page_size ()
 Queries the current size of large (huge) pages on running system. More...
 
std::vector< size_t > large_page_all_supported_sizes ()
 Queries all possible page-sizes. More...
 
void * page_aligned_alloc (size_t n_bytes)
 Allocates system page-aligned memory. More...
 
bool page_aligned_free (void *ptr, size_t n_bytes)
 Releases system page-aligned storage. More...
 
template<typename T , typename Tuple , size_t... Args_index_seq>
void construct_impl (void *mem, size_t offset, Tuple &&tuple, std::index_sequence< Args_index_seq... >)
 
template<typename T , typename Tuple >
void construct (void *mem, size_t offset, Tuple &&tuple)
 

Variables

static constexpr auto SUPER_PAGE_SIZE = VM_FLAGS_SUPERPAGE_SIZE_2MB
 Superpage size to be used (2MB). More...
 
template<typename >
constexpr bool is_unbounded_array_v = false
 
template<typename T >
constexpr bool is_unbounded_array_v< T[]> = true
 
template<typename >
constexpr bool is_bounded_array_v = false
 
template<typename T , std::size_t N>
constexpr bool is_bounded_array_v< T[N]> = true
 
template<typename >
constexpr size_t bounded_array_size_v = 0
 
template<typename T , std::size_t N>
constexpr size_t bounded_array_size_v< T[N]> = N
 

Typedef Documentation

◆ select_alloc_impl_t

template<bool Pfs_memory_instrumentation_on>
using ut::detail::select_alloc_impl_t = typedef typename select_alloc_impl<Pfs_memory_instrumentation_on>::type

Just a small helper type which saves us some keystrokes.

◆ select_large_page_alloc_impl_t

template<bool Pfs_memory_instrumentation_on>
using ut::detail::select_large_page_alloc_impl_t = typedef typename select_large_page_alloc_impl<Pfs_memory_instrumentation_on>::type

Just a small helper type which saves us some keystrokes.

◆ select_malloc_impl_t

template<bool Pfs_memory_instrumentation_on, bool Array_specialization>
using ut::detail::select_malloc_impl_t = typedef typename select_malloc_impl<Pfs_memory_instrumentation_on, Array_specialization>::type

Just a small helper type which saves us some keystrokes.

◆ select_page_alloc_impl_t

template<bool Pfs_memory_instrumentation_on>
using ut::detail::select_page_alloc_impl_t = typedef typename select_page_alloc_impl<Pfs_memory_instrumentation_on>::type

Just a small helper type which saves us some keystrokes.

Enumeration Type Documentation

◆ Page_type

enum class ut::detail::Page_type
strong

Types of pages currently supported by ut:: library functions.

Enumerator
system_page 
large_page 

Function Documentation

◆ calc_align()

constexpr size_t ut::detail::calc_align ( size_t  n,
size_t  m 
)
constexpr

Calculates the smallest multiple of m that is not smaller than n when m is a power of two.

In other words, rounds n up to m * k.

Parameters
nin: number to round up
min: alignment, must be a power of two
Returns
n rounded up to the smallest possible integer multiple of m

◆ calloc()

void * ut::detail::calloc ( size_t  nbytes)
inline

◆ construct()

template<typename T , typename Tuple >
void ut::detail::construct ( void *  mem,
size_t  offset,
Tuple &&  tuple 
)
inline

◆ construct_impl()

template<typename T , typename Tuple , size_t... Args_index_seq>
void ut::detail::construct_impl ( void *  mem,
size_t  offset,
Tuple &&  tuple,
std::index_sequence< Args_index_seq... >   
)
inline

◆ free()

void ut::detail::free ( void *  ptr)
inline

◆ large_page_aligned_alloc()

void * ut::detail::large_page_aligned_alloc ( size_t  n_bytes)
inline

Allocates memory backed by large (huge) pages.

Parameters
[in]n_bytesSize of storage (in bytes) requested to be allocated.
Returns
Pointer to the allocated storage. nullptr if allocation failed.

◆ large_page_aligned_free()

bool ut::detail::large_page_aligned_free ( void *  ptr,
size_t  n_bytes 
)
inline

Releases memory backed by large (huge) pages.

Parameters
[in]ptrPointer to large (huge) page aligned storage.
[in]n_bytesSize of the storage.
Returns
Returns true if releasing the large (huge) page succeeded.

◆ large_page_all_supported_sizes()

std::vector< size_t > ut::detail::large_page_all_supported_sizes ( )
inline

Queries all possible page-sizes.

Solaris allows picking one at runtime which is contrary to how Linux, Windows and OSX does.

Returns
std::vector of supported page sizes (in bytes).

◆ large_page_size()

size_t ut::detail::large_page_size ( )
inline

Queries the current size of large (huge) pages on running system.

Queries the page-size that is next to the minimum supported page-size Lowest supported page size is usually 4K on x86_64 whereas it's 8K on SPARC.

Returns
Large (huge) page size in bytes.
Minimum supported large (huge) page size in bytes.

◆ malloc()

void * ut::detail::malloc ( size_t  nbytes)
inline

◆ page_aligned_alloc()

void * ut::detail::page_aligned_alloc ( size_t  n_bytes)
inline

Allocates system page-aligned memory.

Parameters
[in]n_bytesSize of storage (in bytes) requested to be allocated.
Returns
Pointer to the allocated storage. nullptr if allocation failed.

◆ page_aligned_free()

bool ut::detail::page_aligned_free ( void *  ptr,
size_t  n_bytes 
)
inline

Releases system page-aligned storage.

Parameters
[in]ptrPointer to system page-aligned storage.
[in]n_bytesSize of the storage.
Returns
True if releasing the page-aligned memory was successful.

◆ pow2_round()

constexpr size_t ut::detail::pow2_round ( size_t  n,
size_t  m 
)
constexpr

Calculates the biggest multiple of m that is not bigger than n when m is a power of two.

In other words, rounds n down to m * k.

Parameters
nin: number to round down
min: alignment, must be a power of two
Returns
n rounded down to the biggest possible integer multiple of m

◆ realloc()

void * ut::detail::realloc ( void *  ptr,
size_t  nbytes 
)
inline

◆ round_to_next_multiple()

constexpr size_t ut::detail::round_to_next_multiple ( size_t  n,
size_t  m 
)
constexpr

Calculates the next multiple of m that is bigger or equal to n.

Parameters
nin: number to find the next multiple of in terms of m
min: alignment, must be a power of two
Returns
next next multiple of m bigger or equal than n

Variable Documentation

◆ bounded_array_size_v

template<typename >
constexpr size_t ut::detail::bounded_array_size_v = 0
constexpr

◆ bounded_array_size_v< T[N]>

template<typename T , std::size_t N>
constexpr size_t ut::detail::bounded_array_size_v< T[N]> = N
constexpr

◆ is_bounded_array_v

template<typename >
constexpr bool ut::detail::is_bounded_array_v = false
constexpr

◆ is_bounded_array_v< T[N]>

template<typename T , std::size_t N>
constexpr bool ut::detail::is_bounded_array_v< T[N]> = true
constexpr

◆ is_unbounded_array_v

template<typename >
constexpr bool ut::detail::is_unbounded_array_v = false
constexpr

◆ is_unbounded_array_v< T[]>

template<typename T >
constexpr bool ut::detail::is_unbounded_array_v< T[]> = true
constexpr

◆ SUPER_PAGE_SIZE

constexpr auto ut::detail::SUPER_PAGE_SIZE = VM_FLAGS_SUPERPAGE_SIZE_2MB
staticconstexpr

Superpage size to be used (2MB).