Skip to content

[6.0][llvm/Support/VirtualOutputBackends] Don't create unbuffered streams when the MirroringOutputBackend is used #8927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

akyrtzi
Copy link

@akyrtzi akyrtzi commented Jun 26, 2024

MirroringOutputBackend was forcing the raw_ostreams to be unbuffered, causing significant slowdown due to I/O. When enabling Clang caching for building Clang or WebKit, the "from scratch" (all cache misses) build was slower than the regular non-caching build. For building debug Clang the overhead was ~22%, and for debug build of WebKit, it was ~15%.

The overhead went away after removing the SetUnbuffered() calls.

rdar://130514092
(cherry picked from commit d87edc2)

…when the `MirroringOutputBackend` is used

`MirroringOutputBackend` was forcing the `raw_ostream`s to be unbuffered, causing significant slowdown due to I/O.
When enabling Clang caching for building Clang or WebKit, the "from scratch" (all cache misses) build was slower than the regular non-caching build.
For building debug Clang the overhead was ~22%, and for debug build of WebKit, it was ~15%.

The overhead went away after removing the `SetUnbuffered()` calls.

rdar://130514092
(cherry picked from commit d87edc2)
@akyrtzi
Copy link
Author

akyrtzi commented Jun 26, 2024

Explanation: When compilation is performed with Clang caching enabled, there's a MirroringOutputBackend used that forces the raw_ostreams for the outputs to be unbuffered, causing significant slowdown due to I/O, that is measurable when building Clang or WebKit projects. Original author (Duncan Exon Smith) does not remember the significance of disabling buffering, but I couldn't find any issue with allowing the raw_ostreams to be buffered. The overhead goes away with this change.
Radar (and possibly SR Issue): rdar://130514092
Scope: Affects compilations with Clang caching enabled
Risk: None anticipated
Testing: Local testing with projects
Reviewed By: Steven Wu

@akyrtzi
Copy link
Author

akyrtzi commented Jun 26, 2024

@swift-ci Please test

@bnbarham bnbarham merged commit 3ccd82b into swiftlang:swift/release/6.0 Jun 27, 2024
3 checks passed
@akyrtzi akyrtzi deleted the akyrtzi/pr/6.0-dont-disable-buffered-io branch June 27, 2024 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants