diff options
author | Andrew Ng <andrew.ng@sony.com> | 2023-03-31 17:50:22 +0100 |
---|---|---|
committer | Tobias Hieta <tobias@hieta.se> | 2023-04-14 08:36:02 +0200 |
commit | b5aa566a7e5326e9aecf795a3fef148798092715 (patch) | |
tree | 11569451ce01e1cd550d4627f5185904f5092d10 | |
parent | 74e76ab7b6f8b2847521950f31d56bcaedc1678d (diff) | |
download | llvm-b5aa566a7e5326e9aecf795a3fef148798092715.tar.gz |
[Support] Improve Windows performance of buffered raw_ostream
The "preferred" buffer size for raw_ostream is set to BUFSIZ which on
Windows is only 512. This results in more calls to write and this
overhead can have a significant negative impact on performance,
especially when Anti-Virus is also involved.
Therefore increase the "preferred" buffer size to 16KB for Windows.
One example of where this helps is the LLD --Map option which dumps out
the symbol map for a link. In a link of UE4, this change has been seen
to improve the performance of the symbol map writing by more than a
factor of 6.
Differential Revision: https://reviews.llvm.org/D147340
(cherry picked from commit a3aa916d019c8deb10c750acecdef650b3365f22)
-rw-r--r-- | llvm/lib/Support/raw_ostream.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp index 7b9b8b2f53fb..fae4a4308fd7 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -84,8 +84,15 @@ raw_ostream::~raw_ostream() { } size_t raw_ostream::preferred_buffer_size() const { +#ifdef _WIN32 + // On Windows BUFSIZ is only 512 which results in more calls to write. This + // overhead can cause significant performance degradation. Therefore use a + // better default. + return (16 * 1024); +#else // BUFSIZ is intended to be a reasonable default. return BUFSIZ; +#endif } void raw_ostream::SetBuffered() { |