Stream: t-compiler

Topic: Tracing in rustc


David Barsky (May 23 2020 at 18:06, on Zulip):

Hello! There's been some discussion on #wg-traits about introducing tracing into Chalk, which would make it transitive dependency of rustc, I believe. I also believe that this might require a MCP for the introduction of new/different logging dependency. Am I correct? Is the introduction of tracing be something that y'all would be opposed to?

Regardless if an MCP is required, I'd like to put together a small PR (with the intention of discarding it!) where log is replaced with tracing in rustc. There's been a few situations where a drop-in replacement of log with tracing resulted in a non-trivial performance improvements. Off the top of my head, Eliza Weisman observed that replacing log with tracing in h2 for fully disabled log statements yielded a p99 performance improvement of 2 ms; dropping from 3ms to 1ms. I'm not sure I expect something as dramatic as this in rustc (given H2 is an interactive system and rustc is batch-optimized...), but measuring the compiler performance impact might be useful.

David Barsky (May 23 2020 at 18:07, on Zulip):

(Measuring and accepting a change in rustc might allow for less work in Chalk to feature-flag out some of tracing's more advanced macros _and_—this is a big maybe—yield performance improvements in rustc.)

Jack Huey (May 23 2020 at 18:27, on Zulip):

It's worth noting that with some (roughly) planned refactoring to Chalk crate structure, tracing probably won't even be a transitive dependency of librustc_middle, only librustc_traits

David Barsky (May 23 2020 at 18:49, on Zulip):

Oh, good to hear. I now realize you mentioned this yesterday, but I didn't process it. Thanks for the correction and sorry for making you repeat it :)

nikomatsakis (May 26 2020 at 18:01, on Zulip):

@David Barsky one thing to note is that, in rustc anyway, I think logging is compiled out in release builds

nikomatsakis (May 26 2020 at 18:01, on Zulip):

in particular, if debug-assertions is not enabled

David Barsky (May 26 2020 at 18:01, on Zulip):

ah, then this will be a no-op. excellent!

oli (May 26 2020 at 18:06, on Zulip):

I would love to have tracing in rustc instead of plain log

nikomatsakis (May 26 2020 at 18:06, on Zulip):

if we can get more structured logs out, I'm a fan

oli (May 26 2020 at 18:07, on Zulip):

I mean... as already stated, we can start with a drop-in replacement and then slowly play with the advanced features

David Barsky (May 26 2020 at 18:41, on Zulip):

Okay, to make sure I understand the conclusions:

bjorn3 (May 26 2020 at 18:57, on Zulip):

nikomatsakis said:

David Barsky one thing to note is that, in rustc anyway, I think logging is compiled out in release builds

$ echo "fn main() {}" | RUSTC_LOG=trace rustc -
[INFO  rustc_metadata::creader] resolving crate `std`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /home/bjorn/.rustup/toolchains/nightly-2020-05-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-265ff16c7b6b86f9.rlib
[...]
[INFO  rustc_codegen_ssa::back::link] linker stderr:

[INFO  rustc_codegen_ssa::back::link] linker stdout:

Info and higher are enabled when debug assertions are disables: https://github.com/rust-lang/rust/blob/7b73d14b0b35e7b4f79f2d71dc1bbbab31698288/src/librustc_hir/Cargo.toml#L21

Last update: May 29 2020 at 15:20UTC