页面错误陷阱成本 [英] Cost of a page fault trap

查看:152
本文介绍了页面错误陷阱成本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它会定期(每经过1或2秒)通过派生本身需要检查点。因此,检查点是原来的进程,直到它被要求时,在原来的过程中的一些错误发生时要启动的只是停留闲置的一个分支。

I have an application which periodically (after each 1 or 2 seconds) takes checkpoints by forking itself. So checkpoint is a fork of the original process which just stays idle until it is asked to start when some error in the original process occurs.

现在我的问题是如何昂贵的是叉的写入时复制机制。多少页故障陷阱,将(以一个检查点是后第一次)只要原来的进程写入到一个内存页发生的费用,如写入时复制机制将确保它给人的最初的过程不同的物理页面超过检查点。

Now my question is how costly is the copy-on-write mechanism of fork. How much is the cost of a page fault trap that will occur whenever the original process writes to a memory page (first time after taking a checkpoint that is), as copy-on-write mechanism will make sure that it gives the original process a different physical page than the checkpoint.

在我看来,页面错误陷阱的开销可能是因为发生中断时相当高,我们从用户空间的土地到内核空间耕地的土地,然后再从内核到用户空间。我多少个CPU周期可以从这样失去了一个页面错误陷阱。假设内存足够大,我们永远不要需要交换到硬盘。

In my opinion, the page fault trap overhead could be quite high as an interrupt occurs, we land from user-space land to the kernel space land and then back from kernel to user-space. How many CPU cycles can I lose from such a a page fault trap. Assume that the RAM is big enough and we don't ever need to swap to the hard disk.

嗯,我知道,它很难想象,一个检查点计划比这更有效的,因此,你可以说我为什么担心网页陷阱故障的开销,但我要求只是有一个想法多少费用怎么会在那里这项计划。

Well I know that its difficult to imagine a checkpointing scheme more efficient than this and therefore you could say why I'm worrying about page trap fault overhead, but I'm asking just to have an idea how much cost will be there for this scheme.

推荐答案

您可以做粗糙数学的一个猜测自己。假设没有磁盘访问(约10十亿次),你必须考虑

You can do the rough math for an educated guess yourself. Assuming no disk access (~10 billion cycles), you have to account for


  • 160次循环的陷阱和返回(约,在x86_64)

  • 有效性检查,配额,会计,和诸如此类的东西(未知,可能是几百到一千次)

  • 对齐的memcpy 4096字节,周围的东西循环500-800

  • TLB失效(增加第一次访问10-100次)

  • 其他的缓存数据要么被驱逐或者根据的的memcpy 的实施都保证高速缓存未命中(80-400次)。这是相当重要的您的访问模式是否一个或其他更好。

  • 160 cycles for the trap and returning (approximately, on x86_64)
  • validity checks, quota, accounting, and whatnot (unknown, probably a few hundred to a thousand cycles)
  • aligned memcpy of 4096 bytes, something around 500-800 cycles
  • TLB invalidation (adds 10-100 cycles on first access)
  • either eviction of other cached data or one guaranteed cache miss (80-400 cycles) depending on the implementation of the memcpy. It matters a lot on your access pattern whether one or the other is better.

所以,所有的一切,我们在2000年左右的周期说话的东西,与一些效果(例如TLB和高速缓存的影响)为S. $ P $垫出来,而不是立即可见。 Omondi和Sedukhin报道1700次的P-III早在2003年,这是与此估计是一致的。

So all in all, we're talking of something around 2000 cycles, with some of the effects (e.g. TLB and cache effects) being spread out and not immediately visible. Omondi and Sedukhin reported 1700 cycles on P-III back in 2003, which is consistent with this estimate.

请注意,如果页面从未被写入之前,事情稍有不同根据L.托沃兹回在2000年评论零页面上的写入时复制小姐从池中拉另一个零页和不复制零。这是pretty太大的保证缓存未命中过,但。

Note that if the page has never been written to before, things are slightly different according to a comment by L. Torvalds back in 2000. A copy-on-write miss on a zero page pulls another zero page from the pool and doesn't copy zeroes. That's pretty much a guaranteed cache miss too, though.

这篇关于页面错误陷阱成本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆