简体   繁体   English

Emacs 使用 mmap 分配缓冲区

[英]Emacs Buffer Allocation using mmap

Why is mmap buffer allocation activated by default on cygwin, freebsd and irix6-5 but not on linux?为什么在 cygwin、freebsd 和 irix6-5 上默认激活mmap缓冲区分配,但在 linux 上没有?

See USE_MMAP_FOR_BUFFERS in emacs/src/config.h .请参阅emacs/src/config.hUSE_MMAP_FOR_BUFFERS and use_mmap_for_buffers in emacs/configure.in .emacs/configure.in中的use_mmap_for_buffers

Isn't mmap based access superior to normal buffer allocation?基于mmap的访问不是优于正常的缓冲区分配吗?

The default glibc malloc() uses mmap for large allocations;默认的 glibc malloc() 使用 mmap 进行大分配; From the malloc(3) manpage.来自 malloc(3) 联机帮助页。 "When allocating blocks of memory larger than MMAP_THRESHOLD bytes, the glibc malloc() implementation allocates the memory as a private anonymous mapping using mmap(2). MMAP_THRESHOLD is 128 kB by default, but is adjustable using mallopt(3)." “当分配大于 MMAP_THRESHOLD 字节的 memory 块时,glibc malloc() 实现将 memory 分配为使用 mmap(2) 的私有匿名映射。默认情况下,MMAP_THRESHOLD 为 128 kB,但可使用 mallopt(3) 进行调整。”

Perhaps switching to mmap on those other platforms is to work around poor malloc() implementations that don't do it themselves?也许在其他平台上切换到 mmap 是为了解决自己不做的糟糕的 malloc() 实现?

mmap() allocation is easier to realize in a threadsafe fashion, but brk() allocation is about 10% slower on Linux. mmap() 分配更容易以线程安全的方式实现,但 brk() 分配在 Linux 上慢了大约 10%。 See this question .看到这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM