MMAP VS SBRK,性能比较 [英] mmap vs sbrk, performance comparison

查看:369
本文介绍了MMAP VS SBRK,性能比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪个这些调用的平均为快?我听说MMAP是较小的分配速度更快,但我还没有听说过的任何比较。对这些性能的任何信息就好了。

Which of these calls is faster on average? I've heard that mmap is faster for smaller allocations but I haven't heard a comparison of either. Any information on performance for these would be nice.

推荐答案

您应该用特殊的实现(如的Linux )标签,这一点,因为答案肯定通过实施不同而不同。现在我假设的Linux,因为它是最流行的。

You should tag this with a particular implementation (like linux) since the answer surely varies by implementation. For now I'll assume Linux since it's the most popular.

随着中说, BRK 在理论上更加优化的,并在实践运行我的机器上快10%左右。分配一个页面,这些都是我得到的时间:

With that said, brk is in theory more optimizable, and in practice it runs about 10% faster on my machine. Allocating one page, these are the times I get:


  • BRK :分钟2550次,典型的2650个周期

  • MMAP :2700分钟周期,典型的2800个周期

  • brk: min 2550 cycles, typical 2650 cycles
  • mmap: min 2700 cycles, typical 2800 cycles

我记得,在能够跳过锁定 MMAP 信号,这可以解释的 BRK 行听到的东西的差异。

I remember hearing something along the lines of brk being able to skip locking the mmap semaphore, which would explain the discrepancy.

注意:我这些时间调整我的测试,以一个虚拟的电话之前,定时更新后,确保了code都将是在缓存

Note: I updated these times after adjusting my test to make a dummy calls prior to timing, to ensure that the code would all be in the cache.

这篇关于MMAP VS SBRK,性能比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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