Live data from Hacker News

Bazel 1.0

opensource.googleblog.com

151–160 of 204 posts

Re: Bazel 1.0

#151
post #101
post #42

Whats the advantage of using Bazel over CMake ? What does one do about package management ?

For packages, you download things by specifying an archive (zip file, git repo, etc), and a SHA256 hash. Think of it as extremely-precise version pinning. You can also refer to other Bazel projects and use their internal rules if permitted. The biggest advantages of Bazel over something like CMake are: 1) It is very general, so you can easily express dependencies of this sort: - concat three text files, then - run th…

(1) sounds like table stakes for any build system - `make` has done all that for decades

Re: Bazel 1.0

#152
post #107

Earlier quoted context omitted.

Bazel is almost a standard for build systems at this point. Did you ever use it, or at least see what a bazel build rule looks like [1] before calling it arcane? [1] https://docs.bazel.build/versions/1.0.0/tutorial/cpp.html#un...

Build rules for bazel are straightforward when you’re on the happy path & trying to do something that bazel already understands. It’s when you’re not on the happy path that things get awkward. E.g. How easy is it to integrate a new C++ compiler into bazel? (and I don’t just mean what you get by changing CC to point somewhere else. I want the full integration with the bazel build system in order to get those hermetic…

There's genrule() which basically runs a shell script. With that, you can build anything for which you can write a command-line. And you can go as far as invoke a binary that is built by another bazel rule.

You can also define your own rules in a subset of Python (by wrapping other rules including genrule()), so adding new languages should be simple enough.

Re: Bazel 1.0

#153

One of the major time savers of bazel is Remote Build Execution (RBE), which allows you to build modules in parallel in the cloud. So if you have 1000 CPUs, you can really just have a client do `bazel build -j 1000 //...` and you can get a huge speed-up. Remote (and local) builds all happen in a sandbox, so you don't have to worry about e.g. preparing a docker image with the worker / build slave environment. (You do,…

Check out recc: https://gitlab.com/bloomberg/recc

It's a remote execution client, that you can use with your current cmake project, along with buildgrid: https://gitlab.com/BuildGrid/buildgrid which is a basically a FOSS RBE.

Along with workers: https://gitlab.com/BuildGrid/buildbox/buildbox-worker

With these FOSS alternatives, you can tailor/scale your builds yourself without relying on RBE.

All of these utilize the Remote Execution protocol, so you can plug and play with other clients/workers/servers that use the protocol.

Re: Bazel 1.0

#154
post #49

Earlier quoted context omitted.

There are alternatives that satisfy this (valid, IMO) requirement. For example, there is build2 ( https://build2.org ; full disclousure: I am involved with the project) that tries to achieve the same objectives (correct & fast builds, uniform interface accross platforms, being language agnostic, etc) though not necessarily using the same mechanisms (build2, for example, tries to be fairly light-weight). Here is the i…

I checked as I was interested, but it seems that build2 doesn't do distributed builds. edit: remote->distributed

Not yet, but it's coming. And most of the really difficult infrastructure is already there, at least for the C/C++ compilation.

Re: Bazel 1.0

#155
post #135

Earlier quoted context omitted.

JVM startup for `java -version` is around 150ms on my machine: $ time java -version openjdk version "11.0.1" 2018-10-16 OpenJDK Runtime Environment 18.9 (build 11.0.1+13) OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode) real 0m0.159s user 0m0.116s sys 0m0.052s This is how long it takes for a program like git to do actual work. Once you start running an actual program like Maven, it blows up to 500ms for `m…

Java 13 takes 97ms on Windows 10, and I haven't bothered to produce a Java native image before attempting it. PS C:\Workdir> Measure-Command { java -version } openjdk version "13" 2019-09-17 OpenJDK Runtime Environment (build 13+33) OpenJDK 64-Bit Server VM (build 13+33, mixed mode, sharing) Days : 0 Hours : 0 Minutes : 0 Seconds : 0 Milliseconds : 97 Ticks : 975572 TotalDays : 1.12913425925926E-06 TotalHours : 2.709…

FWIW, I don't think "java -version" is a good benchmark of java startup time - why should it start up the JVM just to print the version?

Re: Bazel 1.0

#156
post #107

Earlier quoted context omitted.

Build rules for bazel are straightforward when you’re on the happy path & trying to do something that bazel already understands. It’s when you’re not on the happy path that things get awkward. E.g. How easy is it to integrate a new C++ compiler into bazel? (and I don’t just mean what you get by changing CC to point somewhere else. I want the full integration with the bazel build system in order to get those hermetic…

There's genrule() which basically runs a shell script. With that, you can build anything for which you can write a command-line. And you can go as far as invoke a binary that is built by another bazel rule. You can also define your own rules in a subset of Python (by wrapping other rules including genrule()), so adding new languages should be simple enough.

Based on my experience with bazel the phrase “should be simple enough” is doing an awful lot of work in that sentence ;)

It’s just a SMOP, right?

Re: Bazel 1.0

#157
> We will have a window of at least three months between major (breaking) releases

That seems... short

Re: Bazel 1.0

#158
post #151
post #101

Earlier quoted context omitted.

For packages, you download things by specifying an archive (zip file, git repo, etc), and a SHA256 hash. Think of it as extremely-precise version pinning. You can also refer to other Bazel projects and use their internal rules if permitted. The biggest advantages of Bazel over something like CMake are: 1) It is very general, so you can easily express dependencies of this sort: - concat three text files, then - run th…

(1) sounds like table stakes for any build system - `make` has done all that for decades

Well, sort of. The way make tracks changes triggers more rebuilds and the build products are much less reusable. There's a good comparison table at the bottom of section 2.4 in https://www.microsoft.com/en-us/research/uploads/prod/2018/0...

Bazel's dependency graph tends to be much more detailed than Makefiles, extends all the way to toolchains at the base, and all the way up to build products and test results.

It can also be composed together across huge file layouts in ways make doesn't support.

Re: Bazel 1.0

#159

Earlier quoted context omitted.

JVM startup is sub-second. Still not great for e.g. small command line utilities, but completely fine otherwise.

JVM startup for `java -version` is around 150ms on my machine: $ time java -version openjdk version "11.0.1" 2018-10-16 OpenJDK Runtime Environment 18.9 (build 11.0.1+13) OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode) real 0m0.159s user 0m0.116s sys 0m0.052s This is how long it takes for a program like git to do actual work. Once you start running an actual program like Maven, it blows up to 500ms for `m…

$ time ./java -version openjdk version "14-ea" 2020-03-17 OpenJDK Runtime Environment (build 14-ea+19-824) OpenJDK 64-Bit Server VM (build 14-ea+19-824, mixed mode, sharing)

real 0m0.074s user 0m0.063s sys 0m0.025s

Re: Bazel 1.0

#160

Earlier quoted context omitted.

Xoogler here who used the internal version of Bazel ( blaze ) extensively, liked it and now opted to use it for our 2 person startup ( at least for the backend ). You don't need a giant codebase to start benefitting from it. Even if you have a smaller codebase, and properly use bazel to setup tests, you only test what needs testing, and that makes a huge difference in productivity.

What languages are you using with Bazel? I have a project that uses Typescript and Python. Are you using Bazel with interpreted languages?

Bazel has experimental but pretty sophisticated support for TypeScript, with arguably a better compilation experience for large projects than the best known alternatives. (Disclaimer: I'm biased because I work on it, but I also work on non-bazel TypeScript projects so I am aware of the tradeoffs.)

https://bazelbuild.github.io/rules_nodejs/TypeScript.html

Post reply on HN