]> arthur.barton.de Git - bup.git/commit
bloom: avoid kernel disk flushes when we dirty a lot of pages.
authorAvery Pennarun <apenwarr@gmail.com>
Tue, 8 Feb 2011 03:09:06 +0000 (19:09 -0800)
committerAvery Pennarun <apenwarr@gmail.com>
Tue, 8 Feb 2011 03:54:07 +0000 (19:54 -0800)
commitf841907461d0279faaddde750adf0b23d440a328
tree3c273ff15d57698d8ab60e1d4638e736e6734223
parentbda2a9e054b2a02780e38135d08c81246f010976
bloom: avoid kernel disk flushes when we dirty a lot of pages.

Based on the number of objects we'll add to the bloom, decide if we want to
mmap() the pages as shared-writable ('immediate' write) or else map them
private-writable for later manual writing back to the file ('delayed'
write).

A bloom table's write access pattern is such that we dirty almost all the
pages after adding very few entries; essentially, we can expect to dirty
about n*k/4096 pages if we add n objects to the bloom with k hashes. But the
table is so big that dirtying *all* the pages often exceeds Linux's default
/proc/sys/vm/dirty_ratio or /proc/sys/vm/dirty_background_ratio,
thus causing it to start flushing the table before we're
finished... even though there's more than enough space to
store the bloom table in RAM.

To work around that behaviour, if we calculate that we'll probably end up
touching the whole table anyway (at least one bit flipped per memory page),
let's use a "private" mmap, which defeats Linux's ability to flush it to
disk.  Then we'll flush it as one big lump during close(), which doesn't
lose any time since we would have had to flush all the pages anyway.

While we're here, let's remove the readwrite=True option to
ShaBloom.create(); nobody's going to create a bloom file that isn't
writable.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
cmd/bloom-cmd.py
lib/bup/git.py
lib/bup/helpers.py
lib/bup/t/tgit.py