apple / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. This fork is used to manage Apple’s stable releases of Clang as well as support the Swift project.
https://llvm.org
Other
1.09k stars 320 forks source link

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

Closed akyrtzi closed 5 days ago

akyrtzi commented 6 days ago

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 d87edc2fde10542ada0bd7b2fb30555375df7b70)

akyrtzi commented 6 days ago

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 commented 6 days ago

@swift-ci Please test