[PATCH] Do not break buffers in fvwrite for unbuffered files
Federico Terraneo
fede.tft@hotmail.it
Mon Oct 21 08:36:00 GMT 2013
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
While hunting a performance bottleneck related to writing files on a
microcontroller I noticed an inconsistency in newlib for unbuffered files.
While doing an fread() with a large buffer results in a call to read()
with the same buffer and size, a call to fwrite() breaks the buffer in
multiple calls to write() each up to BUFSIZ in size.
This may cause performance issues, and for reference glibc seems to even
try to pass large buffers untouched also if the files are fully
buffered, at least that's what a simple test using strace on Linux has
shown.
This simple patch makes the behaviour of fwrite() consistent with fread().
2013-10-21 Terraneo Federico <fede.tft@hotmail.it>
* libc/stdio/fvwrite.c: Do not break buffers for unbuffered
files
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJSZOdvAAoJECkLFtN5Xr9fM2oH/A7NJZx/v48gPZpRQ7TSD0Qk
WGjr7vR0lU6D+CWwmHjj6x8utPOKZSRGFmvK1SQN9Aui8foP+qSTylt8gvGOAgEx
xtyXPrOPJp4X17IxYG251ggDF0vEWcypkzUCDLv1ZdGVqoNb6Oq9Hc6MqQzJwrqd
bM4hx2rF65/o48+ARJ6ziFPHcbdZZPlpsl1KmiK9p7M3/NvkYtcwrVpP0t27QPjl
kZmF/Ho6kmZH4uL0L7aqsayOpwqStjtPB15/F0FNFHeEgg9Yp3LBZ5KHjzi8rlF7
DfineuQBktcPyikP0KM9WfwfoSxaUMWsUbqvdENOYOnqlSNigqyDKIq2hrnHsak=
=wFdl
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fvwrite.patch
Type: text/x-patch
Size: 579 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20131021/a757cde2/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fvwrite.patch.sig
Type: application/octet-stream
Size: 287 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20131021/a757cde2/attachment.obj>
More information about the Newlib
mailing list