[Libguestfs] [nbdkit PATCH] sh: Prefer dd bs=1 over iflag=count_bytes

Eric Blake eblake at redhat.com
Mon Aug 17 17:45:47 UTC 2020


On 8/17/20 11:35 AM, Eric Blake wrote:
> While iflag=count_bytes combined with bs > 1 allows for more efficient
> operation, it is a feature of GNU dd, and not present on other
> implementations such as BSD.  Sticking to just POSIX features makes
> things more portable.
> 
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---
>   docs/nbdkit-loop.pod                | 2 +-
>   docs/nbdkit.pod                     | 4 ++--
>   plugins/eval/nbdkit-eval-plugin.pod | 6 +++---
>   plugins/sh/nbdkit-sh-plugin.pod     | 2 +-
>   plugins/sh/assemble.sh              | 2 +-
>   plugins/sh/example.sh               | 7 +++----
>   tests/test-cacheextents.sh          | 5 ++---
>   tests/test-eval-file.sh             | 5 ++---
>   tests/test-eval.sh                  | 3 +--
>   tests/test-export-name.sh           | 5 ++---
>   tests/test-parallel-sh.sh           | 5 ++---
>   tests/test-readahead-test-plugin.sh | 2 +-
>   tests/test-readahead.sh             | 1 -
>   tests/test-retry-reopen-fail.sh     | 3 +--
>   tests/test-retry-size.sh            | 3 +--
>   tests/test-retry.sh                 | 3 +--
>   tests/test-shell.sh                 | 5 ++---
>   tests/test-single-sh.sh             | 3 +--
>   tests/test-tls-fallback.sh          | 2 +-
>   19 files changed, 28 insertions(+), 40 deletions(-)

To see if this makes a noticeable impact on GNU systems, I compared:

$ time make -C tests check TESTS='test-cacheextents.sh test-eval-file.sh 
test-eval.sh test-export-name.sh test-parallel-sh.sh test-readahead.sh 
test-retry-reopen-fail.sh test-retry-size.sh test-retry.sh test-shell 
test-single-sh.sh test-tls-fallback.sh'

after first completing an entire 'make check' to prime the cache. 
Typical timings of a few runs were

before:
real	1m45.445s
user	0m6.626s
sys	0m4.181s

after:
real	1m53.366s
user	0m13.510s
sys	0m13.387s


So it is indeed a noticeable slowdown (although it also points out that 
the bulk of our test time is spend sleep()ing, waiting for servers to 
start or for parallel tests to prove their merit).

But not all the tests use the same amount of .pread calls; breaking it 
down into per-test timings, I see the worst degradation in 
test-eval-file.sh (8 seconds!), second worst in test-shell (~0.8s); but 
both make sense - those are the tests where we are hammering the file 
with the most .pread and .pwrite calls from libguestfs, rather than a 
one-off read or even testing something unrelated to read.

Maybe instead of directly using this patch, we instead compromise by 
mentioning the speedup trick in the .pod files (list the portable 
spelling side-by-side with the efficient GNU-only spelling), and make 
those two tests use the efficient spelling.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




More information about the Libguestfs mailing list