diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2020-11-09 13:01:01 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2020-11-09 13:01:01 -0800 |
commit | 42904eef310313eeed6f8d91d5306488fd016d2e (patch) | |
tree | a240c60973296f52c6d32391c0ff731360efdf59 /src/rmd_parseargs.c | |
parent | 1a06acc0e75eacb6f284999e7530b729b3cb261c (diff) |
cache: introduce "syncer" thread for cache writers
This adds a new flag:
--periodic-datasync-ms
with a default of 100ms.
When a new CacheFile is created for writing, and the datasync
period is non-zero, a thread is created for the sole purpose of
calling fdatasync() on the underlying fd in a loop separated by
sleeps of the specified duration.
The purpose of this is to prevent a large backlog of dirty
buffers from accumulating until the operating system's normal
background dirty sync kicks in. Depending on how the underlying
filesystem and storage stack is configured, these bulk writebacks
can result in very long stalls on a subsequent write operation.
This is easily observed on ext4+lvm+dmcrypt setups, even using a
simple test like `dd if=/dev/urandom of=testfile bs=8M`. Despite
having plenty of available buffers, once ext4's internal journal
fills while a bulk writeback is underway, dd's progress will
completely stall until the entire writeback is completed, usually
it's in the jbd2 wchan of do_get_write_access().
When this occurs during a recording by recordMyDesktop, the
result is dropping frames for the entire duration of the stall.
One thing recordMyDesktop could do to insulate from this is
perform its own buffering of sampled frames at the YUV stage,
with the cache writer consuming from this pool of buffered
frames. Then when the cache writer gets stalled on jbd2/dmcrypt
holdups, the buffer pool just grows instead of frames being
dropped. I may explore this option in the future, but for now
simply syncing regularly has been sufficient in my usage, as it
keeps the storage subsystem more continuously utilized and
spreads out the writebacks so they don't completely back up the
journal.
Diffstat (limited to 'src/rmd_parseargs.c')
-rw-r--r-- | src/rmd_parseargs.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/rmd_parseargs.c b/src/rmd_parseargs.c index 5a39f2a..e4cfdd7 100644 --- a/src/rmd_parseargs.c +++ b/src/rmd_parseargs.c @@ -262,6 +262,11 @@ boolean rmdParseArgs(int argc, char **argv, ProgArgs *arg_return) "Image data are cached with light compression.", NULL }, + { "periodic-datasync-ms", '\0', + POPT_ARG_INT, &arg_return->periodic_datasync_ms, 0, + "Asynchronously fdatasync() cache files every specified ms while writing, 0 disables (default 100).", + "N>=0"}, + { "workdir", '\0', POPT_ARG_STRING, &arg_return->workdir, 0, "Location where a temporary directory will be created to hold project files(default $HOME).", |