linux - How to prioritize write() over mmap updates (or delay mmap page cache flush) -


i'm running specialized db daemon on debian-64 64g of ram , lots of disk space. uses on-disk hashtable (mmaped) , writes actual data file regular write() calls. when doing lot of updates, big part of mmap gets dirty , page cache tries flush disk, producing lots of random writes in turn slows down performance of regular (sequential) writes data file.

if possible delay page cache flush of mmaped area performance improve (i assume), since several (or all) changes dirty page written @ once instead of once every update (worst case, in reality of course aggregates lot of changes anyway).

so question: possible delay page cache flush memory-mapped area? or possible prioritze regular write? or have other ideas? madvise , posix_fadvise don't seem make difference...

you play tuneables in /proc/sys/vm. example, increase value in dirty_writeback_centisecs make pdflush wake less often, increase dirty_expire_centiseconds data allowed stay dirty longer until must written out, , increase dirty_background_ratio allow more dirty pages stay in ram before must done.
see here comprehensive description of values do.

note affect every process on machine, seeing how you're running huge database server, chances no problem since don't want else run on same machine anyway.

now of course delays writes, still doesn't solve problem of dirty page writebacks competing write (though collapse few writes if there many updates).
but: can use sync_file_range syscall force beginning write-out of pages in given range on "write" file descriptor (sync_file_range_write). while dirty pages written @ unknown time later (and greater grace periods), manually kick off writeback on ones you're interested.
doesn't give guarantees, should work.

be sure absolutely positively read documentation, better read twice. sync_file_range can corrupt or lose data if use wrong. in particular, must sure metadata up-to-date , flushed if appended file, or data has been "successfully written" "gone" in case of crash.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -