You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

266 lines
9.8 KiB

20 years ago
branches/zip: Improve the LRU algorithm with a separate unzip_LRU list of blocks that contains uncompressed and compressed frames. This patch was designed by Heikki and Inaam, implemented by Inaam, and refined and reviewed by Marko and Sunny. buf_buddy_n_frames, buf_buddy_min_n_frames, buf_buddy_max_n_frames: Remove. buf_page_belongs_to_unzip_LRU(): New predicate: bpage->zip.data && buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE. buf_pool_t, buf_block_t: Add the linked list unzip_LRU. A block in the regular LRU list is in unzip_LRU iff buf_page_belongs_to_unzip_LRU() holds. buf_LRU_free_block(): Add a third return value to refine the case "cannot free the block". buf_LRU_search_and_free_block(): Update the documentation to reflect the implementation. buf_LRU_stat_t, buf_LRU_stat_cur, buf_LRU_stat_sum, buf_LRU_stat_arr[]: Statistics for the unzip_LRU algorithm. buf_LRU_stat_update(): New function: Update the statistics. Called once per second by srv_error_monitor_thread(). buf_LRU_validate(): Validate the unzip_LRU list as well. buf_LRU_evict_from_unzip_LRU(): New predicate: Use the unzip_LRU before falling back to the regular LRU? buf_LRU_free_from_unzip_LRU_list(), buf_LRU_free_from_common_LRU_list(): Subfunctions of buf_LRU_search_and_free_block(). buf_LRU_search_and_free_block(): Reimplement. Try to evict an uncompressed page from the unzip_LRU list before falling back to evicting an entire block from the common LRU list. buf_unzip_LRU_remove_block_if_needed(): New function. buf_unzip_LRU_add_block(): New function: Add a block to the unzip_LRU list.
18 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
branches/zip: Improve the LRU algorithm with a separate unzip_LRU list of blocks that contains uncompressed and compressed frames. This patch was designed by Heikki and Inaam, implemented by Inaam, and refined and reviewed by Marko and Sunny. buf_buddy_n_frames, buf_buddy_min_n_frames, buf_buddy_max_n_frames: Remove. buf_page_belongs_to_unzip_LRU(): New predicate: bpage->zip.data && buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE. buf_pool_t, buf_block_t: Add the linked list unzip_LRU. A block in the regular LRU list is in unzip_LRU iff buf_page_belongs_to_unzip_LRU() holds. buf_LRU_free_block(): Add a third return value to refine the case "cannot free the block". buf_LRU_search_and_free_block(): Update the documentation to reflect the implementation. buf_LRU_stat_t, buf_LRU_stat_cur, buf_LRU_stat_sum, buf_LRU_stat_arr[]: Statistics for the unzip_LRU algorithm. buf_LRU_stat_update(): New function: Update the statistics. Called once per second by srv_error_monitor_thread(). buf_LRU_validate(): Validate the unzip_LRU list as well. buf_LRU_evict_from_unzip_LRU(): New predicate: Use the unzip_LRU before falling back to the regular LRU? buf_LRU_free_from_unzip_LRU_list(), buf_LRU_free_from_common_LRU_list(): Subfunctions of buf_LRU_search_and_free_block(). buf_LRU_search_and_free_block(): Reimplement. Try to evict an uncompressed page from the unzip_LRU list before falling back to evicting an entire block from the common LRU list. buf_unzip_LRU_remove_block_if_needed(): New function. buf_unzip_LRU_add_block(): New function: Add a block to the unzip_LRU list.
18 years ago
20 years ago
branches/zip: Improve the LRU algorithm with a separate unzip_LRU list of blocks that contains uncompressed and compressed frames. This patch was designed by Heikki and Inaam, implemented by Inaam, and refined and reviewed by Marko and Sunny. buf_buddy_n_frames, buf_buddy_min_n_frames, buf_buddy_max_n_frames: Remove. buf_page_belongs_to_unzip_LRU(): New predicate: bpage->zip.data && buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE. buf_pool_t, buf_block_t: Add the linked list unzip_LRU. A block in the regular LRU list is in unzip_LRU iff buf_page_belongs_to_unzip_LRU() holds. buf_LRU_free_block(): Add a third return value to refine the case "cannot free the block". buf_LRU_search_and_free_block(): Update the documentation to reflect the implementation. buf_LRU_stat_t, buf_LRU_stat_cur, buf_LRU_stat_sum, buf_LRU_stat_arr[]: Statistics for the unzip_LRU algorithm. buf_LRU_stat_update(): New function: Update the statistics. Called once per second by srv_error_monitor_thread(). buf_LRU_validate(): Validate the unzip_LRU list as well. buf_LRU_evict_from_unzip_LRU(): New predicate: Use the unzip_LRU before falling back to the regular LRU? buf_LRU_free_from_unzip_LRU_list(), buf_LRU_free_from_common_LRU_list(): Subfunctions of buf_LRU_search_and_free_block(). buf_LRU_search_and_free_block(): Reimplement. Try to evict an uncompressed page from the unzip_LRU list before falling back to evicting an entire block from the common LRU list. buf_unzip_LRU_remove_block_if_needed(): New function. buf_unzip_LRU_add_block(): New function: Add a block to the unzip_LRU list.
18 years ago
branches/zip: Improve the LRU algorithm with a separate unzip_LRU list of blocks that contains uncompressed and compressed frames. This patch was designed by Heikki and Inaam, implemented by Inaam, and refined and reviewed by Marko and Sunny. buf_buddy_n_frames, buf_buddy_min_n_frames, buf_buddy_max_n_frames: Remove. buf_page_belongs_to_unzip_LRU(): New predicate: bpage->zip.data && buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE. buf_pool_t, buf_block_t: Add the linked list unzip_LRU. A block in the regular LRU list is in unzip_LRU iff buf_page_belongs_to_unzip_LRU() holds. buf_LRU_free_block(): Add a third return value to refine the case "cannot free the block". buf_LRU_search_and_free_block(): Update the documentation to reflect the implementation. buf_LRU_stat_t, buf_LRU_stat_cur, buf_LRU_stat_sum, buf_LRU_stat_arr[]: Statistics for the unzip_LRU algorithm. buf_LRU_stat_update(): New function: Update the statistics. Called once per second by srv_error_monitor_thread(). buf_LRU_validate(): Validate the unzip_LRU list as well. buf_LRU_evict_from_unzip_LRU(): New predicate: Use the unzip_LRU before falling back to the regular LRU? buf_LRU_free_from_unzip_LRU_list(), buf_LRU_free_from_common_LRU_list(): Subfunctions of buf_LRU_search_and_free_block(). buf_LRU_search_and_free_block(): Reimplement. Try to evict an uncompressed page from the unzip_LRU list before falling back to evicting an entire block from the common LRU list. buf_unzip_LRU_remove_block_if_needed(): New function. buf_unzip_LRU_add_block(): New function: Add a block to the unzip_LRU list.
18 years ago
branches/zip: Improve the LRU algorithm with a separate unzip_LRU list of blocks that contains uncompressed and compressed frames. This patch was designed by Heikki and Inaam, implemented by Inaam, and refined and reviewed by Marko and Sunny. buf_buddy_n_frames, buf_buddy_min_n_frames, buf_buddy_max_n_frames: Remove. buf_page_belongs_to_unzip_LRU(): New predicate: bpage->zip.data && buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE. buf_pool_t, buf_block_t: Add the linked list unzip_LRU. A block in the regular LRU list is in unzip_LRU iff buf_page_belongs_to_unzip_LRU() holds. buf_LRU_free_block(): Add a third return value to refine the case "cannot free the block". buf_LRU_search_and_free_block(): Update the documentation to reflect the implementation. buf_LRU_stat_t, buf_LRU_stat_cur, buf_LRU_stat_sum, buf_LRU_stat_arr[]: Statistics for the unzip_LRU algorithm. buf_LRU_stat_update(): New function: Update the statistics. Called once per second by srv_error_monitor_thread(). buf_LRU_validate(): Validate the unzip_LRU list as well. buf_LRU_evict_from_unzip_LRU(): New predicate: Use the unzip_LRU before falling back to the regular LRU? buf_LRU_free_from_unzip_LRU_list(), buf_LRU_free_from_common_LRU_list(): Subfunctions of buf_LRU_search_and_free_block(). buf_LRU_search_and_free_block(): Reimplement. Try to evict an uncompressed page from the unzip_LRU list before falling back to evicting an entire block from the common LRU list. buf_unzip_LRU_remove_block_if_needed(): New function. buf_unzip_LRU_add_block(): New function: Add a block to the unzip_LRU list.
18 years ago
branches/zip: Improve the LRU algorithm with a separate unzip_LRU list of blocks that contains uncompressed and compressed frames. This patch was designed by Heikki and Inaam, implemented by Inaam, and refined and reviewed by Marko and Sunny. buf_buddy_n_frames, buf_buddy_min_n_frames, buf_buddy_max_n_frames: Remove. buf_page_belongs_to_unzip_LRU(): New predicate: bpage->zip.data && buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE. buf_pool_t, buf_block_t: Add the linked list unzip_LRU. A block in the regular LRU list is in unzip_LRU iff buf_page_belongs_to_unzip_LRU() holds. buf_LRU_free_block(): Add a third return value to refine the case "cannot free the block". buf_LRU_search_and_free_block(): Update the documentation to reflect the implementation. buf_LRU_stat_t, buf_LRU_stat_cur, buf_LRU_stat_sum, buf_LRU_stat_arr[]: Statistics for the unzip_LRU algorithm. buf_LRU_stat_update(): New function: Update the statistics. Called once per second by srv_error_monitor_thread(). buf_LRU_validate(): Validate the unzip_LRU list as well. buf_LRU_evict_from_unzip_LRU(): New predicate: Use the unzip_LRU before falling back to the regular LRU? buf_LRU_free_from_unzip_LRU_list(), buf_LRU_free_from_common_LRU_list(): Subfunctions of buf_LRU_search_and_free_block(). buf_LRU_search_and_free_block(): Reimplement. Try to evict an uncompressed page from the unzip_LRU list before falling back to evicting an entire block from the common LRU list. buf_unzip_LRU_remove_block_if_needed(): New function. buf_unzip_LRU_add_block(): New function: Add a block to the unzip_LRU list.
18 years ago
20 years ago
branches/zip: Improve the LRU algorithm with a separate unzip_LRU list of blocks that contains uncompressed and compressed frames. This patch was designed by Heikki and Inaam, implemented by Inaam, and refined and reviewed by Marko and Sunny. buf_buddy_n_frames, buf_buddy_min_n_frames, buf_buddy_max_n_frames: Remove. buf_page_belongs_to_unzip_LRU(): New predicate: bpage->zip.data && buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE. buf_pool_t, buf_block_t: Add the linked list unzip_LRU. A block in the regular LRU list is in unzip_LRU iff buf_page_belongs_to_unzip_LRU() holds. buf_LRU_free_block(): Add a third return value to refine the case "cannot free the block". buf_LRU_search_and_free_block(): Update the documentation to reflect the implementation. buf_LRU_stat_t, buf_LRU_stat_cur, buf_LRU_stat_sum, buf_LRU_stat_arr[]: Statistics for the unzip_LRU algorithm. buf_LRU_stat_update(): New function: Update the statistics. Called once per second by srv_error_monitor_thread(). buf_LRU_validate(): Validate the unzip_LRU list as well. buf_LRU_evict_from_unzip_LRU(): New predicate: Use the unzip_LRU before falling back to the regular LRU? buf_LRU_free_from_unzip_LRU_list(), buf_LRU_free_from_common_LRU_list(): Subfunctions of buf_LRU_search_and_free_block(). buf_LRU_search_and_free_block(): Reimplement. Try to evict an uncompressed page from the unzip_LRU list before falling back to evicting an entire block from the common LRU list. buf_unzip_LRU_remove_block_if_needed(): New function. buf_unzip_LRU_add_block(): New function: Add a block to the unzip_LRU list.
18 years ago
20 years ago
branches/zip: Improve the LRU algorithm with a separate unzip_LRU list of blocks that contains uncompressed and compressed frames. This patch was designed by Heikki and Inaam, implemented by Inaam, and refined and reviewed by Marko and Sunny. buf_buddy_n_frames, buf_buddy_min_n_frames, buf_buddy_max_n_frames: Remove. buf_page_belongs_to_unzip_LRU(): New predicate: bpage->zip.data && buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE. buf_pool_t, buf_block_t: Add the linked list unzip_LRU. A block in the regular LRU list is in unzip_LRU iff buf_page_belongs_to_unzip_LRU() holds. buf_LRU_free_block(): Add a third return value to refine the case "cannot free the block". buf_LRU_search_and_free_block(): Update the documentation to reflect the implementation. buf_LRU_stat_t, buf_LRU_stat_cur, buf_LRU_stat_sum, buf_LRU_stat_arr[]: Statistics for the unzip_LRU algorithm. buf_LRU_stat_update(): New function: Update the statistics. Called once per second by srv_error_monitor_thread(). buf_LRU_validate(): Validate the unzip_LRU list as well. buf_LRU_evict_from_unzip_LRU(): New predicate: Use the unzip_LRU before falling back to the regular LRU? buf_LRU_free_from_unzip_LRU_list(), buf_LRU_free_from_common_LRU_list(): Subfunctions of buf_LRU_search_and_free_block(). buf_LRU_search_and_free_block(): Reimplement. Try to evict an uncompressed page from the unzip_LRU list before falling back to evicting an entire block from the common LRU list. buf_unzip_LRU_remove_block_if_needed(): New function. buf_unzip_LRU_add_block(): New function: Add a block to the unzip_LRU list.
18 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
branches/zip: Improve the LRU algorithm with a separate unzip_LRU list of blocks that contains uncompressed and compressed frames. This patch was designed by Heikki and Inaam, implemented by Inaam, and refined and reviewed by Marko and Sunny. buf_buddy_n_frames, buf_buddy_min_n_frames, buf_buddy_max_n_frames: Remove. buf_page_belongs_to_unzip_LRU(): New predicate: bpage->zip.data && buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE. buf_pool_t, buf_block_t: Add the linked list unzip_LRU. A block in the regular LRU list is in unzip_LRU iff buf_page_belongs_to_unzip_LRU() holds. buf_LRU_free_block(): Add a third return value to refine the case "cannot free the block". buf_LRU_search_and_free_block(): Update the documentation to reflect the implementation. buf_LRU_stat_t, buf_LRU_stat_cur, buf_LRU_stat_sum, buf_LRU_stat_arr[]: Statistics for the unzip_LRU algorithm. buf_LRU_stat_update(): New function: Update the statistics. Called once per second by srv_error_monitor_thread(). buf_LRU_validate(): Validate the unzip_LRU list as well. buf_LRU_evict_from_unzip_LRU(): New predicate: Use the unzip_LRU before falling back to the regular LRU? buf_LRU_free_from_unzip_LRU_list(), buf_LRU_free_from_common_LRU_list(): Subfunctions of buf_LRU_search_and_free_block(). buf_LRU_search_and_free_block(): Reimplement. Try to evict an uncompressed page from the unzip_LRU list before falling back to evicting an entire block from the common LRU list. buf_unzip_LRU_remove_block_if_needed(): New function. buf_unzip_LRU_add_block(): New function: Add a block to the unzip_LRU list.
18 years ago
20 years ago
20 years ago
20 years ago
20 years ago
branches/zip: Improve the LRU algorithm with a separate unzip_LRU list of blocks that contains uncompressed and compressed frames. This patch was designed by Heikki and Inaam, implemented by Inaam, and refined and reviewed by Marko and Sunny. buf_buddy_n_frames, buf_buddy_min_n_frames, buf_buddy_max_n_frames: Remove. buf_page_belongs_to_unzip_LRU(): New predicate: bpage->zip.data && buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE. buf_pool_t, buf_block_t: Add the linked list unzip_LRU. A block in the regular LRU list is in unzip_LRU iff buf_page_belongs_to_unzip_LRU() holds. buf_LRU_free_block(): Add a third return value to refine the case "cannot free the block". buf_LRU_search_and_free_block(): Update the documentation to reflect the implementation. buf_LRU_stat_t, buf_LRU_stat_cur, buf_LRU_stat_sum, buf_LRU_stat_arr[]: Statistics for the unzip_LRU algorithm. buf_LRU_stat_update(): New function: Update the statistics. Called once per second by srv_error_monitor_thread(). buf_LRU_validate(): Validate the unzip_LRU list as well. buf_LRU_evict_from_unzip_LRU(): New predicate: Use the unzip_LRU before falling back to the regular LRU? buf_LRU_free_from_unzip_LRU_list(), buf_LRU_free_from_common_LRU_list(): Subfunctions of buf_LRU_search_and_free_block(). buf_LRU_search_and_free_block(): Reimplement. Try to evict an uncompressed page from the unzip_LRU list before falling back to evicting an entire block from the common LRU list. buf_unzip_LRU_remove_block_if_needed(): New function. buf_unzip_LRU_add_block(): New function: Add a block to the unzip_LRU list.
18 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
branches/zip: Improve the LRU algorithm with a separate unzip_LRU list of blocks that contains uncompressed and compressed frames. This patch was designed by Heikki and Inaam, implemented by Inaam, and refined and reviewed by Marko and Sunny. buf_buddy_n_frames, buf_buddy_min_n_frames, buf_buddy_max_n_frames: Remove. buf_page_belongs_to_unzip_LRU(): New predicate: bpage->zip.data && buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE. buf_pool_t, buf_block_t: Add the linked list unzip_LRU. A block in the regular LRU list is in unzip_LRU iff buf_page_belongs_to_unzip_LRU() holds. buf_LRU_free_block(): Add a third return value to refine the case "cannot free the block". buf_LRU_search_and_free_block(): Update the documentation to reflect the implementation. buf_LRU_stat_t, buf_LRU_stat_cur, buf_LRU_stat_sum, buf_LRU_stat_arr[]: Statistics for the unzip_LRU algorithm. buf_LRU_stat_update(): New function: Update the statistics. Called once per second by srv_error_monitor_thread(). buf_LRU_validate(): Validate the unzip_LRU list as well. buf_LRU_evict_from_unzip_LRU(): New predicate: Use the unzip_LRU before falling back to the regular LRU? buf_LRU_free_from_unzip_LRU_list(), buf_LRU_free_from_common_LRU_list(): Subfunctions of buf_LRU_search_and_free_block(). buf_LRU_search_and_free_block(): Reimplement. Try to evict an uncompressed page from the unzip_LRU list before falling back to evicting an entire block from the common LRU list. buf_unzip_LRU_remove_block_if_needed(): New function. buf_unzip_LRU_add_block(): New function: Add a block to the unzip_LRU list.
18 years ago
20 years ago
  1. /*****************************************************************************
  2. Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
  3. This program is free software; you can redistribute it and/or modify it under
  4. the terms of the GNU General Public License as published by the Free Software
  5. Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful, but WITHOUT
  7. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along with
  10. this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  11. Place, Suite 330, Boston, MA 02111-1307 USA
  12. *****************************************************************************/
  13. /******************************************************
  14. The database buffer pool LRU replacement algorithm
  15. Created 11/5/1995 Heikki Tuuri
  16. *******************************************************/
  17. #ifndef buf0lru_h
  18. #define buf0lru_h
  19. #include "univ.i"
  20. #include "ut0byte.h"
  21. #include "buf0types.h"
  22. /** The return type of buf_LRU_free_block() */
  23. enum buf_lru_free_block_status {
  24. /** freed */
  25. BUF_LRU_FREED = 0,
  26. /** not freed because the caller asked to remove the
  27. uncompressed frame but the control block cannot be
  28. relocated */
  29. BUF_LRU_CANNOT_RELOCATE,
  30. /** not freed because of some other reason */
  31. BUF_LRU_NOT_FREED
  32. };
  33. /**********************************************************************
  34. Tries to remove LRU flushed blocks from the end of the LRU list and put them
  35. to the free list. This is beneficial for the efficiency of the insert buffer
  36. operation, as flushed pages from non-unique non-clustered indexes are here
  37. taken out of the buffer pool, and their inserts redirected to the insert
  38. buffer. Otherwise, the flushed blocks could get modified again before read
  39. operations need new buffer blocks, and the i/o work done in flushing would be
  40. wasted. */
  41. UNIV_INTERN
  42. void
  43. buf_LRU_try_free_flushed_blocks(void);
  44. /*==================================*/
  45. /**********************************************************************
  46. Returns TRUE if less than 25 % of the buffer pool is available. This can be
  47. used in heuristics to prevent huge transactions eating up the whole buffer
  48. pool for their locks. */
  49. UNIV_INTERN
  50. ibool
  51. buf_LRU_buf_pool_running_out(void);
  52. /*==============================*/
  53. /* out: TRUE if less than 25 % of buffer pool
  54. left */
  55. /*#######################################################################
  56. These are low-level functions
  57. #########################################################################*/
  58. /* Minimum LRU list length for which the LRU_old pointer is defined */
  59. #define BUF_LRU_OLD_MIN_LEN 80
  60. #define BUF_LRU_FREE_SEARCH_LEN (5 + 2 * BUF_READ_AHEAD_AREA)
  61. /**********************************************************************
  62. Invalidates all pages belonging to a given tablespace when we are deleting
  63. the data file(s) of that tablespace. A PROBLEM: if readahead is being started,
  64. what guarantees that it will not try to read in pages after this operation has
  65. completed? */
  66. UNIV_INTERN
  67. void
  68. buf_LRU_invalidate_tablespace(
  69. /*==========================*/
  70. ulint id); /* in: space id */
  71. /**********************************************************************
  72. Gets the minimum LRU_position field for the blocks in an initial segment
  73. (determined by BUF_LRU_INITIAL_RATIO) of the LRU list. The limit is not
  74. guaranteed to be precise, because the ulint_clock may wrap around. */
  75. UNIV_INTERN
  76. ulint
  77. buf_LRU_get_recent_limit(void);
  78. /*==========================*/
  79. /* out: the limit; zero if could not determine it */
  80. /************************************************************************
  81. Insert a compressed block into buf_pool->zip_clean in the LRU order. */
  82. UNIV_INTERN
  83. void
  84. buf_LRU_insert_zip_clean(
  85. /*=====================*/
  86. buf_page_t* bpage); /* in: pointer to the block in question */
  87. /**********************************************************************
  88. Try to free a block. If bpage is a descriptor of a compressed-only
  89. page, the descriptor object will be freed as well.
  90. NOTE: If this function returns BUF_LRU_FREED, it will not temporarily
  91. release buf_pool_mutex. Furthermore, the page frame will no longer be
  92. accessible via bpage.
  93. The caller must hold buf_pool_mutex and buf_page_get_mutex(bpage) and
  94. release these two mutexes after the call. No other
  95. buf_page_get_mutex() may be held when calling this function. */
  96. UNIV_INTERN
  97. enum buf_lru_free_block_status
  98. buf_LRU_free_block(
  99. /*===============*/
  100. /* out: BUF_LRU_FREED if freed,
  101. BUF_LRU_CANNOT_RELOCATE or
  102. BUF_LRU_NOT_FREED otherwise. */
  103. buf_page_t* bpage, /* in: block to be freed */
  104. ibool zip, /* in: TRUE if should remove also the
  105. compressed page of an uncompressed page */
  106. ibool* buf_pool_mutex_released);
  107. /* in: pointer to a variable that will
  108. be assigned TRUE if buf_pool_mutex
  109. was temporarily released, or NULL */
  110. /**********************************************************************
  111. Try to free a replaceable block. */
  112. UNIV_INTERN
  113. ibool
  114. buf_LRU_search_and_free_block(
  115. /*==========================*/
  116. /* out: TRUE if found and freed */
  117. ulint n_iterations); /* in: how many times this has been called
  118. repeatedly without result: a high value means
  119. that we should search farther; if
  120. n_iterations < 10, then we search
  121. n_iterations / 10 * buf_pool->curr_size
  122. pages from the end of the LRU list; if
  123. n_iterations < 5, then we will also search
  124. n_iterations / 5 of the unzip_LRU list. */
  125. /**********************************************************************
  126. Returns a free block from the buf_pool. The block is taken off the
  127. free list. If it is empty, returns NULL. */
  128. UNIV_INTERN
  129. buf_block_t*
  130. buf_LRU_get_free_only(void);
  131. /*=======================*/
  132. /* out: a free control block, or NULL
  133. if the buf_block->free list is empty */
  134. /**********************************************************************
  135. Returns a free block from the buf_pool. The block is taken off the
  136. free list. If it is empty, blocks are moved from the end of the
  137. LRU list to the free list. */
  138. UNIV_INTERN
  139. buf_block_t*
  140. buf_LRU_get_free_block(
  141. /*===================*/
  142. /* out: the free control block,
  143. in state BUF_BLOCK_READY_FOR_USE */
  144. ulint zip_size); /* in: compressed page size in bytes,
  145. or 0 if uncompressed tablespace */
  146. /**********************************************************************
  147. Puts a block back to the free list. */
  148. UNIV_INTERN
  149. void
  150. buf_LRU_block_free_non_file_page(
  151. /*=============================*/
  152. buf_block_t* block); /* in: block, must not contain a file page */
  153. /**********************************************************************
  154. Adds a block to the LRU list. */
  155. UNIV_INTERN
  156. void
  157. buf_LRU_add_block(
  158. /*==============*/
  159. buf_page_t* bpage, /* in: control block */
  160. ibool old); /* in: TRUE if should be put to the old
  161. blocks in the LRU list, else put to the
  162. start; if the LRU list is very short, added to
  163. the start regardless of this parameter */
  164. /**********************************************************************
  165. Adds a block to the LRU list of decompressed zip pages. */
  166. UNIV_INTERN
  167. void
  168. buf_unzip_LRU_add_block(
  169. /*====================*/
  170. buf_block_t* block, /* in: control block */
  171. ibool old); /* in: TRUE if should be put to the end
  172. of the list, else put to the start */
  173. /**********************************************************************
  174. Moves a block to the start of the LRU list. */
  175. UNIV_INTERN
  176. void
  177. buf_LRU_make_block_young(
  178. /*=====================*/
  179. buf_page_t* bpage); /* in: control block */
  180. /**********************************************************************
  181. Moves a block to the end of the LRU list. */
  182. UNIV_INTERN
  183. void
  184. buf_LRU_make_block_old(
  185. /*===================*/
  186. buf_page_t* bpage); /* in: control block */
  187. /************************************************************************
  188. Update the historical stats that we are collecting for LRU eviction
  189. policy at the end of each interval. */
  190. UNIV_INTERN
  191. void
  192. buf_LRU_stat_update(void);
  193. /*=====================*/
  194. #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
  195. /**************************************************************************
  196. Validates the LRU list. */
  197. UNIV_INTERN
  198. ibool
  199. buf_LRU_validate(void);
  200. /*==================*/
  201. /* out: TRUE */
  202. #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
  203. #if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
  204. /**************************************************************************
  205. Prints the LRU list. */
  206. UNIV_INTERN
  207. void
  208. buf_LRU_print(void);
  209. /*===============*/
  210. #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
  211. /**********************************************************************
  212. These statistics are not 'of' LRU but 'for' LRU. We keep count of I/O
  213. and page_zip_decompress() operations. Based on the statistics we decide
  214. if we want to evict from buf_pool->unzip_LRU or buf_pool->LRU. */
  215. /** Statistics for selecting the LRU list for eviction. */
  216. struct buf_LRU_stat_struct
  217. {
  218. ulint io; /**< Counter of buffer pool I/O operations. */
  219. ulint unzip; /**< Counter of page_zip_decompress operations. */
  220. };
  221. typedef struct buf_LRU_stat_struct buf_LRU_stat_t;
  222. /** Current operation counters. Not protected by any mutex.
  223. Cleared by buf_LRU_stat_update(). */
  224. extern buf_LRU_stat_t buf_LRU_stat_cur;
  225. /** Running sum of past values of buf_LRU_stat_cur.
  226. Updated by buf_LRU_stat_update(). Protected by buf_pool_mutex. */
  227. extern buf_LRU_stat_t buf_LRU_stat_sum;
  228. /************************************************************************
  229. Increments the I/O counter in buf_LRU_stat_cur. */
  230. #define buf_LRU_stat_inc_io() buf_LRU_stat_cur.io++
  231. /************************************************************************
  232. Increments the page_zip_decompress() counter in buf_LRU_stat_cur. */
  233. #define buf_LRU_stat_inc_unzip() buf_LRU_stat_cur.unzip++
  234. #ifndef UNIV_NONINL
  235. #include "buf0lru.ic"
  236. #endif
  237. #endif