GNU bug report logs -
#20029
'yes' surprisingly slow
Previous Next
Reported by: Ole Tange <tange <at> gnu.org>
Date: Sat, 7 Mar 2015 11:50:02 UTC
Severity: normal
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
Full log
Message #14 received at 20029 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 03/09/2015 01:47 PM, Pádraig Brady wrote:
>
> Note this change also ensures that yes will only write complete lines
> for lines softer than BUFSIZ.
s/softer/smaller/
>
> * src/yes.c (main): Build up a BUFSIZ buffer of lines,
> and output that, rather than having stdio process each item.
> * tests/misc/yes.sh: Add a new test for various buffer sizes.
> * tests/local.mk: Reference the new test.
> Fixes http://bugs.gnu.org/20029
> ---
> src/yes.c | 43 +++++++++++++++++++++++++++++++++++++++++--
> tests/local.mk | 1 +
> tests/misc/yes.sh | 28 ++++++++++++++++++++++++++++
> 3 files changed, 70 insertions(+), 2 deletions(-)
> create mode 100755 tests/misc/yes.sh
>
> diff --git a/src/yes.c b/src/yes.c
> index b35b13f..91dea11 100644
> --- a/src/yes.c
> +++ b/src/yes.c
> @@ -58,6 +58,10 @@ Repeatedly output a line with all specified STRING(s), or 'y'.\n\
> int
> main (int argc, char **argv)
> {
> + char buf[BUFSIZ];
Do you really want this stack-allocated? BUFSIZ can be larger than a
page, which can then interfere with stack overflow detection.
> +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
> +print_ver_ yes
> +
> +for size in 1 4095 4096 8191 8192 16383 16384; do
Should you also test 4097 8193 and 16385 (that is, a likely
1-more-than-BUFSIZ in the mix)?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
This bug report was last modified 10 years and 80 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.