<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/102768>102768</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [libc++] LLVM libc++'s fstream is ridiculously slow compared to LLVM libstdc++
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          trcrsired
      </td>
    </tr>
</table>

<pre>
    ```
D:\msys64\home\unlvs\projects\fast_io\benchmark\0002.file_io_tsc\time>clang++ -o fstream fstream.cc -O3 -std=c++26 -I../../include -lntdll -s -flto=thin -fuse-ld=lld --sysroot=D:\toolchains\llvm\x86_64-windows-gnu\x86_64-windows-gnu -rtlib=compiler-rt --unwindlib=libunwind --stdlib=libc++ -lntdll -lc++abi -I../../../include

D:\msys64\home\unlvs\projects\fast_io\benchmark\0002.file_io_tsc\time>fstream
output:9.5154552s
input:2.6723663s

D:\msys64\home\unlvs\projects\fast_io\benchmark\0002.file_io_tsc\time>clang++ -o fstream fstream.cc -O3 -std=c++26 -I../../include -lntdll -s -flto=thin -fuse-ld=lld -lntdll -I../../../include

D:\msys64\home\unlvs\projects\fast_io\benchmark\0002.file_io_tsc\time>fstream
output:0.3279629s
input:0.4409194s

D:\msys64\home\unlvs\projects\fast_io\benchmark\0002.file_io_tsc\time>clang++ -o iobuf_file iobuf_file.cc -O3 -std=c++26 -I../../include -lntdll -s -flto=thin -fuse-ld=lld --sysroot=D:\toolchains\llvm\x86_64-windows-gnu\x86_64-windows-gnu -rtlib=compiler-rt --unwindlib=libunwind --stdlib=libc++ -lntdll -lc++abi -I../../../include

D:\msys64\home\unlvs\projects\fast_io\benchmark\0002.file_io_tsc\time>iobuf_file.exe
output:0.0587952s
input:0.1234146s

D:\msys64\home\unlvs\projects\fast_io\benchmark\0002.file_io_tsc\time>clang++ -o filebuf_file filebuf_file.cc -O3 -std=c++26 -I../../include -lntdll -s -flto=thin -fuse-ld=lld --sysroot=D:\toolchains\llvm\x86_64-windows-gnu\x86_64-windows-gnu -rtlib=compiler-rt --unwindlib=libunwind --stdlib=libc++ -lntdll -lc++abi -I../../../include

D:\msys64\home\unlvs\projects\fast_io\benchmark\0002.file_io_tsc\time>filebuf_file
output:0.3089046s
input:0.1379314s
```

![image](https://github.com/user-attachments/assets/97792b27-a30c-4417-801f-28bbac5a5c4b)


This is at least 20x slower than libstdc++, and I am sure it is not the buffering part but the formatting part that is ridiculously slow since the ```fast_io::filebuf_file``` isn't slow.

https://github.com/cppfastio/fast_io/blob/next/benchmark/0002.file_io_tsc/time/fstream.cc

Benchmark is here.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVk2P5CYQ_TX0BWHhwvjj4MNMdyyttFEuUa4jwHSbBJsWlHdm_n1k98d4Mqu9JZPDSi0byhTF472qLpWSO03WtkQ-EnnYqRmHEFuMJiYXbb_ToX9tScmvP34g_OFAxAOR-zG9prIgcj-E0RK5nyf_LRG5P8fwpzW4DI8q4ZMLRO61ncwwqvgXkXvOOWRH5-2TC0-YDJF7dKMl4hfj1XQi8EjgkbJAjwmjVePtnRlD2W-CsoQ9EQdzWQglZV-yjEC3Ptxk_NxbyvyEvfeUJcqOHgMRBxzcRNlxTpb5ZQPve8pYek0xBCTicMWFIXgzKDctCLz_NhK5f6nLp7Jgz27qw3Nip2n-rpGyiN7p5XBhPDtvI4tIGZunZdHli3f6Ml1i45vR3HDfDu6vFqXdO4RbmBdC_m1arvd_CRNmPM9IxEOTyVwWUkK6fHDTxQ5ZWYEoS5H-m9N9gmhuy_6HrPBMQNWU0PyDFZ4VBW_ypvgcVlzQ8_FpWbkZ_kzoT5LOhgL7Yj8oiMu6aj7kNc9yEEVelJ-U187bu4a2k58q-qwCtCHhYxXidcPvWtloSFSNyO9V6H1ncX1CTuSjG9XJEnkgUA-I57TAgI5Ad3I4zDozYSTQzclGphCVGU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