mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-06 04:52:55 +00:00
Buffer the writes to the WAL redo process pipe.
Reduces the CPU time spent in the write() syscalls. I noticed that we were spending a lot of CPU time in libc::write, coming from request_redo(), in the 'bulk_insert' test. According to some quick profiling with 'perf', this reduces the CPU time spent in request_redo() from about 30% to 15%. For some reason, it doesn't reduce the overall runtime of the 'bulk_insert' test much, maybe by one second if you squint (from about 37s to 36s), so there must be some other bottleneck, like I/O. But this is surely still a good idea, just based on the reduced CPU cycles.
This commit is contained in:
@@ -544,8 +544,9 @@ impl PostgresRedoProcess {
|
||||
base_img: Option<Bytes>,
|
||||
records: &[WALRecord],
|
||||
) -> Result<Bytes, std::io::Error> {
|
||||
let stdin = &mut self.stdin;
|
||||
let stdout = &mut self.stdout;
|
||||
// Buffer the writes to avoid a lot of small syscalls.
|
||||
let mut stdin = tokio::io::BufWriter::new(&mut self.stdin);
|
||||
|
||||
// We do three things simultaneously: send the old base image and WAL records to
|
||||
// the child process's stdin, read the result from child's stdout, and forward any logging
|
||||
|
||||
Reference in New Issue
Block a user