public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pluto at agmk dot net" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/63746] New: i/o fragmentation inside basic_filebuf::xsputn Date: Wed, 05 Nov 2014 09:05:00 -0000 [thread overview] Message-ID: <bug-63746-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63746 Bug ID: 63746 Summary: i/o fragmentation inside basic_filebuf::xsputn Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: pluto at agmk dot net Hi, i'm trying to minimize small i/o operations for better overal application perfromance over networked filesystems. setting quite large stream buffer doesn't work as axpected in some cases. #include <iostream> #include <fstream> #include <memory> #include <sstream> #include <string> int main() { std::size_t bufferSize = 1024*1024; std::unique_ptr< char > buffer( new char[ bufferSize ] ); std::ofstream f; f.rdbuf()->pubsetbuf( buffer.get(), bufferSize ); f.open( "s.txt", std::ios_base::out | std::ios_base::binary ); std::stringstream ss; std::string s1( 10240, 'x' ); ss.str( std::string() ); ss << s1; f << ss.rdbuf(); ss.str( std::string() ); ss << s1; f << ss.rdbuf(); f.close(); } % g++ s.cpp -o s -Wall -g2 -std=c++11 % LANG=C strace ./s (...) open("s.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3 writev(3, [{NULL, 0}, {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"..., 8136}], 2) = 8136 writev(3, [{"", 0}, {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"..., 2104}], 2) = 2104 writev(3, [{"", 0}, {"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"..., 10240}], 2) = 10240 close(3) i've expected that 20kB i/o from testcase will fit in the 1MB buffer but the fstream.tcc contains magic const __chunk = 1k and logic that not use the buffer in the optimal way.
next reply other threads:[~2014-11-05 9:05 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-11-05 9:05 pluto at agmk dot net [this message] 2014-11-05 14:22 ` [Bug libstdc++/63746] " pluto at agmk dot net 2022-11-07 13:54 ` redi at gcc dot gnu.org 2022-11-07 14:12 ` redi at gcc dot gnu.org 2022-11-08 17:44 ` cvs-commit at gcc dot gnu.org 2022-11-08 18:02 ` redi at gcc dot gnu.org 2022-11-08 18:19 ` pawel_sikora at zoho dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-63746-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).