MySQL  8.0.21
Source Code Documentation
ut_new_pfx_t Struct Reference

A structure that holds the necessary data for performance schema accounting. More...

#include <ut0new.h>

Public Attributes

PSI_memory_key m_key
 Performance schema key. More...
 
struct PSI_threadm_owner
 Thread owner. More...
 
size_t m_size
 Size of the allocated block in bytes, including this prepended aux structure (for ut_allocator::allocate()). More...
 

Detailed Description

A structure that holds the necessary data for performance schema accounting.

An object of this type is put in front of each allocated block of memory when allocation is done by ut_allocator::allocate(). This is because the data is needed even when freeing the memory. Users of ut_allocator::allocate_large() are responsible for maintaining this themselves. To maintain proper alignment of the pointers ut_allocator returns to the calling code, this struct is declared with alignas(std::max_align_t). This tells the compiler to insert enough padding to the struct to satisfy the strictest fundamental alignment requirement. The size of this object then becomes a multiple of the alignment requirement, this is implied by the fact that arrays are contiguous in memory. This means that when we increment a pointer to ut_new_pfx_t the resulting pointer must be aligned to the alignment requirement of std::max_align_t. Ref. C++ standard: 6.6.5 [basic.align], 11.3.4 [dcl.array]

Member Data Documentation

◆ m_key

PSI_memory_key ut_new_pfx_t::m_key

Performance schema key.

Assigned to a name at startup via PSI_MEMORY_CALL(register_memory)() and later used for accounting allocations and deallocations with PSI_MEMORY_CALL(memory_alloc)(key, size, owner) and PSI_MEMORY_CALL(memory_free)(key, size, owner).

◆ m_owner

struct PSI_thread* ut_new_pfx_t::m_owner

Thread owner.

Instrumented thread that owns the allocated memory. This state is used by the performance schema to maintain per thread statistics, when memory is given from thread A to thread B.

◆ m_size

size_t ut_new_pfx_t::m_size

Size of the allocated block in bytes, including this prepended aux structure (for ut_allocator::allocate()).

For example if InnoDB code requests to allocate 100 bytes, and sizeof(ut_new_pfx_t) is 16, then 116 bytes are allocated in total and m_size will be 116. ut_allocator::allocate_large() does not prepend this struct to the allocated block and its users are responsible for maintaining it and passing it later to ut_allocator::deallocate_large().


The documentation for this struct was generated from the following file: