Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16427

[PATCH 5.1] zread: read files in 4k chunks

From "Jason A. Donenfeld" <Jason@zx2c4.com>
Newsgroups gnu.bash.bug
Subject [PATCH 5.1] zread: read files in 4k chunks
Date 2020-06-21 23:53 -0600
Message-ID <mailman.248.1592805217.2574.bug-bash@gnu.org> (permalink)
References <20200622055328.155106-1-Jason@zx2c4.com>

Show all headers | View raw


Currently a static sized buffer is used for reading files. At the moment
it is extremely small, making parsing of large files extremely slow.
Increase this to 4k for improved performance. This also allows reading
files like /dev/kmsg on Linux, which will error if the read buffer is
too small.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 lib/sh/zread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/sh/zread.c b/lib/sh/zread.c
index 8dd78102..f1389887 100644
--- a/lib/sh/zread.c
+++ b/lib/sh/zread.c
@@ -117,7 +117,7 @@ zreadintr (fd, buf, len)
    in read(2).  This does some local buffering to avoid many one-character
    calls to read(2), like those the `read' builtin performs. */
 
-static char lbuf[128];
+static char lbuf[4096];
 static size_t lind, lused;
 
 ssize_t
-- 
2.27.0

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

[PATCH 5.1] zread: read files in 4k chunks "Jason A. Donenfeld" <Jason@zx2c4.com> - 2020-06-21 23:53 -0600

csiph-web