MySQL 8.4.2
Source Code Documentation
Btree_multi::Bulk_extent_allocator Class Reference

#include <btr0mtib.h>

Classes

struct  Extent_cache
 

Public Types

enum class  Type { PAGE , EXTENT }
 

Public Member Functions

 ~Bulk_extent_allocator ()
 Destructor to ensure thread stop. More...
 
uint64_t init (dict_table_t *table, trx_t *trx, size_t size, size_t num_threads, bool in_pages)
 Check size and set extent allocator size parameters. More...
 
void start ()
 
void stop ()
 Stop extent allocator thread, if active. More...
 
dberr_t allocate (bool is_leaf, bool alloc_page, Page_range_t &range, std::function< void()> &fn_wait_begin, std::function< void()> &fn_wait_end)
 Allocate a page range - currently ans Extent. More...
 

Private Member Functions

dberr_t run ()
 Exetent thread executor. More...
 
dberr_t allocate_extents (bool is_leaf, size_t num_extents)
 Allocate extents and fill the cache. More...
 
void allocator_wait () const
 Allocator wait function. More...
 
bool check (size_t &n_leaf, size_t &n_non_leaf, bool &trigger)
 Check if leaf and non-leaf extent cache needs to be filled. More...
 
dberr_t allocate_extent (bool is_leaf, mtr_t &mtr, Page_range_t &range)
 Allocate one extent. More...
 
dberr_t allocate_page (bool is_leaf, Page_range_t &range)
 Allocate one page. More...
 
bool is_interrupted ()
 

Private Attributes

std::thread m_thread
 Bulk extent allocator. More...
 
size_t m_consumer_wait_count {}
 Number of times consumer(s) had to wait. More...
 
size_t m_allocator_wait_count {}
 Number of times allocator had to wait. More...
 
std::chrono::microseconds m_consumer_wait_time
 Total consumer wait time in micro seconds. More...
 
std::chrono::microseconds m_allocator_wait_time
 Total allocator wait time in micro seconds. More...
 
Type m_type = Type::EXTENT
 Page range type. More...
 
Extent_cache m_leaf_extents
 Cached leaf extents. More...
 
Extent_cache m_non_leaf_extents
 Cached non-leaf extents. More...
 
std::mutex m_mutex
 This mutex protects the m_queue. More...
 
std::condition_variable m_allocator_condition
 Condition variable for allocator thread. More...
 
std::condition_variable m_consumer_condition
 Condition variable for extent consumer threads. More...
 
bool m_stop {false}
 Flag to indicate if the bulk allocator thread should stop. More...
 
dberr_t m_error = DB_SUCCESS
 Error code, protected by m_mutex. More...
 
dict_table_tm_table {}
 Innodb dictionary table object. More...
 
trx_tm_trx {}
 Innodb transaction - used for checking interrupt. More...
 
size_t m_concurrency {}
 Number of concurrent consumers. More...
 

Static Private Attributes

static constexpr size_t S_MAX_RANGES = 2 * 1024
 Upper bound for max ranges. More...
 
static constexpr size_t S_BULK_EXTEND_SIZE_MAX = 64
 Maximum size by which the tablespace is extended each time. More...
 

Member Enumeration Documentation

◆ Type

Enumerator
PAGE 

Allocate by Page.

EXTENT 

Allocate by extent.

Constructor & Destructor Documentation

◆ ~Bulk_extent_allocator()

Btree_multi::Bulk_extent_allocator::~Bulk_extent_allocator ( )
inline

Destructor to ensure thread stop.

Member Function Documentation

◆ allocate()

dberr_t Btree_multi::Bulk_extent_allocator::allocate ( bool  is_leaf,
bool  alloc_page,
Page_range_t range,
std::function< void()> &  fn_wait_begin,
std::function< void()> &  fn_wait_end 
)

Allocate a page range - currently ans Extent.

Parameters
[in]is_leaftrue if leaf segment, otherwise non-leaf segment
[in]alloc_pageif true, allocate in pages otherwise allocate extent
[out]rangepage range
[in,out]fn_wait_beginbegin callback if wait is needed
[in,out]fn_wait_endend callback if wait is needed
Returns
Innodb error code.

◆ allocate_extent()

dberr_t Btree_multi::Bulk_extent_allocator::allocate_extent ( bool  is_leaf,
mtr_t mtr,
Page_range_t range 
)
private

Allocate one extent.

Parameters
[in]is_leaftrue if leaf segment, otherwise non-leaf segment
[in,out]mtrmini tranaction to be used for allocation
[out]rangepage rannge for the extent
Returns
innodb error code.

◆ allocate_extents()

dberr_t Btree_multi::Bulk_extent_allocator::allocate_extents ( bool  is_leaf,
size_t  num_extents 
)
private

Allocate extents and fill the cache.

Parameters
[in]is_leaftrue if leaf segment, otherwise non-leaf segment
[in]num_extentsnumber of extents to allocate
Returns
innodb error code.

◆ allocate_page()

dberr_t Btree_multi::Bulk_extent_allocator::allocate_page ( bool  is_leaf,
Page_range_t range 
)
private

Allocate one page.

Parameters
[in]is_leaftrue if leaf segment, otherwise non-leaf segment
[out]rangepage rannge for the page
Returns
innodb error code.

◆ allocator_wait()

void Btree_multi::Bulk_extent_allocator::allocator_wait ( ) const
private

Allocator wait function.

◆ check()

bool Btree_multi::Bulk_extent_allocator::check ( size_t &  n_leaf,
size_t &  n_non_leaf,
bool &  trigger 
)
private

Check if leaf and non-leaf extent cache needs to be filled.

Parameters
[out]n_leafnumber of leaf extents to allocate
[out]n_non_leafnumber of non-leaf extents to allocate
[out]triggertrue if consumers should be triggered
Returns
true if allocator should stop.

◆ init()

uint64_t Btree_multi::Bulk_extent_allocator::init ( dict_table_t table,
trx_t trx,
size_t  size,
size_t  num_threads,
bool  in_pages 
)

Check size and set extent allocator size parameters.

Parameters
[in]tableInnodb dictionary table object
[in]trxtransaction performing bulk load
[in]sizetotal data size to be loaded
[in]num_threadsnumber of concurrent threads
[in]in_pagesif true, allocate in pages
Returns
tablespace extend size in bytes.

◆ is_interrupted()

bool Btree_multi::Bulk_extent_allocator::is_interrupted ( )
private
Returns
true if operation is interrupted.

◆ run()

dberr_t Btree_multi::Bulk_extent_allocator::run ( )
private

Exetent thread executor.

Returns
innodb error code.

◆ start()

void Btree_multi::Bulk_extent_allocator::start ( )

◆ stop()

void Btree_multi::Bulk_extent_allocator::stop ( )

Stop extent allocator thread, if active.

Member Data Documentation

◆ m_allocator_condition

std::condition_variable Btree_multi::Bulk_extent_allocator::m_allocator_condition
mutableprivate

Condition variable for allocator thread.

◆ m_allocator_wait_count

size_t Btree_multi::Bulk_extent_allocator::m_allocator_wait_count {}
mutableprivate

Number of times allocator had to wait.

◆ m_allocator_wait_time

std::chrono::microseconds Btree_multi::Bulk_extent_allocator::m_allocator_wait_time
mutableprivate

Total allocator wait time in micro seconds.

◆ m_concurrency

size_t Btree_multi::Bulk_extent_allocator::m_concurrency {}
private

Number of concurrent consumers.

◆ m_consumer_condition

std::condition_variable Btree_multi::Bulk_extent_allocator::m_consumer_condition
mutableprivate

Condition variable for extent consumer threads.

◆ m_consumer_wait_count

size_t Btree_multi::Bulk_extent_allocator::m_consumer_wait_count {}
mutableprivate

Number of times consumer(s) had to wait.

◆ m_consumer_wait_time

std::chrono::microseconds Btree_multi::Bulk_extent_allocator::m_consumer_wait_time
mutableprivate

Total consumer wait time in micro seconds.

◆ m_error

dberr_t Btree_multi::Bulk_extent_allocator::m_error = DB_SUCCESS
private

Error code, protected by m_mutex.

◆ m_leaf_extents

Extent_cache Btree_multi::Bulk_extent_allocator::m_leaf_extents
private

Cached leaf extents.

◆ m_mutex

std::mutex Btree_multi::Bulk_extent_allocator::m_mutex
mutableprivate

This mutex protects the m_queue.

◆ m_non_leaf_extents

Extent_cache Btree_multi::Bulk_extent_allocator::m_non_leaf_extents
private

Cached non-leaf extents.

◆ m_stop

bool Btree_multi::Bulk_extent_allocator::m_stop {false}
private

Flag to indicate if the bulk allocator thread should stop.

◆ m_table

dict_table_t* Btree_multi::Bulk_extent_allocator::m_table {}
private

Innodb dictionary table object.

◆ m_thread

std::thread Btree_multi::Bulk_extent_allocator::m_thread
private

Bulk extent allocator.

◆ m_trx

trx_t* Btree_multi::Bulk_extent_allocator::m_trx {}
private

Innodb transaction - used for checking interrupt.

◆ m_type

Type Btree_multi::Bulk_extent_allocator::m_type = Type::EXTENT
private

Page range type.

◆ S_BULK_EXTEND_SIZE_MAX

constexpr size_t Btree_multi::Bulk_extent_allocator::S_BULK_EXTEND_SIZE_MAX = 64
staticconstexprprivate

Maximum size by which the tablespace is extended each time.

◆ S_MAX_RANGES

constexpr size_t Btree_multi::Bulk_extent_allocator::S_MAX_RANGES = 2 * 1024
staticconstexprprivate

Upper bound for max ranges.


The documentation for this class was generated from the following files: