Ç的Linux则msync(MS_ASYNC)为了平齐 [英] c linux msync(MS_ASYNC) flush order

查看:300
本文介绍了Ç的Linux则msync(MS_ASYNC)为了平齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

时页面刷新用则msync(MS_ASYNC)在Linux保证是相同的顺序,其中写入的页面命令?

Is the order of page flushes with msync(MS_ASYNC) on linux guaranteed to be the same as the order the pages where written to?

如果它取决于情况下,是有我(全服务器访问)的方式,以确保他们在相同的顺序?

If it depends on circumstances, is there a way for me (full server access) to make sure they are in the same order?

背景

我目前使用 OpenLDAP的Symas MDB 作为持久键/值存储,无 MDB_MAPASYNC - 这将导致使用则msync(MS_ASYNC)(我通过源$ C ​​$ C望着) - 写操作都这么慢,即使在同时,有时&LT处理数据的单核上IO等待永久; 1MB /秒。经过分析,这个问题似乎是许多小IO OPS。使用 MDB_MAPASYNC 我可以很容易地击中了我的磁盘的最大速度,但MDB的文件指出,在这种情况下,数据库可能会损坏。不幸的是,code是太复杂,我/我目前还没有通过整个codeBase的一步步努力找出为什么会发生的时间,而且,我不需要很多功能MDB提供(交易,光标,ACID兼容),所以我想我自己写KV存储通过mmap的支持,使用则msync(MS_ASYNC),并确保写的的方式,一个未刷新页面只会失去最后触摸数据,并且不损坏数据库或丢失的任何其它数据。

I'm currently using OpenLDAP Symas MDB as a persistent key/value storage and without MDB_MAPASYNC - which results in using msync(MS_ASYNC) (I looked through the source code) - the writes are so slow, that even while processing data a single core is permanently waiting on IO at sometimes < 1MB/s. After analyzing, the problem seems to be many small IO Ops. Using MDB_MAPASYNC I can hit the max rate of my disk easily, but the documentation of MDB states that in that case the database can become corrupted. Unfortunately the code is too complex to me/I currently don't have the time to work through the whole codebase step by step to find out why this would be, and also, I don't need many of the features MDB provides (transactions, cursors, ACID compliance), so I was thinking of writing my own KV Store backed by mmap, using msync(MS_ASYNC) and making sure to write in a way that an un-flushed page would only lose the last touched data, and not corrupt the database or lose any other data.

但对于我需要一个答案,我的问题,我完全不能用google搜索或通过Linux的不幸邮件列表会发现(我发现关于则msync补丁一些邮件,但没有别的)

But for that I'd need an answer to my question, which I totally can't find by googling or going through linux mailing lists unfortunately (I've found a few mails regarding msync patches, but nothing else)

在一张纸条,我已经通过许多其他可用的执着KV卖场一看,是不是能找到一个更好的适合我(写入速度快,易于使用,嵌入式(所以没有HTTP服务等) ,确定性的速度(所以没有垃圾收集或随机运行的COM pression像性LevelDB),理智的空间需求(所以没有只追加的数据库),可变密钥长度,二进制密钥和数据),但如果你知道一个可能帮我在这里,我也非常感激。

On a note, I've looked through dozens of other available persistent KV stores, and wasn't able to find a better fit for me (fast writes, easy to use, embedded(so no http services or the like), deterministic speed(so no garbage collection or randomly run compression like leveldb), sane space requirements(so no append-only databases), variable key lengths, binary keys and data), but if you know of one which could help me out here, I'd also be very thankful.

推荐答案

2人则msync

由于Linux 2.6.19, MS_ASYNC 其实是一个空操作,因为内核正确轨道脏页,并将它们刷新到存储是必要的。

Since Linux 2.6.19, MS_ASYNC is in fact a no-op, since the kernel properly tracks dirty pages and flushes them to storage as necessary.

不幸的是,同步与它的后备存储的映射的唯一机制是阻断 MS_SYNC ,也没有任何顺序保证(如果您同步一个1 MIB区域,256的4 KiB页面可以传播到该驱动器以任意顺序 - 你所知道的是,如果则msync 1 MIB的回报的所有的已同步)。

Unfortunately, the only mechanism to sync a mapping with its backing storage is the blocking MS_SYNC, which also does not have any ordering guarantees (if you sync a 1 MiB region, the 256 4 KiB pages can propagate to the drive in any order -- all you know is that if msync returns, all of the 1 MiB has been synced).

这篇关于Ç的Linux则msync(MS_ASYNC)为了平齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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