[llvm-bugs] [Bug 35629] New: i/o fragmentation inside fstream.

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 11 12:20:08 PST 2017


            Bug ID: 35629
           Summary: i/o fragmentation inside fstream.
           Product: libc++
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: pawel_sikora at zoho.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

i'm trying to minimize small i/o operations for better overall application
performance over network filesystem. setting quite large stream buffer doesn't
work as axpected.

% cat t.cpp 
#include <fstream>
#include <memory>
#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::string s1( 10240, 'x' );
    f << s1;
    f << s1;

% ~/toolchain/llvm/sysroot/bin/clang++ t.cpp -o t
-Wl,-rpath,$HOME/toolchain/llvm/sysroot/lib -std=c++1y -stdlib=libc++ -ggdb     
% strace ./t 2>&1 |grep write                                                   
write(3, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"..., 4096) = 4096
write(3, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"..., 16384) = 16384

% g++ t.cpp -o t -std=c++1y // g++ from fedora-27
% strace ./t 2>&1 |grep write
writev(3, [{iov_base=NULL, iov_len=0},
{iov_base="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"..., iov_len=10240}], 2) = 10240
writev(3, [{iov_base="", iov_len=0},
{iov_base="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"..., iov_len=10240}], 2) = 10240

gcc with my patch from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63746:

% ~/toolchain/gcc/sysroot/bin/x86_64-linux-gnu-g++ t.cpp -o t
-Wl,-rpath,$HOME/toolchain/gcc/sysroot/lib64 -std=c++1y
% strace ./t 2>&1 |grep write                                                   
write(3, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"..., 20480) = 20480

looks like both standard c++ library implementations need patching in this

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171211/07f0a90b/attachment.html>

More information about the llvm-bugs mailing list