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

Support -incremental mode #48

Closed
allevato opened this issue Aug 15, 2018 · 9 comments
Closed

Support -incremental mode #48

allevato opened this issue Aug 15, 2018 · 9 comments
Labels
P3 Would be nice, but probably next quarter at the earliest type: feature request New feature or request

Comments

@allevato
Copy link
Member

We may be able to do this with a Bazel persistent worker, which would let us non-hermetically collect the outputs of a library's previous compilations and feed them back in as inputs to future compilations, so that the driver can detect whether they have changed.

However, this is more complicated than simply flipping on a flag—we'll need to design and build a local server that is used as the worker process.

@allevato allevato added type: feature request New feature or request P3 Would be nice, but probably next quarter at the earliest labels Aug 15, 2018
@keith
Copy link
Member

keith commented Aug 29, 2018

Are there any related issues elsewhere about supporting the Swift-style incremental compilation model? It sounds like kotlin and rust might also benefit from support for this in bazel, although I'm not 100% sure they use exactly the same model.

@pauldraper
Copy link

pauldraper commented Sep 3, 2018

bazel-discuss using a stateful compiler with Bazel

rules_scala Should we re-consider zinc's incremental compilation?

I helped author https://github.com/andyscott/rules_scala_annex which implements Zinc (stateful incremental Scala compiler). There, the stateful incrementality is an opt-in for workers.

@kastiglione
Copy link
Contributor

Thanks for the references @pauldraper.

@keith
Copy link
Member

keith commented Sep 24, 2018

Posted the first blocker we hit while working on the persistent worker approach here bazelbuild/bazel#6223

@kastiglione
Copy link
Contributor

kastiglione commented Sep 25, 2018

In bazelbuild/rules_apple#21 (comment), @​dmishe listed two approaches: a non-sandbox approach (persisting incremental artifacts in the file system), and a persistent worker approach. What are the trade-offs between the two alternative options?

@keith
Copy link
Member

keith commented Sep 25, 2018

Posted another blocker we hit bazelbuild/bazel#6230 in theory we could work around this by using a list for building the linker arguments, but being able to combine Args objects seems reasonable to solve this as well.

@pauldraper
Copy link

pauldraper commented Sep 25, 2018

In bazelbuild/rules_apple#21 (comment), @​dmishe listed two approaches: a non-sandbox approach (persisting incremental artifacts in the file system), and a persistent worker approach. What are the trade-offs between the two alternative options?

Both cases are fairly similar to implement, as I imagine(?) the worker will still persist files on disk. The ergonomics of selecting incremental compilation can differ.

Note you will still want to make sure a non-worker, sandboxed, non-incremental fully deterministic method exists.


For reference, this is how https://github.com/andyscott/rules_scala_annex works:

If the compiler worker receives a --persistent_dir=<path> startup flag, then it uses that path to stash and retrieve previous state, keyed by the rule's label. This path is resolved relative to the execution root; currently this rules_scala_annex option is not supported with worker sandboxing.

My own use:

  • There is a distributed cache
  • Devs use --worker_extra_flag=ScalaCompile=--persistent_dir=.bazel-zinc and read from a distributed cache.
  • CI does not use --persistent_dir. It reads and writes to the distributed cache.

Devs get rapid incremental builds. CI gets assuredly deterministic builds (plus, the "previous build" is not always clear anyway). Multiples workers on a dev machine share the same analysis store. And devs can use CI's cache because --worker_extra_flag is not part of the cache key.

Philosophically, I view stateful compilation as a worker-ish thing. The purpose of workers is to reuse expensive state from one action to the next -- typically JIT. Stateful compilation is simply additional state that the worker reuses.

@keith
Copy link
Member

keith commented Sep 25, 2018

@pauldraper thanks for all the context here. I noticed that you're using a hidden directory inside the execution root? Is this required? It looks like in my testing it is, and if it isn't hidden bazel wipes it out between builds, is that your understanding as well?

@pauldraper
Copy link

I believe it can be any name, so long as it doesn't conflict with existing paths (packages). There wasn't a strong reason to make it hidden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Would be nice, but probably next quarter at the earliest type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants