]> git.lizzy.rs Git - rust.git/commitdiff
perf: Buffer stderr when writing json errors/warnings
authorMarkus Westerlind <markus.westerlind@distilnetworks.com>
Mon, 17 Feb 2020 07:09:34 +0000 (08:09 +0100)
committerMarkus Westerlind <markus.westerlind@distilnetworks.com>
Mon, 17 Feb 2020 14:35:42 +0000 (15:35 +0100)
Since `stderr` is unbuffered, writing out json messages actually take up
about ~10%/0.1s of the runtime of the `inflate` benchmark.

cc #64413

src/librustc_errors/json.rs

index ffdff6acec5de1b0a08553198c048fda445667b3..f0cfd815a2c3e473f1e127ac08f322745eae39cf 100644 (file)
@@ -48,7 +48,7 @@ pub fn stderr(
         macro_backtrace: bool,
     ) -> JsonEmitter {
         JsonEmitter {
-            dst: Box::new(io::stderr()),
+            dst: Box::new(io::BufWriter::new(io::stderr())),
             registry,
             sm: source_map,
             pretty,