Use posix_fadvise() like cat(1) does
Date: Wed, 28 Oct 2015 14:04:59 +0100
From: Jacek Wielemborek
Subject: pv performance improvements: direct I/O and POSIX_FADV_SEQUENTIAL?
Hi,
I was exploring a performance problem I was having with my system today
and found that it's most likely that the Linux kernel caches a big files
that "pv" reads and drops important cached files that have to be re-read
later. I read up on a solution and found that pv could use some direct
I/O support, so that if a file is too big, it doesn't overwrite all
cache. Also, posix_fadvise(infile_fd, POSIX_FADV_SEQUENTIAL, 0, 0);
could perhaps add a speedup - that's what I found in "cat" source code.
What do you think?
Date: Mon, 9 Nov 2015 22:42:24 +0000
From: Andrew Wood
To: Jacek Wielemborek
Subject: Re: pv performance improvements: direct I/O and POSIX_FADV_SEQUENTIAL?
Thanks for the suggestions.
I already use the cache loading side effect of PV to show a progress bar
while certain large files are pre-cached - I think you're right to suggest
an option to turn this off by using direct I/O.
I'd not heard of the posix_fadvise() function and will look into it. It
sounds like a good idea, I just need to make sure that any code I add is
portable to all the systems PV currently runs on.
Date: Wed, 28 Oct 2015 14:04:59 +0100 From: [Jacek Wielemborek](https://github.com/d33tah) Subject: pv performance improvements: direct I/O and POSIX_FADV_SEQUENTIAL? Hi, I was exploring a performance problem I was having with my system today and found that it's most likely that the Linux kernel caches a big files that "pv" reads and drops important cached files that have to be re-read later. I read up on a solution and found that pv could use some direct I/O support, so that if a file is too big, it doesn't overwrite all cache. Also, posix_fadvise(infile_fd, POSIX_FADV_SEQUENTIAL, 0, 0); could perhaps add a speedup - that's what I found in "cat" source code. What do you think? ---- Date: Mon, 9 Nov 2015 22:42:24 +0000 From: Andrew Wood To: Jacek Wielemborek Subject: Re: pv performance improvements: direct I/O and POSIX_FADV_SEQUENTIAL? Thanks for the suggestions. I already use the cache loading side effect of PV to show a progress bar while certain large files are pre-cached - I think you're right to suggest an option to turn this off by using direct I/O. I'd not heard of the posix_fadvise() function and will look into it. It sounds like a good idea, I just need to make sure that any code I add is portable to all the systems PV currently runs on.