Pants: Barrier to contributors: Rust compilation speed

Created on 19 May 2020  路  7Comments  路  Source: pantsbuild/pants

Recently, a user reported 1.5 hours to run ./pants on a completely cold cache! We are fortunate that they didn't give up on Pants and that they shared this feedback.

While this is a one-time cost because this will get compiled, this poses an unacceptable barrier to new contributors.

--

Rust compilation is inherently slow, so we won't fix this through changes to the engine or Rust.

Instead, we need some way to cache Rust remotely - such as adding V2 Rust support to Pants. This cache would need to work for both macOS and Linux users.

We would also need to figure out how authentication should work - how would first-time contributors get the authorization to pull from the remote cache?

infra

Most helpful comment

Do you think we should blanket suggest MODE=debug, or maybe set some benchmark?

I think that unless we expect first time pants users (ie, those who have never experienced the tool built in release mode) to clone the repo and then be scared away due to the tool being slow to run, we might want to just change the default (and then toggle it back on the relevant shards in CI).

It's sortof only with experience that you would know what things should or shouldn't be done in release mode... and first time developers probably shouldn't have to make decisions like that.

All 7 comments

Another big hammer would be defaulting to MODE=debug, although we'd have to be cautious about it leaking into the wrong places in CI or benchmarks.

Ohhh good point! See https://pants.readme.io/docs/contributor-setup#step-3-bootstrap-the-rust-engine for a warning I'm adding about this.

Do you think we should blanket suggest MODE=debug, or maybe set some benchmark?

If you haven't got past 3 files in the first minute, we recommend canceling with ctrl-c and setting MODE=debug. This will substantially speed up the Rust compilation, at the expense of a slower experience running Pants.

Do you think we should blanket suggest MODE=debug, or maybe set some benchmark?

I think that unless we expect first time pants users (ie, those who have never experienced the tool built in release mode) to clone the repo and then be scared away due to the tool being slow to run, we might want to just change the default (and then toggle it back on the relevant shards in CI).

It's sortof only with experience that you would know what things should or shouldn't be done in release mode... and first time developers probably shouldn't have to make decisions like that.

That sounds great to me! We should be optimizing for first-time contributors.

We can also have a tooltip recommending changing the value if you want Pants to run faster.

For reference: the default for cargo and rust in general is to build in debug mode. It takes an extra flag (--release) to build in release mode. Lots of first time rust devs end up posting stackoverflow questions like "why is X slow?" for which 90% of the time the answer is "because you didn't turn on --release".

first time pants users (ie, those who have never experienced the tool built in release mode) to clone the repo and then be scared away due to the tool being slow to run,

I expect before that scares them away, they would be scared away by thinking they need to download Rust to run the tool in the first place.

Ideally, they will have run Pants the normal way via a wheel before contributing. We can audit our docs to encourage that flow.

Closing because we realized that MODE=debug is a bad default. Remote caching would be great, but should be tracked by a proper ticket for Rust support, rather than here.

Was this page helpful?
0 / 5 - 0 ratings