How to portably extend a file accessed using mmap()

前端 未结 3 1117
你的背包
你的背包 2020-12-23 10:21

We\'re experimenting with changing SQLite, an embedded database system, to use mmap() instead of the usual read() and write() calls to access the database file on disk. Usin

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-23 10:40

    1. Use fallocate() instead of ftruncate() where available. If not, just open file in O_APPEND mode and increase file by writing some amount of zeroes. This greatly reduce fragmentation.

    2. Use "Huge pages" if available - this greatly reduce overhead on big mappings.

    3. pread()/pwrite()/pwritev()/preadv() with not-so-small block size is not slow really. Much faster than IO can actually be performed.

    4. IO errors when using mmap() will generate just segfault instead of EIO or so.

    5. The most of SQLite WRITE performance problems is concentrated in good transactional use (i.e. you should debug when COMMIT actually performed).

提交回复
热议问题