bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gawk -i inplace is an order of magnitude faster when also redirectin


From: Ed Morton
Subject: Re: gawk -i inplace is an order of magnitude faster when also redirecting stdout
Date: Sun, 3 Mar 2024 13:00:48 -0600
User-agent: Mozilla Thunderbird

Arnold - sounds good but could you change this statement:

   Due to this implementation, it helps to..

to:

   Due to this implementation, it improves execution speed to...

just so it's clear to people who don't know about the different types of buffering and their implications what difference adding `> /dev/null` would make?

Thanks,

    Ed.

On 3/3/2024 12:49 PM, arnold@skeeve.com wrote:
arnold@skeeve.com  wrote:

Adding a setvbuf() call didn't work.

Using freopen() instead of playing games with the file descriptor
might work, but it's also a hassle.

Andy - can you look at this? Try: in inplace_begin
- dup stdout to a new fd and save it as now
- do freopen on stdout to the file. this should set block buffering

In inplace_end, do freopen of /dev/fd/NNN where NNN is the duped
fd from the original stdout.

Thanks,

Arnold
I spent a bunch of time on this and could not make anything
work. So I'm going with a documentation patch.

Arnold
----------------------
diff --git a/doc/gawk.texi b/doc/gawk.texi
index a093cb08..769c82c5 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -39495,6 +39495,11 @@ For each regular file that is processed, the extension 
redirects
  standard output to a temporary file configured to have the same owner
  and permissions as the original.  After the file has been processed,
  the extension restores standard output to its original destination.
+(Due to this implementation, it helps to redirect @command{gawk}'s
+standard output to @file{/dev/null}, instead of leaving it set to
+your terminal, so that output will be block-buffered instead of
+line-buffered.)
+
  If @code{inplace::suffix} is not an empty string, the original file is
  linked to a backup @value{FN} created by appending that suffix.  Finally,
  the temporary file is renamed to the original @value{FN}.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]