[PATCH] D147340: [Support] Improve Windows performance of buffered raw_ostream

Andrew Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 5 03:05:56 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa3aa916d019c: [Support] Improve Windows performance of buffered raw_ostream (authored by andrewng).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147340/new/

https://reviews.llvm.org/D147340

Files:
  llvm/lib/Support/raw_ostream.cpp


Index: llvm/lib/Support/raw_ostream.cpp
===================================================================
--- llvm/lib/Support/raw_ostream.cpp
+++ llvm/lib/Support/raw_ostream.cpp
@@ -84,8 +84,15 @@
 }
 
 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() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147340.511034.patch
Type: text/x-patch
Size: 602 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230405/ab6ed4b6/attachment.bin>


More information about the llvm-commits mailing list