`<xiosbase>`: `std::ios_base::sync_with_stdio` has no effect in VS
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
Describe the bug
std::ios_base::sync_with_stdio has no effect in the STL but cout becomes much faster after calling sync_with_stdio on mingw + libstdc++ .
#include <cstdio>
#include <ctime>
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
clock_t start, end;
start = clock();
for (int i = 0; i < 1e+4; i++) {
cout << i;
}
end = clock();
cout << endl;
cout << end - start << endl;
return 0;
}
Expected behavior
sync_with_stdio should give some performance.
STL version
Microsoft Visual Studio Community 2022
Version 17.6.0 Preview 3.0
Additional context
Devcom-10347093
I suggested to the user to add setvbuf(stdout, nullptr, _IOLBF, 16384); after sync_with_stdio but this optimization is still missing.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling and running the provided sample with Microsoft Visual Studio 17.6 Preview 3.0, then compare its timing with the reported mingw + libstdc++ behavior. Investigate the MSVC STL implementation of std::ios_base::sync_with_stdio and verify that the change produces a measurable performance effect without breaking stream behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100