base64: improve encoding I/O efficiency
commit91208453756bf0e86e25c2db35e481ac178f1255
authorPádraig Brady <P@draigBrady.com>
Mon, 11 Nov 2013 02:51:17 +0000 (11 02:51 +0000)
committerPádraig Brady <P@draigBrady.com>
Mon, 11 Nov 2013 23:30:39 +0000 (11 23:30 +0000)
tree9da172f4244cfbd84950cd05eb36aac24463281b
parent90181a5926e96f34b5ffff21b81a2874a846ff6f
base64: improve encoding I/O efficiency

Since the I/O overhead is significant to the relatively
simple processing done by this utility, use fputs() rather
than fputc() to output '\n'.
Time to process a 100MiB file was measured to
decrease from 0.417s to 0.383s, i.e. an 8% improvement.

Related to these changes, is a processing improvement in
gnulib, which increases throughput by 60% when processing
full buffers, which improves processing of a 100MiB file
with standard wrapped output, down to 0.256s.
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commit;h=43fd1e7b

Also increase the encoding buffer size from 3 to 30KiB.
This was seen to give a further 8% improvement, taking
processing time down to 0.235s in the wrapped output case.
The decoding size buffer is not adjusted,
due to the noted caveat with --ignore-garbage.

* src/base64.c (BLOCKSIZE): Split into ENC_ and DEC_ variants,
with the former increased from 3KiB to 30KiB.
(wrap_write): Use the simpler fputc() rather than fputs()
to output the '\n' character.  Also check against EOF
rather than < 0 for errors.
(do_encode): Likewise.
* NEWS: Mention the large increase in performance, which
with the I/O improvements in coreutils and the processing
improvement in gnulib, amount to about a 60% throughput increase.
NEWS
src/base64.c