Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve incremental compile speed on webrender_api #59650

Closed
nnethercote opened this issue Apr 2, 2019 · 3 comments
Closed

Improve incremental compile speed on webrender_api #59650

nnethercote opened this issue Apr 2, 2019 · 3 comments
Labels
A-incr-comp Area: Incremental compilation C-enhancement Category: An issue proposing an enhancement or a PR with one. I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nnethercote
Copy link
Contributor

This was originally filed as a rustc-perf issue, but I'm moving it here because it's really a rustc issue.

The workload in question:

cd webrender/webrender_api && cargo check && touch color.rs && cargo check

In rustc-perf parlance, that is a "CleanIncr" build.

The 5692 lines of rust code in webrender_api expand to 85511 with cargo expand, largely due to serde, and the expansion phase dominates. So it's basically a stress test for proc macro expansion.

#59476 helped a tiny bit. #59507 helped more. The major remaining source of inefficiency is libproc_macro's buffer for communicating between client and server. Buffer::write_all is called more than a million times, almost always for a single byte, mostly due to uleb128 encoding of integers. @eddyb said they would try to improve that code. I estimate this could save another 10%, maybe more.

@nnethercote
Copy link
Contributor Author

Here is some edited Cachegrind output from the abovementioned workload. I removed various entries that didn't obviously relate to proc_macro::bridge.

--------------------------------------------------------------------------------
Ir                      file:function
--------------------------------------------------------------------------------
1,491,299,765 ( 6.63%)  /build/glibc-B9XfQf/glibc-2.28/string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:__memcpy_avx_unaligned_erms
  825,107,571 ( 3.67%)  /home/njn/moz/rust0/src/libproc_macro/bridge/buffer.rs:proc_macro::bridge::buffer::Buffer<T>::extend_from_slice
  364,463,350 ( 1.62%)  /home/njn/moz/rust0/src/libproc_macro/bridge/server.rs:<proc_macro::bridge::server::Dispatcher<proc_macro::bridge::server::MarkedTypes<S>> as proc_macro::bridge::server::DispatcherTrait>::dispatch
  294,650,515 ( 1.31%)  /home/njn/moz/rust0/src/libcore/slice/mod.rs:proc_macro::bridge::buffer::Buffer<T>::extend_from_slice
  249,165,011 ( 1.11%)  /home/njn/moz/rust0/src/libproc_macro/bridge/rpc.rs:<proc_macro::bridge::server::Dispatcher<proc_macro::bridge::server::MarkedTypes<S>> as proc_macro::bridge::server::DispatcherTrait>::dispatch
  222,085,140 ( 0.99%)  /home/njn/moz/rust0/src/libproc_macro/bridge/buffer.rs:<proc_macro::bridge::buffer::Buffer<u8> as std::io::Write>::write_all
  207,506,745 ( 0.92%)  /home/njn/moz/rust0/src/libproc_macro/bridge/rpc.rs:<core::result::Result<T,E> as proc_macro::bridge::rpc::DecodeMut<S>>::decode
  141,654,879 ( 0.63%)  /home/njn/moz/rust0/src/liballoc/collections/btree/search.rs:proc_macro::bridge::client::<impl proc_macro::bridge::rpc::DecodeMut<proc_macro::bridge::client::HandleStore<proc_macro::bridge::server::MarkedTypes<S>>> for proc_macro::bridge::Marked<<S as proc_macro::bridge::server::Types>::TokenStream,proc_macro::bridge::client::TokenStream>>::decode
  138,111,307 ( 0.61%)  /home/njn/moz/rust0/src/libproc_macro/bridge/rpc.rs:<core::result::Result<T,E> as proc_macro::bridge::rpc::Encode<S>>::encode
  125,087,401 ( 0.56%)  /home/njn/moz/rust0/src/libproc_macro/bridge/rpc.rs:<proc_macro::bridge::server::Dispatcher<proc_macro::bridge::server::MarkedTypes<S>> as proc_macro::bridge::server::DispatcherTrait>::dispatch::{{closure}}
  121,934,434 ( 0.54%)  /home/njn/moz/rust0/src/liballoc/collections/btree/search.rs:proc_macro::bridge::client::<impl proc_macro::bridge::rpc::Encode<proc_macro::bridge::client::HandleStore<proc_macro::bridge::server::MarkedTypes<S>>> for proc_macro::bridge::Marked<<S as proc_macro::bridge::server::Types>::TokenStream,proc_macro::bridge::client::TokenStream>>::encode
  117,864,212 ( 0.52%)  /home/njn/moz/rust0/src/libcore/num/mod.rs:proc_macro::bridge::buffer::Buffer<T>::extend_from_slice
  117,647,691 ( 0.52%)  /home/njn/moz/rust0/src/libstd/panicking.rs:<proc_macro::bridge::server::Dispatcher<proc_macro::bridge::server::MarkedTypes<S>> as proc_macro::bridge::server::DispatcherTrait>::dispatch

@jonas-schievink jonas-schievink added A-incr-comp Area: Incremental compilation I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Apr 2, 2019
@nnethercote
Copy link
Contributor Author

#59820 helps some more.

@Mark-Simulacrum
Copy link
Member

Closing. The particular benchmark I think was removed & replaced in ~2022, but the current incr-unchanged compile times are around 1 second for this crate, and have been improving steadily. I don't think there's necessarily more to pay attention to for this particular case.

image

(src: https://perf.rust-lang.org/index.html?start=2019-04-01&benchmark=webrender-2022&profile=check&scenario=incr-unchanged&stat=wall-time&kind=raw)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation C-enhancement Category: An issue proposing an enhancement or a PR with one. I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants