https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94268
Bug ID: 94268 Summary: std::filebuf is extremely (at least 10x) slow on windows compared to Linux. Even much slower MSVC STL with terrible ABI. Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: euloanty at live dot com Target Milestone: --- Even the hacks work the same result. https://bitbucket.org/ejsvifq_mabmip/fast_io/src/reserver_test/benchmarks/0000.10m_size_t/unit/filebuf_io_observer.cc D:\hg\w4\f8\fast_io\benchmarks\0000.10m_size_t\unit>g++ -o filebuf_io_observer filebuf_io_observer.cc -Ofast -std=c++2a -s D:\hg\w4\f8\fast_io\benchmarks\0000.10m_size_t\unit>filebuf_io_observer output: 0.5130060000000001s input: 0.256011s running the same program on Linux WSL2 cqwrteur@Home-Server:~/myhome/fast_io/benchmarks/0000.10m_size_t/unit$ g++ -o filebuf_io_observer filebuf_io_observer.cc -Ofast -std=c++2a -s cqwrteur@Home-Server:~/myhome/fast_io/benchmarks/0000.10m_size_t/unit$ ./filebuf_io_observer output: 0.058395978s input: 0.06603426700000001s It is not possible to be an optimization problem since my code has no difference on windows and linux. I think the only reason is FILE*'s issue. I guess the problem is just that code relies on unknown libc does not correctly on windows. One explanation might be the underlining FILE* buffer size's problem. I think you guys need to try larger buffer size. Same program builds with MSVC STL (Their ABIs are terrible) MSVC STL with hacking: D:\hg\w4\f8\fast_io\benchmarks\0000.10m_size_t\unit>filebuf_io_observer output: 0.119666s input: 0.2497127s Other comparison benchmarks GCC 10.0.1 with msvcrt hacking. https://bitbucket.org/ejsvifq_mabmip/fast_io/src/reserver_test/include/fast_io_legacy_impl/c/msvcrt.h D:\hg\w4\f8\fast_io\benchmarks\0000.10m_size_t\unit>c_file_unlocked output: 0.09216600000000001s input: 0.12230700000000001s GCC