Buffer cache Experiment 3:lru and Lruw linked list

Source: Internet
Author: User
Tags touch

The concept of LRU linked list in 1.Buffer cache:

When Oracle does not search for the desired buffer in the hash chain, the Oracel service process makes an I/O call and reads the corresponding data block to the disk's data file--except for direct path reading, the contents of the data block are copied to the buffer cache In memory--constructs a buffer header at the same time.

When the data block is copied to the buffer cache, if the buffer cache is empty, take an empty memory block to use.

But if the buffer cache memory blocks are all used, there is no empty memory block, how to do? Here is the LRU linked list.

by LRU, Lruw and other linked lists to manage which blocks can be reused (overwritten), so as to speed up the physical read load block to buffer cache to find the available memory block speed.

In the previous diagram describing the buffer cache structure, you can also see that there are two linked lists: LRU and Lruw.

Before introducing LRU and LRUW, let's explain a few concepts.

1. Dirty data block (dirty buffer): The contents of the memory block in buffer cache are inconsistent with the contents of the data block in the data file.

2. Available data block (free buffer): the memory block in buffer cache is empty or its content is consistent with the data file. Note that the available blocks of data are not necessarily empty.

3. Pinned block of data (ping buffer): The memory data block currently being updated.

4. Database write Process (DBWR): This is a very low-level database background process. Since it is a background process, it means that the process cannot be invoked by the user. Some of the events built up by Oracle start the process as needed to write dirty blocks to data files on disk. LRU represents the least recently Used, which refers to the least recently used buffer header list. The buffer header concatenated with the LRU list points to the available data blocks. And Lruw said least recently Used write, also known as the Dirty list, that is, dirty data block linked list, LRUW string up are modified but have not yet written data file memory data block corresponding to the buffer header. A buffer header is either hung on the LRU or hung on the Lruw cannot be hung on both lists at the same time.

LRU represents the least recently Used, which refers to the least recently used buffer header list. The buffer header concatenated with the LRU list points to the available data blocks.

And Lruw said least recently Used write, also known as the Dirty list, that is, dirty data block linked list, LRUW string up are modified but have not yet written data file memory data block corresponding to the buffer header.

A buffer header is either hung on the LRU or hung on the LRUW and cannot be hung on both lists at the same time.

#########################################################################################

2. On the significance of different lru_flag in X$BH

sys@ bys3>select distinct lru_flag from X$BH; --lru_flag has these 5 kinds of marker bits.

Lru_flag

----------

6

2

4

8

0

The X$bh.lru_flag is 0, which corresponds to the cold end--dsi of the production LRU. You can also use the dump buffer cache, search BH LRU value to calculate the 0 State BH Position-very complex ah ha.

X$bh.lru_flag is 2, corresponding to: Lru-flags:moved_to_tail at LRU Hot end

X$bh.lru_flag is 8, corresponding: Lru-flags:hot_buffer at the LRU hot end---is said to have a state is 9, is also at the hot end.

X$bh.lru_flag is 4, corresponding to: lru-flags:on_auxiliary_list

X$bh.lru_flag is 6, corresponds: Lru-flags:moved_to_tail on_auxiliary_list in auxiliary LRU

--by identifying the file number block number of each sign and doing dump to verify that, in addition to 0 can not dump BH verification, other can be.

Method:

sys@ Bys3>select dbarfil,dbablk from X$BH where lru_flag=2 and rownum=1;

Dbarfil dbablk

---------- ----------

2 15796

sys@ bys3>alter System dump datafile 2 block 15796; --10g can't use this command, 11G can.

The management mechanism of the 3.LRU chain list:

The LRU management mechanism before 8i is no longer discussed.

After 8i, the LRU and Lruw linked lists have two sub lists, called Auxiliary lists and master lists respectively.

At the same time, add a property to the buffer header: Touch number, that is, each buffer header has been visited the number of times to the LRU linked list management. --x$bh.tch

Each time Oracle accesses the buffer header, it increases the number of hits on the buffer header by 1, so the touch number "approximate" reflects the number of times a block of memory data has been accessed. Note that this is only approximate and not accurate. Because the increase in touch does not use latch to manage concurrency. This is just a ballpark figure, which indicates a trend that does not have to be hundred percent accurate (only one time in 3 seconds for multiple block accesses).

############################

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.