Log Message: |
Fix the excessive amount of read and seek syscalls in various fsfs operations
that read from disk.
The idea behind the fix is that we provide a special svn_stream_readline()
implementation for APR file-based streams that handles a common case of
LF ("\n") end-of-line sequence with apr_file_gets().
For example, this patch turns the following sequence ...
open("/repo/db/revs/22.pack/manifest", O_RDONLY|O_CLOEXEC) = 4
read(4, "0\n3304\n7139\n12288\n13981\n37151\n59"..., 4096) = 4096
read(4, "5140\n20998974\n21002732\n21004670\n"..., 4096) = 4096
lseek(4, 4020, SEEK_SET) = 4020
read(4, "18102627\n18139220\n18141921\n18147"..., 4096) = 4096
read(4, "2535219\n52537641\n52550290\n525536"..., 4096) = 584
lseek(4, 8043, SEEK_SET) = 8043
read(4, "51452518\n51454318\n51456275\n51457"..., 4096) = 657
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
read(4, "", 4096) = 0
close(4) = 0
...into this:
open("/repo/db/revs/22.pack/manifest", O_RDONLY|O_CLOEXEC) = 4
read(4, "0\n3304\n7139\n12288\n13981\n37151\n59"..., 4096) = 4096
read(4, "5140\n20998974\n21002732\n21004670\n"..., 4096) = 4096
read(4, "131\n52730772\n52744939\n52748273\n5"..., 4096) = 508
read(4, "", 4096) = 0
close(4)
* subversion/libsvn_subr/stream.c
(readline_apr_lf): New.
(readline_apr_generic): New, factored out from ...
(readline_apr_handler): ...here. Call the apr_file_gets()-based routine
when we're looking for an LF end-of-line sequence to avoid unnecessary
syscalls.
* subversion/tests/libsvn_subr/stream-test.c
(test_stream_readline_file): New helper for ...
(test_stream_readline_file_lf, test_stream_readline_file_crlf): ...these
new tests that cover svn_stream_readline() behavior for LF and CRLF
terminated lines.
(test_funcs): Add new tests.
|