MySQL 8.0.40
Source Code Documentation
|
Keep track of MDL_ticket for different durations. More...
#include <mdl.h>
Classes | |
struct | Duration |
struct | Hash |
struct | Key_equal |
struct | MDL_ticket_handle |
Utility struct for representing a ticket pointer and its duration. More... | |
Public Types | |
using | List_iterator = Ticket_p_list::Iterator |
Public alias. More... | |
Public Member Functions | |
MDL_ticket_store () | |
Constructs store. More... | |
template<typename CLOS > | |
void | for_each_ticket_in_duration_list (enum_mdl_duration dur, CLOS &&clos) |
Calls the closure provided as argument for each of the MDL_tickets in the given duration. More... | |
template<typename CLOS > | |
void | for_each_ticket_in_ticket_lists (CLOS &&clos) |
Calls the closure provided as argument for each of the MDL_tickets in the store. More... | |
bool | is_empty () const |
Predicate for the emptiness of the store. More... | |
bool | is_empty (int di) const |
Predicate for the emptiness of a given duration list. More... | |
MDL_ticket * | front (int di) |
Return the first MDL_ticket for the given duration. More... | |
void | push_front (enum_mdl_duration dur, MDL_ticket *ticket) |
Push a ticket onto the list for a given duration. More... | |
void | remove (enum_mdl_duration dur, MDL_ticket *ticket) |
Remove a ticket from a duration list. More... | |
List_iterator | list_iterator (int di) const |
Return a P-list iterator to the given duration. More... | |
void | move_all_to_explicit_duration () |
Move all tickets to the explicit duration list. More... | |
void | move_explicit_to_transaction_duration () |
Move all tickets to the transaction duration list. More... | |
MDL_ticket_handle | find (const MDL_request &req) const |
Look up a ticket based on its MDL_key. More... | |
void | set_materialized () |
Mark boundary for tickets with fast_path=false, so that later calls to materialize_fast_path_locks() do not have to traverse the whole set of tickets. More... | |
MDL_ticket * | materialized_front (int di) |
Return the first ticket for which materialize_fast_path_locks already has been called for the given duration. More... | |
Private Types | |
using | Ticket_p_list = I_P_List< MDL_ticket, I_P_List_adapter< MDL_ticket, &MDL_ticket::next_in_context, &MDL_ticket::prev_in_context > > |
using | Ticket_map = std::unordered_multimap< const MDL_key *, MDL_ticket_handle, Hash, Key_equal > |
Private Member Functions | |
MDL_ticket_handle | find_in_lists (const MDL_request &req) const |
MDL_ticket_handle | find_in_hash (const MDL_request &req) const |
Private Attributes | |
Duration | m_durations [MDL_DURATION_END] |
const size_t | THRESHOLD = 256 |
If the number of tickets in the ticket store (in all durations) is equal to, or exceeds this constant the hash index (in the form of an unordered_multi_map) will be maintained and used for lookups. More... | |
const size_t | INITIAL_BUCKET_COUNT = THRESHOLD * 2 |
Initial number of buckets in the hash index. More... | |
size_t | m_count = 0 |
std::unique_ptr< Ticket_map > | m_map |
Keep track of MDL_ticket for different durations.
Maintains a hash-based secondary index into the linked lists, to speed up access by MDL_key.
Public alias.
|
private |
|
private |
|
inline |
Constructs store.
The hash index is initially empty. Filled on demand.
MDL_ticket_store::MDL_ticket_handle MDL_ticket_store::find | ( | const MDL_request & | req | ) | const |
Look up a ticket based on its MDL_key.
req | request to locate ticket for |
NDEBUG
|
private |
|
private |
|
inline |
Calls the closure provided as argument for each of the MDL_tickets in the given duration.
dur | duration list to iterate over |
clos | closure to invoke for each ticket in the list |
|
inline |
Calls the closure provided as argument for each of the MDL_tickets in the store.
clos | closure to invoke for each ticket in the store |
MDL_ticket * MDL_ticket_store::front | ( | int | di | ) |
Return the first MDL_ticket for the given duration.
di | duration to get first ticket for |
bool MDL_ticket_store::is_empty | ( | ) | const |
Predicate for the emptiness of the store.
bool MDL_ticket_store::is_empty | ( | int | di | ) | const |
Predicate for the emptiness of a given duration list.
di | the duration to check |
|
inline |
Return a P-list iterator to the given duration.
di | duration list index |
MDL_ticket * MDL_ticket_store::materialized_front | ( | int | di | ) |
Return the first ticket for which materialize_fast_path_locks already has been called for the given duration.
di | duration list index |
void MDL_ticket_store::move_all_to_explicit_duration | ( | ) |
Move all tickets to the explicit duration list.
void MDL_ticket_store::move_explicit_to_transaction_duration | ( | ) |
Move all tickets to the transaction duration list.
void MDL_ticket_store::push_front | ( | enum_mdl_duration | dur, |
MDL_ticket * | ticket | ||
) |
Push a ticket onto the list for a given duration.
dur | duration list to push into |
ticket | to push |
void MDL_ticket_store::remove | ( | enum_mdl_duration | dur, |
MDL_ticket * | ticket | ||
) |
Remove a ticket from a duration list.
Note that since the underlying list is an intrusive linked list there is no guarantee that the ticket is actually in the duration list. It will be removed from which ever list it is in.
void MDL_ticket_store::set_materialized | ( | ) |
Mark boundary for tickets with fast_path=false, so that later calls to materialize_fast_path_locks() do not have to traverse the whole set of tickets.
|
private |
Initial number of buckets in the hash index.
THRESHOLD is chosen to get a fill-factor of 50% when reaching the threshold value.
|
private |
|
private |
|
private |
|
private |
If the number of tickets in the ticket store (in all durations) is equal to, or exceeds this constant the hash index (in the form of an unordered_multi_map) will be maintained and used for lookups.
The value 256 is chosen as it has worked well in benchmarks.