java怎样在内存中分页_内存 - 分页和TLB

本文探讨了TLB(Translation Lookaside Buffer)在内存分页中的工作原理,详细解释了如何通过TLB避免频繁的内存访问,特别是在流式访问模式下,每个TLB条目可以显著提高性能。通过实例分析双入口直接映射数据TLB的命中和缺失情况,阐述了TLB条目的复用机制及其对系统性能的影响。
摘要由CSDN通过智能技术生成

由于访问模式是流式访问,因此每个TLB条目将用于对整个页面的每四个字节的一次访问,并且永远不会重复使用 . 这意味着每个TLB条目将被重复使用1023次,因此每页将避免1023个查找(2046个内存访问) . (由于使用不同的翻译没有重叠,只有完全本地化的重用,单个条目数据TLB的性能与2048条目的TLB相当 . )

考虑以下对双入口直接映射数据TLB所发生情况的描述(认识到虚拟地址的最低有效12位 - 页面内的偏移 - 被TLB忽略,并且虚拟地址的一位是用于索引到TLB):

load 0x0100_0000; // TLB entry 0 tag != 0x0800 (page # 0x0_1000) [miss]

// 2 memory accesses to fill TLB entry 0

load 0x0100_0004; // TLB entry 0 tag == 0x0800 [hit]

load 0x0100_0008; // TLB entry 0 tag == 0x0800 [hit]

... // 1020 TLB hits in TLB entry 0

load 0x0100_0ffc; // TLB entry 0 tag == 0x0800 [hit]; last word in page

load 0x0100_1000; // TLB entry 1 tag != 0x0800 (page # 0x0_1001) [miss]

// 2 memory accesses to fill TLB entry 1

load 0x0100_1004; // TLB entry 1 tag == 0x0800 [hit]

load 0x0100_1008; // TLB entry 1 tag == 0x0800 [hit]

... // 1020 TLB hits in TLB entry 1

load 0x0100_1ffc; // TLB entry 1 tag == 0x0800 [hit]; last word in page

load 0x0100_2000; // TLB entry 0 tag (0x0800) != 0x0801 (page # 0x0_1002) [miss]

// 2 memory accesses to fill TLB entry 0

load 0x0100_2004; // TLB entry 0 tag == 0x0801 [hit]

load 0x0100_2008; // TLB entry 0 tag == 0x0801 [hit]

... // 1020 TLB hits in TLB entry 0

load 0x0100_2ffc; // TLB entry 0 tag == 0x0801 [hit]; last word in page

load 0x0100_3000; // TLB entry 1 tag (0x0800) != 0x0801 (page # 0x0_1003) [miss)

// 2 memory accesses to fill TLB entry 1

load 0x0100_3004; // TLB entry 1 tag == 0x0801 [hit]

load 0x0100_3008; // TLB entry 1 tag == 0x0801 [hit]

... // 1020 TLB hits in TLB entry 1

load 0x0100_3ffc; // TLB entry 1 tag == 0x0801 [hit]; last word in page

... // repeat the above 510 times

// then the last 4 pages of the 8 MiB stream

load 0x017f_c000; // TLB entry 0 tag (0x0bfd) != 0x0bfe (page # 0x0_17fc) [miss]

// 2 memory accesses to fill TLB entry 0

load 0x017f_c004; // TLB entry 0 tag == 0x0bfe [hit]

load 0x017f_c008; // TLB entry 0 tag == 0x0bfe [hit]

... // 1020 TLB hits in TLB entry 0

load 0x017f_cffc; // TLB entry 0 tag == 0x0bfe [hit]; last word in page

load 0x017f_d000; // TLB entry 1 tag (0x0bfd) != 0x0bfe (page # 0x0_17fd) [miss]

// 2 memory accesses to fill TLB entry 1

load 0x017f_d004; // TLB entry 1 tag == 0x0bfe [hit]

load 0x017f_d008; // TLB entry 1 tag == 0x0bfe [hit]

... // 1020 TLB hits in TLB entry 1

load 0x017f_dffc; // TLB entry 1 tag == 0x0bfe [hit]; last word in page

load 0x017f_e000; // TLB entry 0 tag (0x0bfe) != 0x0bff (page # 0x0_17fe) [miss]

// 2 memory accesses to fill TLB entry 0

load 0x017f_e004; // TLB entry 0 tag == 0x0bff [hit]

load 0x017f_e008; // TLB entry 0 tag == 0x0bff [hit]

... // 1020 TLB hits in TLB entry 0

load 0x017f_effc; // TLB entry 0 tag == 0x0bff [hit]; last word in page

load 0x017f_f000; // TLB entry 1 tag (0x0bfe) != 0x0bff (page # 0x0_17ff) [miss]

// 2 memory accesses to fill TLB entry 1

load 0x017f_f004; // TLB entry 1 tag == 0x0bff [hit]

load 0x017f_f008; // TLB entry 1 tag == 0x0bff [hit]

... // 1020 TLB hits in TLB entry 1

load 0x017f_fffc; // TLB entry 1 tag == 0x0bff [hit]; last word in page

每个页面按顺序引用1024次(每个四字节元素一次),然后再从未引用 .

(现在考虑一个带有四个TLB条目和两个条目缓存页面目录条目的设计[每个条目都有指向页面表条目页面的指针] . 每个缓存的PDE将被重用于1023页面查找,将它们减少到一个内存访问每个 . [如果8 MiB流式访问作为内部循环重复并且是4 MiB对齐,则在第一次迭代之后,双入口PDE缓存将完全预热,并且所有后续页面表查找仅需要一个内存参考 . ])

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值