angular/angular-bazel-example

How to enable remote execution with language servers for `TypeScriptCompile` and `AngularTemplateCompile` actions

qzmfranklin opened this issue · 3 comments

I am trying to make use RBE on our project.

I followed the instructions in bazel-buildfarm and got it working. Java, C/C++, and genrule targets are now using remote instead of linux-sandbox or cached. Nice.

I noticed that TypeScriptCompile and AngularTemplateCompile actions are still using workers to enable language servers:

build --strategy=TypeScriptCompile=worker
build --strategy=AngularTemplateCompile=worker

I changed it to

build --strategy=TypeScriptCompile=remote
build --strategy=AngularTemplateCompile=remote

and get it to work using remotes. But it got significantly slower as it cannot use language servers on the remote executors.

Is there a way to enable language servers on remote executors?

This is a great question, I have struggled with it also. The right tuning depends on the incrementality of the build - if only a small number of ts_library actions need to run, it's generally faster to do this locally because you have warm workers. But if you have a massive cache miss, and also a wide enough graph of ts_library, then there may be some of them which are queued for local worker pool so it would be faster to go remote.

Bazel has an experimental strategy to race local and remote and take the faster one, but this doesn't also allow workers to be used.

Remote compilations are over a big farm, and don't have affinity for the same worker over multiple requests, so it wouldn't make much sense to have a remote worker - it would always have a cold cache. (The time to bring up a tsc process, parse typescript.js, and JIT it is probably lower than the variable cost of compiling your sources)

/cc @gpounder

Thanks @alexeagle for the explanation!

Agree on your comment that remote workers don't make much sense due to lack of affinities. I did not think of that earlier.

The race strategy sounds interesting. I'd certainly like to give it a shot if it comes out.

The race strategy is --experimental_spawn_strategy so you can give it a try, but the RBE team says it has some bugs so beware!