Pseudo-LRU Tree Implementation (2024)

An approximation of LRU (pseudo-LRU) can be achieved if only the most recently and the least recently blocks need to be tracked. The recency of the intermediate blocks are unimportant. One such approach, uses a binary tree to keep track of the most recent and the least recent blocks.

Binary Node

A binary tree with Pseudo-LRU Tree Implementation (1) leaves will have Pseudo-LRU Tree Implementation (2) internal nodes. Thus Pseudo-LRU Tree Implementation (3) blocks in a set will require Pseudo-LRU Tree Implementation (4) bits to approximate LRU. Each node (and corresponding bit) encodes the information about which child node is Pseudo-LRU Tree Implementation (5) and which child node is Pseudo-LRU Tree Implementation (6). Let Pseudo-LRU Tree Implementation (7) represent that the left side has been referenced more recently than the right side, and Pseudo-LRU Tree Implementation (8) vice-versa.

Consider a Pseudo-LRU Tree Implementation (10) block (line) cache implemented as a Pseudo-LRU Tree Implementation (11) node tree.

State Pseudo-LRU Tree Implementation (12)

Pseudo-LRU Tree Implementation (13)

Here, the first bit Pseudo-LRU Tree Implementation (14) divides the Pseudo-LRU Tree Implementation (15) blocks into two sets of Pseudo-LRU Tree Implementation (16) blocks. Since this bit is a Pseudo-LRU Tree Implementation (17), this means that the first two blocks are Pseudo-LRU Tree Implementation (18) when compared to the last two blocks. The second bit is also a Pseudo-LRU Tree Implementation (19). This means that within the first two blocks, the first block is Pseudo-LRU Tree Implementation (20) when compared to the second block. Notice that the third bit is inconsequential in determining the Least Recently Used block. Within the last two blocks any block can be Pseudo-LRU Tree Implementation (21) or Pseudo-LRU Tree Implementation (22). This bit is marked as an Pseudo-LRU Tree Implementation (23). Thus, for both configurations Pseudo-LRU Tree Implementation (24) and Pseudo-LRU Tree Implementation (25), the first block is the Least Recently used.

State Pseudo-LRU Tree Implementation (26)

Pseudo-LRU Tree Implementation (27)

Here, the first bit Pseudo-LRU Tree Implementation (28) divides the Pseudo-LRU Tree Implementation (29) blocks into two sets of Pseudo-LRU Tree Implementation (30) blocks. Since this bit is a Pseudo-LRU Tree Implementation (31), this means that the first two blocks are Pseudo-LRU Tree Implementation (32) when compared to the last two blocks. The second bit is a Pseudo-LRU Tree Implementation (33). This means that within the first two blocks, the second block is Pseudo-LRU Tree Implementation (34) when compared to the first block. Notice that the third bit is inconsequential in determining the Least Recently Used block. Within the last two blocks any block can be Pseudo-LRU Tree Implementation (35) or Pseudo-LRU Tree Implementation (36). This bit is marked as an Pseudo-LRU Tree Implementation (37). Thus, for both configurations Pseudo-LRU Tree Implementation (38) and Pseudo-LRU Tree Implementation (39), the second block is the Least Recently used.

State Pseudo-LRU Tree Implementation (40)

Pseudo-LRU Tree Implementation (41)

Here, the first bit Pseudo-LRU Tree Implementation (42) divides the Pseudo-LRU Tree Implementation (43) blocks into two sets of Pseudo-LRU Tree Implementation (44) blocks. Since this bit is a Pseudo-LRU Tree Implementation (45), this means that the last two blocks are Pseudo-LRU Tree Implementation (46) when compared to the first two blocks. The third bit is a Pseudo-LRU Tree Implementation (47). This means that within the last two blocks, the first block is Pseudo-LRU Tree Implementation (48) when compared to the second block. Notice that the first bit is inconsequential in determining the Least Recently Used block. Within the first two blocks any block can be Pseudo-LRU Tree Implementation (49) or Pseudo-LRU Tree Implementation (50). This bit is marked as an Pseudo-LRU Tree Implementation (51). Thus, for both configurations Pseudo-LRU Tree Implementation (52) and Pseudo-LRU Tree Implementation (53), the third block is the Least Recently used.

State Pseudo-LRU Tree Implementation (54)

Pseudo-LRU Tree Implementation (55)

Here, the first bit Pseudo-LRU Tree Implementation (56) divides the Pseudo-LRU Tree Implementation (57) blocks into two sets of Pseudo-LRU Tree Implementation (58) blocks. Since this bit is a Pseudo-LRU Tree Implementation (59), this means that the last two blocks are Pseudo-LRU Tree Implementation (60) when compared to the first two blocks. The third bit is a Pseudo-LRU Tree Implementation (61). This means that within the last two blocks, the second block is Pseudo-LRU Tree Implementation (62) when compared to the first block. Notice that the first bit is inconsequential in determining the Least Recently Used block. Within the first two blocks any block can be Pseudo-LRU Tree Implementation (63) or Pseudo-LRU Tree Implementation (64). This bit is marked as an Pseudo-LRU Tree Implementation (65). Thus, for both configurations Pseudo-LRU Tree Implementation (66) and Pseudo-LRU Tree Implementation (67), the last block is the Least Recently used.

When a cache block is referenced through a hit or a block replacement, the branch of the tree from the root to this leaf cache block gets populated with Pseudo-LRU Tree Implementation (68). This does affects the recency of other nodes along this branch, hence the approximation.

Block 0

Pseudo-LRU Tree Implementation (69)

When the first block is referenced, the edges from the root to this block get populated with Pseudo-LRU Tree Implementation (70). The complementary edges get populated with Pseudo-LRU Tree Implementation (71). This process sets the first two bits to Pseudo-LRU Tree Implementation (72). Notice that this process does not affect the third bit. It remains unchanged. This is marked as a Pseudo-LRU Tree Implementation (73). Thus, when the first block is referenced, the state changes to Pseudo-LRU Tree Implementation (74).

Block 1

Pseudo-LRU Tree Implementation (75)

When the second block is referenced, the edges from the root to this block get populated with Pseudo-LRU Tree Implementation (76). The complementary edges get populated with Pseudo-LRU Tree Implementation (77). This process sets the first bit to Pseudo-LRU Tree Implementation (78) and the second bit to Pseudo-LRU Tree Implementation (79). Notice that this process does not affect the third bit. It remains unchanged. This is marked as a Pseudo-LRU Tree Implementation (80). Thus, when the second block is referenced, the state changes to Pseudo-LRU Tree Implementation (81).

Block 2

Pseudo-LRU Tree Implementation (82)

When the third block is referenced, the edges from the root to this block get populated with Pseudo-LRU Tree Implementation (83). The complementary edges get populated with Pseudo-LRU Tree Implementation (84). This process sets the first bit to Pseudo-LRU Tree Implementation (85) and the third bit to Pseudo-LRU Tree Implementation (86). Notice that this process does not affect the second bit. It remains unchanged. This is marked as a Pseudo-LRU Tree Implementation (87). Thus, when the third block is referenced, the state changes to Pseudo-LRU Tree Implementation (88).

Block 3

Pseudo-LRU Tree Implementation (89)

When the last block is referenced, the edges from the root to this block get populated with Pseudo-LRU Tree Implementation (90). The complementary edges get populated with Pseudo-LRU Tree Implementation (91). This process sets the first and third bit to Pseudo-LRU Tree Implementation (92). Notice that this process does not affect the second bit. It remains unchanged. This is marked as a Pseudo-LRU Tree Implementation (93). Thus, when the last block is referenced, the state changes to Pseudo-LRU Tree Implementation (94).

Pseudo-LRU Tree Implementation (2024)
Top Articles
Latest Posts
Article information

Author: Rev. Leonie Wyman

Last Updated:

Views: 5686

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Rev. Leonie Wyman

Birthday: 1993-07-01

Address: Suite 763 6272 Lang Bypass, New Xochitlport, VT 72704-3308

Phone: +22014484519944

Job: Banking Officer

Hobby: Sailing, Gaming, Basketball, Calligraphy, Mycology, Astronomy, Juggling

Introduction: My name is Rev. Leonie Wyman, I am a colorful, tasty, splendid, fair, witty, gorgeous, splendid person who loves writing and wants to share my knowledge and understanding with you.