From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E0C8C3858426; Tue, 8 Nov 2022 17:44:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E0C8C3858426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667929467; bh=k9lpE7STRnaXpFsRHxV+Y8OrEYsd8ViBfIJQbmfiDPY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xAsjYKj/mdowlmpfPexU8KLh3YNozRjiRpTPz9ju5wSnqUePqjbKKMrFNiKfXCEm/ i70XOPo+fZEfLyX6MpaR0pLiZcC2l1LjMIjapH0ZDfdpYGK/R5XE+z/auKZe34QE9r 3QXYD7A9gsTd+W015tUadaAgR4ayg1pXkW/u0V8A= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/63746] i/o fragmentation inside basic_filebuf::xsputn Date: Tue, 08 Nov 2022 17:44:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D63746 --- Comment #6 from CVS Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:3f1519eef5cbdcea2f18445852f5482798e3936a commit r13-3815-g3f1519eef5cbdcea2f18445852f5482798e3936a Author: Charles-Fran=C3=A7ois Natali Date: Thu Oct 6 20:02:56 2022 +0100 libstdc++: basic_filebuf: don't flush more often than necessary [PR6374= 6] `basic_filebuf::xsputn` would bypass the buffer when passed a chunk of size 1024 and above, seemingly as an optimisation. This can have a significant performance impact if the overhead of a `write` syscall is non-negligible, e.g. on a slow disk, on network filesystems, or simply during IO contention because instead of flushing every `BUFSIZ` (by default), we can flush every 1024 char. The impact is even greater with custom larger buffers, e.g. for network filesystems, because the code could issue `write` for example 1000X more often than necessary with respect to the buffer size. It also introduces a significant discontinuity in performance when writing chunks of size 1024 and above. Instead, it makes sense to only bypass the buffer if the amount of data to be written is larger than the buffer capacity. Signed-off-by: Charles-Francois Natali libstdc++-v3/ChangeLog: PR libstdc++/63746 * include/bits/fstream.tcc (basic_filbuf::xsputn): Remove 1024-byte chunking that bypasses the buffer for large writes. * testsuite/27_io/basic_filebuf/sputn/char/63746.cc: New test.=