buf0lru.h
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:4k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /******************************************************
  2. The database buffer pool LRU replacement algorithm
  3. (c) 1995 Innobase Oy
  4. Created 11/5/1995 Heikki Tuuri
  5. *******************************************************/
  6. #ifndef buf0lru_h
  7. #define buf0lru_h
  8. #include "univ.i"
  9. #include "ut0byte.h"
  10. #include "buf0types.h"
  11. /**********************************************************************
  12. Tries to remove LRU flushed blocks from the end of the LRU list and put them
  13. to the free list. This is beneficial for the efficiency of the insert buffer
  14. operation, as flushed pages from non-unique non-clustered indexes are here
  15. taken out of the buffer pool, and their inserts redirected to the insert
  16. buffer. Otherwise, the flushed blocks could get modified again before read
  17. operations need new buffer blocks, and the i/o work done in flushing would be
  18. wasted. */
  19. void
  20. buf_LRU_try_free_flushed_blocks(void);
  21. /*==================================*/
  22. /*#######################################################################
  23. These are low-level functions
  24. #########################################################################*/
  25. /* Minimum LRU list length for which the LRU_old pointer is defined */
  26. #define BUF_LRU_OLD_MIN_LEN 80
  27. #define BUF_LRU_FREE_SEARCH_LEN (5 + 2 * BUF_READ_AHEAD_AREA)
  28. /**********************************************************************
  29. Gets the minimum LRU_position field for the blocks in an initial segment
  30. (determined by BUF_LRU_INITIAL_RATIO) of the LRU list. The limit is not
  31. guaranteed to be precise, because the ulint_clock may wrap around. */
  32. ulint
  33. buf_LRU_get_recent_limit(void);
  34. /*==========================*/
  35. /* out: the limit; zero if could not determine it */
  36. /**********************************************************************
  37. Returns a free block from the buf_pool. The block is taken off the
  38. free list. If it is empty, blocks are moved from the end of the
  39. LRU list to the free list. */
  40. buf_block_t*
  41. buf_LRU_get_free_block(void);
  42. /*=========================*/
  43. /* out: the free control block */
  44. /**********************************************************************
  45. Puts a block back to the free list. */
  46. void
  47. buf_LRU_block_free_non_file_page(
  48. /*=============================*/
  49. buf_block_t* block); /* in: block, must not contain a file page */
  50. /**********************************************************************
  51. Adds a block to the LRU list. */
  52. void
  53. buf_LRU_add_block(
  54. /*==============*/
  55. buf_block_t* block, /* in: control block */
  56. ibool old); /* in: TRUE if should be put to the old
  57. blocks in the LRU list, else put to the
  58. start; if the LRU list is very short, added to
  59. the start regardless of this parameter */
  60. /**********************************************************************
  61. Moves a block to the start of the LRU list. */
  62. void
  63. buf_LRU_make_block_young(
  64. /*=====================*/
  65. buf_block_t* block); /* in: control block */
  66. /**********************************************************************
  67. Moves a block to the end of the LRU list. */
  68. void
  69. buf_LRU_make_block_old(
  70. /*===================*/
  71. buf_block_t* block); /* in: control block */
  72. /**********************************************************************
  73. Look for a replaceable block from the end of the LRU list and put it to
  74. the free list if found. */
  75. ibool
  76. buf_LRU_search_and_free_block(
  77. /*==========================*/
  78. /* out: TRUE if freed */
  79. ulint n_iterations); /* in: how many times this has been called
  80. repeatedly without result: a high value
  81. means that we should search farther */
  82. /**************************************************************************
  83. Validates the LRU list. */
  84. ibool
  85. buf_LRU_validate(void);
  86. /*==================*/
  87. /**************************************************************************
  88. Prints the LRU list. */
  89. void
  90. buf_LRU_print(void);
  91. /*===============*/
  92. #ifndef UNIV_NONINL
  93. #include "buf0lru.ic"
  94. #endif
  95. #endif