Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Prevent unnecessary fsyncs caused by periodic fsyncs in rdb snapshots…

… and aof rewrites.
  • Loading branch information...
commit 785cf9297733e32110daed8ca8b16169ea4288b5 1 parent 4fe5034
@yoav-steinberg yoav-steinberg authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/rio.c
View
4 src/rio.c
@@ -82,10 +82,10 @@ static size_t rioFileWrite(rio *r, const void *buf, size_t len) {
size_t bytes_to_write = (r->io.file.fsync_interval && r->io.file.fsync_interval < len) ? r->io.file.fsync_interval : len;
if (fwrite((char*)buf + bytes_written,bytes_to_write,1,r->io.file.fp) != 1)
return 0;
+ if (r->io.file.fsync_interval && (r->processed_bytes + bytes_written)/r->io.file.fsync_interval < (r->processed_bytes + bytes_written + bytes_to_write)/r->io.file.fsync_interval)
+ fsync(fileno(r->io.file.fp));
bytes_written += bytes_to_write;
len -= bytes_to_write;
- if (r->io.file.fsync_interval && r->processed_bytes/r->io.file.fsync_interval < (r->processed_bytes + bytes_written)/r->io.file.fsync_interval)
- fsync(fileno(r->io.file.fp));
}
return 1;
}
Please sign in to comment.
Something went wrong with that request. Please try again.