From 7ac4154643a952fed1d942adcb78e27b17ad41dd Mon Sep 17 00:00:00 2001 From: Markus Westerlind Date: Mon, 17 Feb 2020 08:09:34 +0100 Subject: [PATCH] perf: Buffer stderr when writing json errors/warnings 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_errors/json.rs b/src/librustc_errors/json.rs index ffdff6acec5..f0cfd815a2c 100644 --- a/src/librustc_errors/json.rs +++ b/src/librustc_errors/json.rs @@ -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, -- 2.44.0