Skip to content

PS-10595 [9.7]: Lazy initialization for buffer pool block latches#6040

Open
polchawa-percona wants to merge 1 commit into
percona:9.7from
polchawa-percona:PS-10595-9.7-lazy-latch-init
Open

PS-10595 [9.7]: Lazy initialization for buffer pool block latches#6040
polchawa-percona wants to merge 1 commit into
percona:9.7from
polchawa-percona:PS-10595-9.7-lazy-latch-init

Conversation

@polchawa-percona

Copy link
Copy Markdown
Contributor

https://perconadev.atlassian.net/browse/PS-10595

Buffer pool initialization speedup.

  1. Refactor buf_block_init into buf_block_init_light(), performing only lightweight setup without creating latches.
  2. Introduce lazy latch initialization for buffer blocks via buf_block_initialize_latches().
  3. Call lazy latch initialization when a block is taken from the free list for the first time.
  4. Adjust buf_pool teardown to free mutexes/rwlocks only for blocks that had latches initialized.

The patch is based on a contribution from Alexey Bychko: adf7b21

Modifications on top of the original contribution:

  • a system variable to enable this optionally;
  • the lazy initialization is done when a block is taken from the free list;
  • sharding was removed (it was broken);
  • replaced the CAS with a regular store to a non-atomic variable:
    • there are no concurrent accesses to this logic for the same block;
    • otherwise it would not be thread-safe (a thread could be scheduled out just after the CAS succeeded but before creating the mutex);
    • accesses are protected by free_list_mutex, or happen during the startup phase.

https://perconadev.atlassian.net/browse/PS-10595

Buffer pool initialization speedup. This is a contribution from
Alexey Bychko <abychko@gmail.com>, based on:
percona@adf7b21

1. Refactor buf_block_init into buf_block_init_light(), performing only
   lightweight setup without creating latches.
2. Introduce lazy latch initialization for buffer blocks via
   buf_block_initialize_latches().
3. Call lazy latch initialization when a block is taken from the free list
   for the first time.
4. Adjust buf_pool teardown to free mutexes/rwlocks only for blocks that had
   latches initialized.

Modifications on top of the original contribution:
- a system variable to enable this optionally;
- the lazy initialization is done when a block is taken from the free list;
- sharding was removed (it was broken);
- replaced the CAS with a regular store to a non-atomic variable:
  - there are no concurrent accesses to this logic for the same block;
  - otherwise it would not be thread-safe (a thread could be scheduled out
    after the CAS succeeded but before creating the mutex);
  - accesses are protected by free_list_mutex, or happen during startup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants