127#include <type_traits>
128#include <unordered_map>
129#include <unordered_set>
245#ifdef UNIV_PFS_MEMORY
274 "fil0innodb_pages_persistence",
353 for (
size_t i = 0; i < b_len; ++i) {
365 for (
size_t i = 0;; ++i) {
366 if (
file[i] ==
'\0' ||
file[i] ==
'.') {
378 for (
size_t i = 0; i <
n_auto; ++i) {
380 return static_cast<int>(i);
405#define UT_NEW_THIS_FILE_PSI_INDEX \
406 (force_constexpr<ut_new_get_key_by_file(MY_BASENAME)>::value)
408#define UT_NEW_THIS_FILE_PSI_KEY \
409 (UT_NEW_THIS_FILE_PSI_INDEX == -1 \
410 ? ut::make_psi_memory_key(PSI_NOT_INSTRUMENTED) \
411 : ut::make_psi_memory_key(auto_event_keys[UT_NEW_THIS_FILE_PSI_INDEX]))
415#define UT_NEW_THIS_FILE_PSI_KEY ut::make_psi_memory_key(PSI_NOT_INSTRUMENTED)
421#ifdef HAVE_PSI_MEMORY_INTERFACE
441 return malloc_impl::alloc<false>(
size,
key());
477 return malloc_impl::alloc<true>(
size,
key());
518 std::size_t
size)
noexcept {
559inline void free(
void *ptr)
noexcept {
592template <
typename T,
typename... Args>
597 new (
mem)
T(std::forward<Args>(args)...);
602 return static_cast<T *
>(
mem);
635template <
typename T,
typename... Args>
638 std::forward<Args>(args)...);
715template <
typename T,
typename... Args>
719 auto mem = malloc_impl::alloc<false>(
sizeof(
T) *
sizeof...(args),
key());
725 detail::construct<T>(
mem,
sizeof(
T) * idx++, std::forward<Args>(args)));
727 for (
size_t offset = (idx - 1) *
sizeof(
T); offset != 0;
728 offset -=
sizeof(
T)) {
729 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(
mem) + offset -
736 return static_cast<T *
>(
mem);
800template <
typename T,
typename... Args>
803 std::forward<Args>(args)...);
872 auto mem = malloc_impl::alloc<false>(
sizeof(
T) *
count(),
key());
877 for (; offset <
sizeof(
T) *
count(); offset +=
sizeof(
T)) {
878 new (
reinterpret_cast<uint8_t *
>(
mem) + offset)
T{};
881 for (; offset != 0; offset -=
sizeof(
T)) {
882 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(
mem) + offset -
889 return static_cast<T *
>(
mem);
955 const auto data_len = malloc_impl::datalen(ptr);
956 for (
size_t offset = 0; offset < data_len; offset +=
sizeof(
T)) {
957 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(ptr) + offset)->~T();
991 std::size_t
size)
noexcept {
994 return page_alloc_impl::alloc(
size,
key());
1040 return page_alloc_impl::datalen(ptr);
1054 return page_alloc_impl::low_level_info(ptr);
1090 std::size_t
size)
noexcept {
1093 return large_page_alloc_impl::alloc(
size,
key());
1138 return large_page_alloc_impl::datalen(ptr);
1152 return large_page_alloc_impl::low_level_info(ptr);
1200 void *large_page_mem =
nullptr;
1201 if (large_pages_enabled) {
1299 if (!ptr)
return false;
1305 ut_a(large_page_alloc_impl::page_type(ptr) ==
1327 std::size_t alignment)
noexcept {
1330 return aligned_alloc_impl::alloc<false>(
size, alignment,
key());
1369 std::size_t alignment)
noexcept {
1372 return aligned_alloc_impl::alloc<true>(
size, alignment,
key());
1435template <
typename T,
typename... Args>
1441 new (
mem)
T(std::forward<Args>(args)...);
1446 return static_cast<T *
>(
mem);
1476template <
typename T,
typename... Args>
1479 alignment, std::forward<Args>(args)...);
1491template <
typename T>
1556template <
typename T,
typename... Args>
1565 detail::construct<T>(
mem,
sizeof(
T) * idx++, std::forward<Args>(args)));
1567 for (
size_t offset = (idx - 1) *
sizeof(
T); offset != 0;
1568 offset -=
sizeof(
T)) {
1569 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(
mem) + offset -
1576 return static_cast<T *
>(
mem);
1620template <
typename T>
1628 for (; offset <
sizeof(
T) *
count(); offset +=
sizeof(
T)) {
1629 new (
reinterpret_cast<uint8_t *
>(
mem) + offset)
T{};
1632 for (; offset != 0; offset -=
sizeof(
T)) {
1633 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(
mem) + offset -
1640 return static_cast<T *
>(
mem);
1679template <
typename T,
typename... Args>
1682 alignment, std::forward<Args>(args)...);
1721template <
typename T>
1736template <
typename T>
1740 const auto data_len = aligned_alloc_impl::datalen(ptr);
1741 for (
size_t offset = 0; offset < data_len; offset +=
sizeof(
T)) {
1742 reinterpret_cast<T *
>(
reinterpret_cast<std::uintptr_t
>(ptr) + offset)->~T();
1764template <
typename T,
size_t Alignment>
1786 template <
typename... Args>
1803 template <
typename... Args>
1807 ut::aligned_new_withkey<T>(
key,
Alignment, std::forward<Args>(args)...);
1822 operator T *()
const {
1858template <
typename T,
size_t Alignment>
1898 template <
typename... Args>
1901 ptr = ut::aligned_new_arr<T>(
Alignment, std::forward<Args>(args)...);
1936 template <
typename... Args>
1940 std::forward<Args>(args)...);
1955 operator T *()
const {
1962template <
typename T>
1966 template <
typename U>
1972template <
typename T>
1976 template <
typename U>
2020template <
typename T,
typename Allocator_base = std::conditional_t<
2033 static_assert(
alignof(
T) <=
alignof(std::max_align_t),
2034 "ut::allocator does not support over-aligned types. Use "
2035 "ut::aligned_* API to handle such types.");
2059 template <
typename U>
2061 : Allocator_base(other) {}
2068 template <
typename U>
2079 return !(*
this == other);
2106 throw std::bad_array_new_length();
2109 auto ptr = Allocator_base::allocate_impl(n_elements *
sizeof(
T));
2112 throw std::bad_alloc();
2115 return static_cast<pointer>(ptr);
2131template <
typename T>
2136template <
typename T, std::
size_t N>
2141template <
typename T, std::
size_t N>
2144template <
typename T>
2149template <
typename T>
2154template <
typename T>
2159template <
typename T>
2181template <
typename T,
typename Deleter = detail::Deleter<T>,
typename... Args>
2184 return std::unique_ptr<T, Deleter>(ut::new_<T>(std::forward<Args>(args)...));
2200template <
typename T,
typename Deleter = detail::Deleter<T>,
typename... Args>
2203 return std::unique_ptr<T, Deleter>(
2204 ut::new_withkey<T>(
key, std::forward<Args>(args)...));
2222template <
typename T,
2223 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2224std::enable_if_t<detail::is_unbounded_array_v<T>, std::unique_ptr<T, Deleter>>
2226 return std::unique_ptr<T, Deleter>(
2242template <
typename T,
2243 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2244std::enable_if_t<detail::is_unbounded_array_v<T>, std::unique_ptr<T, Deleter>>
2246 return std::unique_ptr<T, Deleter>(
2255template <
typename T,
typename... Args>
2256std::enable_if_t<detail::is_bounded_array_v<T>>
make_unique(Args &&...) =
2265template <
typename T,
typename... Args>
2278template <
typename T>
2282 detail::is_unbounded_array_v<T>,
2283 std::unique_ptr<T, detail::Array_deleter<std::remove_extent_t<T>>>,
2302template <
typename T,
typename Deleter = detail::Aligned_deleter<T>,
2306 return std::unique_ptr<T, Deleter>(
2307 ut::aligned_new<T>(alignment, std::forward<Args>(args)...));
2325template <
typename T,
typename Deleter = detail::Aligned_deleter<T>,
2329 return std::unique_ptr<T, Deleter>(
2330 ut::aligned_new_withkey<T>(
key, alignment, std::forward<Args>(args)...));
2353template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2354 std::remove_extent_t<T>>>
2355std::enable_if_t<detail::is_unbounded_array_v<T>, std::unique_ptr<T, Deleter>>
2357 return std::unique_ptr<T, Deleter>(
2379template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2380 std::remove_extent_t<T>>>
2381std::enable_if_t<detail::is_unbounded_array_v<T>, std::unique_ptr<T, Deleter>>
2383 return std::unique_ptr<T, Deleter>(
2393template <
typename T,
typename... Args>
2395 Args &&...) =
delete;
2403template <
typename T,
typename... Args>
2416template <
typename T>
2419 std::conditional_t<detail::is_unbounded_array_v<T>,
2421 std::remove_extent_t<T>>>,
2439template <
typename T,
typename Deleter = detail::Deleter<T>,
typename... Args>
2442 return std::shared_ptr<T>(ut::new_<T>(std::forward<Args>(args)...),
2459template <
typename T,
typename Deleter = detail::Deleter<T>,
typename... Args>
2462 return std::shared_ptr<T>(
2463 ut::new_withkey<T>(
key, std::forward<Args>(args)...),
Deleter{});
2482template <
typename T,
2483 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2484std::enable_if_t<detail::is_unbounded_array_v<T>, std::shared_ptr<T>>
2486 return std::shared_ptr<T>(
2505template <
typename T,
2506 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2507std::enable_if_t<detail::is_unbounded_array_v<T>, std::shared_ptr<T>>
2509 return std::shared_ptr<T>(
2529template <
typename T,
2530 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2531std::enable_if_t<detail::is_bounded_array_v<T>, std::shared_ptr<T>>
2533 return std::shared_ptr<T>(
ut::new_arr<std::remove_extent_t<T>>(
2534 ut::Count{detail::bounded_array_size_v<T>}),
2551template <
typename T,
2552 typename Deleter = detail::Array_deleter<std::remove_extent_t<T>>>
2553std::enable_if_t<detail::is_bounded_array_v<T>, std::shared_ptr<T>>
make_shared(
2555 return std::shared_ptr<T>(
2577template <
typename T,
typename Deleter = detail::Aligned_deleter<T>,
2581 return std::shared_ptr<T>(
2582 ut::aligned_new<T>(alignment, std::forward<Args>(args)...),
Deleter{});
2600template <
typename T,
typename Deleter = detail::Aligned_deleter<T>,
2604 return std::shared_ptr<T>(
2605 ut::aligned_new_withkey<T>(
key, alignment, std::forward<Args>(args)...),
2627template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2628 std::remove_extent_t<T>>>
2629std::enable_if_t<detail::is_unbounded_array_v<T>, std::shared_ptr<T>>
2631 return std::shared_ptr<T>(
2652template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2653 std::remove_extent_t<T>>>
2654std::enable_if_t<detail::is_unbounded_array_v<T>, std::shared_ptr<T>>
2656 return std::shared_ptr<T>(
2679template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2680 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>(
2685 alignment,
ut::Count{detail::bounded_array_size_v<T>}),
2704template <
typename T,
typename Deleter = detail::Aligned_array_deleter<
2705 std::remove_extent_t<T>>>
2706std::enable_if_t<detail::is_bounded_array_v<T>, std::shared_ptr<T>>
2708 return std::shared_ptr<T>(
2710 key, alignment,
ut::Count{detail::bounded_array_size_v<T>}),
2723template <
typename T>
2724using vector = std::vector<T, ut::allocator<T>>;
2727template <
typename T>
2728using list = std::list<T, ut::allocator<T>>;
2731template <
typename Key,
typename Compare = std::less<Key>>
2732using set = std::set<Key, Compare, ut::allocator<Key>>;
2734template <
typename Key>
2736 std::unordered_set<Key, std::hash<Key>, std::equal_to<Key>,
2740template <
typename Key,
typename Value,
typename Compare = std::less<Key>>
2742 std::map<Key, Value, Compare, ut::allocator<std::pair<const Key, Value>>>;
2744template <
typename Key,
typename Value,
typename Hash = std::hash<Key>,
2745 typename Key_equal = std::equal_to<Key>>
Definition: tls_cipher.cc:38
Lightweight convenience wrapper which manages a dynamically allocated array of over-aligned types.
Definition: ut0new.h:1859
void dealloc()
Invokes destructors of instances of type T, if applicable.
Definition: ut0new.h:1947
void alloc(Count count)
Allocates sufficiently large memory of dynamic storage duration to fit the array of size number of el...
Definition: ut0new.h:1881
void alloc(Args &&...args)
Allocates sufficiently large memory of dynamic storage duration to fit the array of size number of el...
Definition: ut0new.h:1899
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:1937
T * ptr
Definition: ut0new.h:1860
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:1917
~aligned_array_pointer()
Destructor.
Definition: ut0new.h:1867
Lightweight convenience wrapper which manages dynamically allocated over-aligned type.
Definition: ut0new.h:1765
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:1804
void alloc(Args &&...args)
Allocates sufficiently large memory of dynamic storage duration to fit the instance of type T at the ...
Definition: ut0new.h:1787
~aligned_pointer()
Destructor.
Definition: ut0new.h:1773
T * ptr
Definition: ut0new.h:1766
void dealloc()
Invokes the destructor of instance of type T, if applicable.
Definition: ut0new.h:1813
Allocator that allows std containers to manage their memory through ut::malloc* and ut::free library ...
Definition: ut0new.h:2023
T & reference
Definition: ut0new.h:2027
void deallocate(pointer ptr, size_type n_elements=0)
Releases the memory allocated through ut::allocator<T>::allocate().
Definition: ut0new.h:2123
const T * const_pointer
Definition: ut0new.h:2026
ptrdiff_t difference_type
Definition: ut0new.h:2031
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:2029
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:2060
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:2103
allocator(PSI_memory_key key)
Explicit constructor.
Definition: ut0new.h:2044
size_type max_size() const
Return the maximum number of objects that can be allocated by this allocator.
Definition: ut0new.h:2086
const T & const_reference
Definition: ut0new.h:2028
allocator(allocator< T, Allocator_base > &&)=default
allocator()
Default constructor, use mem_key_std.
Definition: ut0new.h:2039
bool operator!=(const ut::allocator< T, Allocator_base > &other) const
Non-equality of allocators instantiated with same types T.
Definition: ut0new.h:2078
allocator(const allocator< T, Allocator_base > &)=default
size_t size_type
Definition: ut0new.h:2030
bool operator==(const ut::allocator< T, Allocator_base > &) const
Equality of allocators instantiated with same types T.
Definition: ut0new.h:2074
T * pointer
Definition: ut0new.h:2025
Implementation bits and pieces of include/ut0new.h.
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
#define T
Definition: jit_executor_value.cc:373
#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:58
static int count
Definition: myisam_ftdump.cc:45
Instrumentation helpers for memory allocation.
std::atomic< Type > N
Definition: ut0counter.h:225
Definition: packet_based_table_with_cursor.h:36
std::string_view Key
The key type for the hash structure in HashJoinRowBuffer.
Definition: hash_join_buffer.h:108
Definition: http_server_component.cc:36
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
ValueType max(X &&first)
Definition: gtid.h:103
noexcept
The return type for any call_and_catch(f, args...) call where f(args...) returns Type.
Definition: call_and_catch.h:76
size_t size(const char *const c)
Definition: base64.h:46
Alignment
Enum class describing alignment-requirements.
Definition: lock_free_type.h:39
constexpr bool is_unbounded_array_v< T[]>
Definition: ut0new.h:2132
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:2142
constexpr bool is_bounded_array_v
Definition: ut0new.h:2135
constexpr bool is_unbounded_array_v
Definition: ut0new.h:2130
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:2140
constexpr bool is_bounded_array_v< T[N]>
Definition: ut0new.h:2137
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:1368
std::unordered_map< Key, Value, Hash, Key_equal, ut::allocator< std::pair< const Key, Value > > > unordered_map
Definition: ut0new.h:2748
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:967
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:1436
void * zalloc_withkey(PSI_memory_key_t key, std::size_t size) noexcept
Dynamically allocates zero-initialized storage of given size.
Definition: ut0new.h:474
void * malloc_withkey(PSI_memory_key_t key, std::size_t size) noexcept
Dynamically allocates storage of given size.
Definition: ut0new.h:438
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:1391
void * malloc_large_page(std::size_t size) noexcept
Dynamically allocates memory backed up by large (huge) pages.
Definition: ut0new.h:1113
std::unordered_set< Key, std::hash< Key >, std::equal_to< Key >, ut::allocator< Key > > unordered_set
Definition: ut0new.h:2737
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2720
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:1051
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2724
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:1737
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:2183
void delete_(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::new*() variants.
Definition: ut0new.h:651
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2732
void * malloc_page(std::size_t size) noexcept
Dynamically allocates system page-aligned storage of given size.
Definition: ut0new.h:1017
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:517
void delete_arr(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::new_arr*() variants.
Definition: ut0new.h:951
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:2305
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:1557
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:1149
bool free_page(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc_page*() variants.
Definition: ut0new.h:1067
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:1089
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:1135
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2742
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:2580
void * malloc(std::size_t size) noexcept
Dynamically allocates storage of given size.
Definition: ut0new.h:459
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:2284
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:1680
T * new_(Args &&...args)
Dynamically allocates storage for an object of type T.
Definition: ut0new.h:636
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2728
void free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc*(),...
Definition: ut0new.h:559
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:1326
constexpr bool WITH_PFS_MEMORY
Definition: ut0new.h:422
void aligned_delete(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the aligned_new_*() variants.
Definition: ut0new.h:1492
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:990
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:2422
void * realloc(void *ptr, std::size_t size) noexcept
Upsizes or downsizes already dynamically allocated storage to the new size.
Definition: ut0new.h:545
T * new_arr_withkey(PSI_memory_key_t key, Args &&...args)
Dynamically allocates storage for an array of T's.
Definition: ut0new.h:716
T * new_withkey(PSI_memory_key_t key, Args &&...args)
Dynamically allocates storage for an object of type T.
Definition: ut0new.h:593
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:1037
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:1166
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:2440
void aligned_free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the aligned_alloc_*() or aligned...
Definition: ut0new.h:1405
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:1349
T * new_arr(Args &&...args)
Dynamically allocates storage for an array of T's.
Definition: ut0new.h:801
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:1477
void * zalloc(std::size_t size) noexcept
Dynamically allocates zero-initialized storage of given size.
Definition: ut0new.h:495
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:100
Memory instrument information.
Definition: psi_memory_bits.h:58
static constexpr int value
Definition: ut0new.h:402
Light-weight and type-safe wrapper which serves a purpose of being able to select proper ut::new_arr*...
Definition: ut0new.h:823
Count(size_t count)
Definition: ut0new.h:824
size_t m_count
Definition: ut0new.h:826
size_t operator()() const
Definition: ut0new.h:825
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:2069
Small wrapper which utilizes SFINAE to dispatch the call to appropriate aligned allocator implementat...
Definition: aligned_alloc.h:697
Definition: ut0new.h:2160
void operator()(T *ptr)
Definition: ut0new.h:2161
Definition: ut0new.h:2155
void operator()(T *ptr)
Definition: ut0new.h:2156
Small wrapper which utilizes SFINAE to dispatch the call to appropriate allocator implementation.
Definition: alloc.h:435
Definition: ut0new.h:2150
void operator()(T *ptr)
Definition: ut0new.h:2151
Definition: ut0new.h:2145
void operator()(T *ptr)
Definition: ut0new.h:2146
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:1973
void * allocate_impl(size_t n_bytes)
Definition: ut0new.h:1982
const PSI_memory_key m_key
Definition: ut0new.h:1987
PSI_memory_key get_mem_key() const
Definition: ut0new.h:1980
allocator_base_pfs(PSI_memory_key key)
Definition: ut0new.h:1974
allocator_base_pfs(const allocator_base_pfs< U > &other)
Definition: ut0new.h:1977
Definition: ut0new.h:1963
allocator_base(const allocator_base< U > &)
Definition: ut0new.h:1967
void * allocate_impl(size_t n_bytes)
Definition: ut0new.h:1969
allocator_base(PSI_memory_key)
Definition: ut0new.h:1964
Definition: ut0new.h:1173
Version control for database, common definitions, and include files.
#define UT_ARR_SIZE(a)
Definition: univ.i:527
Utilities for byte operations.
Utilities related to CPU cache.
Debug utilities for Innobase.
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:109
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:97
PSI_memory_key mem_key_ddl
Definition: ut0new.cc:62
void ut_new_boot_safe()
Setup the internal objects needed for ut::*_withkey() to operate.
Definition: ut0new.cc:140
PSI_memory_key mem_key_mtr_t
Definition: ut0new.cc:57
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:59
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:377
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)
Compute whether a string begins with a given prefix, compile-time.
Definition: ut0new.h:351
PSI_memory_key mem_key_lock_sys
Definition: ut0new.cc:58
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:393
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:121
PSI_memory_key mem_key_partitioning
Definition: ut0new.cc:60
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:248
PSI_memory_key mem_key_std
Definition: ut0new.cc:63
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:61
PSI_memory_key mem_key_trx_sys_t_rw_trx_ids
Definition: ut0new.cc:64
static constexpr size_t n_auto
Definition: ut0new.h:342
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:364
PSI_memory_key mem_key_undo_spaces
Definition: ut0new.cc:65
PSI_memory_key mem_key_ut_lock_free_hash_t
Definition: ut0new.cc:66
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:44