Skip to content

Start moving dependencies into their own Bazel externals.#1682

Merged
htuch merged 1 commit intoenvoyproxy:masterfrom
jmillikin-stripe:parallel-dependency-builds
Oct 16, 2017
Merged

Start moving dependencies into their own Bazel externals.#1682
htuch merged 1 commit intoenvoyproxy:masterfrom
jmillikin-stripe:parallel-dependency-builds

Conversation

@jmillikin-stripe
Copy link
Copy Markdown
Contributor

@jmillikin-stripe jmillikin-stripe commented Sep 16, 2017

The eventual goal here is to have each dependency in its own @thing, so
Bazel can download and build them in parallel. This should also simplify
the build, because some dependencies (protobuf, boringssl) have their own
Bazel configs.

Reason these particular four deps were chosen as a starting point:

  • fmtlib and spdlog are header-only libraries used by every
    envoy_cc_library target. Moving them out of the deps blob is trivial,
    and decouples most of the small libraries from the other huge deps.

  • protobuf has its own BUILD file, which we should use.

  • lightstep depends on protobuf, and therefore must also be moved
    out. This was relatively straightforward, by copying the existing
    "build recipe" shell script into a genrule.

I'm hopeful that we can eventually move these dependencies into
https://github.com/bazelbuild/bazel-packages when that project begins
accepting contributions.

Signed-off-by: John Millikin jmillikin@stripe.com

@jmillikin-stripe jmillikin-stripe force-pushed the parallel-dependency-builds branch 2 times, most recently from fb8a6cb to aea0338 Compare September 16, 2017 02:18
@mattklein123 mattklein123 requested a review from htuch September 16, 2017 02:49
@mattklein123
Copy link
Copy Markdown
Member

@jmillikin-stripe I'm not a huge fan of this change for all the reasons we have already discussed:

  1. We are writing BUILD files for some things that don't have BUILD files.
  2. It's not clear to me how this is going to work in the world of pre-built third party dependencies.

From my perspective, the situation we have today, though maybe "ugly", actually works quite well. My preference here would be to somehow allow both the old and new behavior with the old behavior being the default, but will defer to @htuch.

@jmillikin-stripe
Copy link
Copy Markdown
Contributor Author

jmillikin-stripe commented Sep 16, 2017

We are writing BUILD files for some things that don't have BUILD files.

The new BUILD files are equivalent to, and replace, the existing BUILD rules in ci/prebuilt/BUILD plus an existing build script from ci/build_container/build_recipes/. I'm not planning to add any non-genrule BUILD files.

For upstreams that are willing to use Bazel directly (example: gperftools/gperftools#800), I'm planning to migrate them first and then have Envoy consume their configs.

It's not clear to me how this is going to work in the world of pre-built third party dependencies.

Would you be willing to tell a bit more about how the pre-built dependencies work? I believe this work can be done in a way that involves zero changes to your existing tools, but I don't fully understand how you're replacing dependencies in the existing bind()-based system.

@mattklein123
Copy link
Copy Markdown
Member

Would you be willing to tell a bit more about how the pre-built dependencies work? I believe this work can be done in a way that involves zero changes to your existing tools, but I don't fully understand how you're replacing dependencies in the existing bind()-based system.

We essentially do exactly what CI currently does which is to pre-build all the dependencies using native build systems, and then map them in. For build speed reasons CI will need to keep doing this, and I see no reason to change our internal build system either, as it works fine.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no way to get this into a separate file, i.e. a build a recipe? It's easier to read than being inlined here, where it's a mix of Bazel macros and shell.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not with new_http_archive, but using a smarter repository definer should let us put in additional files during the "fetch" step. I'll try to get that figured out.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would caution against adding repository rules that perform build, or you might hit the issue that led to the single massive recursive make repository rule in the current implementation. Repository rules execute sequentially, so you don't get any cross dependency build parallelism. This slowed down the initial fetch significantly, e.g. from a couple of minutes to tens of minutes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of using ctx.symlink() to make a shell script available within the repository, similar to how the Skylark new_http_archive works. I definitely want to avoid doing any build actions within the repository rule implementation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that's what we do today https://github.com/envoyproxy/envoy/blob/master/bazel/repositories.bzl#L12. I'm starting to wonder how the new approach (if we're moving to repository rules for everything) is moving away from the existing approach, other than decomposing the monolith recursive make, which provide parallelism via job control, to a bunch of repository rules that will be executed sequentially with no job control.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The future repository rules should be very fast (just unpacking a tarball, maybe writing a shell blob). I want all the real build work to happen within standard BUILD rules, so they can be parallelized.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could work. I'm still a little unsure on how this will work though with output file determination, since output files may only be known following the build process (even headers might be generated), so figuring out the output artifacts is going to require a post-build step.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the reasons we opted for using a repository_rule instead of genrule. You have to manually enumerate and maintain the complete list of outputs in genrules. For simple cases it's OK, but when you have a large set of headers, which is the case in some libs, it becomes really big.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. I think it should be possible to avoid huge manual enumerations by using glob(), since it's uncommon for large numbers of output files to use arbitrary names. For example, a library that installed ~dozens of proto headers could use glob("**/*.proto") to derive the output names.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think genrules support globs on outputs FYI, at least last time I checked. Maybe this has changed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://github.com/jmillikin/bazel-packages/blob/master/libevent/libevent.bzl for an example. The glob is on input files, and used to calculate the output file names using normal Python expressions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use caps for shell vars like PROTOC, CONFIGURE here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CAPITAL_CASE variables are reserved for the OS or the shell. I'm using the Google Shell Style conventions here, which encourage lower_case names for variables defined by the user: https://google.github.io/styleguide/shell.xml#Naming_Conventions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within Envoy, I think we have a slight variation where all variables are upper case. Where there is disagreement between Google style guide and Envoy, we tend to prefer consistency (unless you want to update this everywhere). Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be fine updating this everywhere (might as well), if you're OK with the extra PRs and general commit churn.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me. @mattklein123?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is existing_rule_keys needed? Please add a comment if it's necessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It lets users override the dependencies simply by defining their own, instead of having to adjust the params of envoy_dependencies. For example, I could have a WORKSPACE that uses a custom protobuf_bzl, and then this code would use it automatically.

I'll add a comment.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems crazy to have two mechanisms for this (this and the skip_targets). I don't feel that strongly on which is better, but we should just have one, even if we need to deprecate skip_targets.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer skip_targets, since there some optional dependencies that can be skipped without overriding, e.g. lightstep.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@htuch I'd like to deprecate skip_targets once the migration is finished, because it'll be redundant and is harder to use when Envoy is built as part of a larger workspace.

@lizan If a dependency is optional, then Bazel won't try to fetch it unless it's needed to build a target the user asked for.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lizan can we get rid of skip_targets based on this? Would really prefer just one approach here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah you're right, I'm fine with that.

@htuch
Copy link
Copy Markdown
Member

htuch commented Sep 18, 2017

@jmillikin-stripe I think most of this is a reasonable step, but I'd like to check on one thing. If you do bazel clean --expunge; time build build //source/..., what is the difference before/after? It's an important part of build experience that we don't make things prohibitively slow.

One of the advantages of the recursive make implementation previously was we had a single make server providing job control of the configure/make steps, which allowed effective parallel execution of non-Bazel bits (but not parallel Bazel/non-Bazel). I'm hoping we don't have a regression here (it's possible your change makes it faster as well).

On the prebuilts and CI, one of the advantages of the build recipes, which I hope we can preserve, is that they could be executed ahead-of-time in the CI image build, independent of Bazel, as well as under the Bazel repository_rule. If we can have the genrule use the build recipes, then this could work nicely. See https://github.com/envoyproxy/envoy/blob/master/ci/build_container/build_container.sh for how this works in the Docker image build today.

I think we will still have the recursive make repository_rule going forward for when the output file list is large and folks don't want to maintain a genrule. You can find the complete history of this discussion and evolution in Envoy at bazelbuild/bazel#2792.

FWIW, I'm down with these changes as long as we don't go to a world in which Envoy relies on BUILD files that are non-canonical, i.e. we rely on random 3rd party contrib BUILD files that either we or others maintain that are not part of upstream CI for the respective projects. I don't see that scaling well for the Envoy developer flow and these random BUILD files usually don't have any test coverage. It's relatively easy to hack up a BUILD file for a project, but getting tests to run and maintaining these files is much harder.

Copy link
Copy Markdown
Member

@lizan lizan Sep 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work when the repo is consumed by other git_repository or local_repository? Make sure this works in envoy-filter-example, or istio/proxy.

We had to use build_file_content to embed them into .bzl files, just want to double check if things changed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_file takes a label, resolved relative to the current repository (bazelbuild/bazel#682). This will work when building Envoy as part of a larger workspace.

I believe older versions of Bazel (< 4.something?) used plain paths for build_file. If we need to support those versions, I can change to build_file_content. But I'd prefer not to, because it's ugly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I don't need older version support, Good to know it works now.

@jmillikin-stripe
Copy link
Copy Markdown
Contributor Author

If you do bazel clean --expunge; time build build //source/..., what is the difference before/after? It's an important part of build experience that we don't make things prohibitively slow.

Testing with command: docker run -it --volume=$PWD:/src lyft/envoy-build:latest sh -c 'cd /src && time bazel build //source/...'

On my machine, master times at real 12m59.995s, this branch times at real 12m41.509s. I suspect that difference is just noise, but at least it's not slower.

FWIW, I'm down with these changes as long as we don't go to a world in which Envoy relies on BUILD files that are non-canonical, i.e. we rely on random 3rd party contrib BUILD files

Agreed, we don't want to re-create the build systems of everything we depend on.

@jmillikin-stripe
Copy link
Copy Markdown
Contributor Author

I've made an attempt at the CI prebuilt dependency stuff. It runs bazel build within build_container.sh, using opt/dbg/fastbuild modes. This lets us avoid defining the dependency versions twice, or only within some shell blob.

@mattklein123
Copy link
Copy Markdown
Member

@jmillikin-stripe I discussed with @htuch and I'm fine with this approach if you want to see it through. (I think there will be multiple PRs needed to get CI passing but not sure).

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I actually like the approach. It has similarities with an earlier approach in our Bazel history which was largely genrule based, but does a better job at encapsulating some of the build/fetch setup behind a repository_rule.

I feel we should retain the existing repository_rule for some time, until we are comfortable that new dependencies can be added cheaply without Envoy developers becoming Bazel experts. The advantage of the previous approach is that you only had to write a single shell script and you were done.

You should also update docs at https://github.com/envoyproxy/envoy/blob/master/bazel/EXTERNAL_DEPS.md. For now, I would provide developers the option of using either new or old approach.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you even need empty.cc? I was under the impression that cc_library targets could be used to aggregate libraries without providing their own sources.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment. An empty .cc file is needed to make Bazel trigger a build. A cc_library that depends only on .a files will report "nothing to do" if you try to build it on the command line.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite neat, but also non-obvious to the reader. Can you add a comment on each of these sites where you reference GENRULE_REPOSITORY_COMMAND and explain where it is coming from?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to use a function that takes a label. This should be a bit more self-describing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment on why this is needed, i.e. that you need the protobuf library headers/libraries to feed into GENRULE_REPOSITORY_COMMAND below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please either switch back to upper case or put in a PR first to adjust the entire repository to a lower case convention for internal variables. You can always re-lower case it later if you want to delay that repository conversion PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to upper-case. I don't want to barrier this PR on some giant shell blob cleanup.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe have the extensions of these .genrule.cmd or something, so that it can't be confused with real .sh.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lizan can we get rid of skip_targets based on this? Would really prefer just one approach here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer 4 spaces here. We've been a bit inconsistent, but the idea is that this Skylark, not Python and we're trying to be consistent across BUILD files and .bzl.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also ran buildifier.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach is great, I like the idea of getting the build under genrule (for build parallelism) while still doing the setup heavy lifting under repository_rule. It doesn't solve the problem of having to explicitly enumerate output files in the genrule; so far, in this PR it's not an issue, but it's something I think we should consider as we bring in more dependencies with more complex output file lists.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with this approach, providing we maintain the bind support so that folks who really want prebuilts (e.g. that don't come from our build process), are capable of arbitrary rebinding in their WORKSPACE.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than using bind(), we should encourage users to override deps using Bazel repositories. That's why the existing_rule_keys stuff is used -- a user can define a different @protobuf_bzl repository in their own WORKSPACE.

See comments on https://docs.bazel.build/versions/master/be/workspace.html#bind and discussion on bazelbuild/bazel#1952 ("Consider removing bind()") for more background on discouraging use of bind().

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as we can support remapping of the external repos via envoy_exernal_dep_path, we're OK with this at Google. Internally, as you know, we don't have any @ repos, so we need to be able to take each of the individual repository/dependency labels and remap them to a global path in our monorepo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is envoy_exernal_dep_path? Is that the same as the path param to envoy_dependencies?

How do you currently handle the bind() names? I assume there's something set up to avoid polluting the namespace with things like //external:zlib -- do those get transparently mapped to //third_party/ somehow?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/envoyproxy/envoy/blob/master/bazel/envoy_build_system.bzl#L71. Internally, we rewrite the entire envoy_build_system.bzl to match Google's monorepo and build requirements. That function gets turned into a dictionary lookup, that maps from identifiers such as ares to something in //third_party.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that should be fine then. This PR does make a small change to envoy_external_dep_path to support non-ambiguous dep names, but that's merely a change in the identifiers. And since none of them are changing in this PR, you don't have to do anything.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the Bazel story for aliasing without bind()? Suppose I have a repository under @foo, I import @bar, and it expects @foo to exists as @baz. How do I tell Bazel to find @baz as @foo?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you looked into the size of the Docker image? We're now doing 3x the build of external deps. We briefly went from 1 -> 2 and that created almost 50% growth. Please provide stats in the review and I think @mattklein123 might want to review this for sanity.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On master the image is 2.34GB, on this branch the image is 2.17GB. Bazel is fairly good at avoiding copies of files that aren't different between compilation modes.

I'm also preparing another PR to trim the image by reducing Debian deps with apt-get --no-install-recommends, and have filed a Bazel bug to allow use of the headless JDK because we don't need X11 (bazelbuild/bazel#3761).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, reducing image size is a nice improvement.

@jmillikin-stripe jmillikin-stripe force-pushed the parallel-dependency-builds branch 2 times, most recently from 6aac661 to 6f39f17 Compare September 20, 2017 21:19
@htuch
Copy link
Copy Markdown
Member

htuch commented Sep 20, 2017 via email

@jmillikin-stripe
Copy link
Copy Markdown
Contributor Author

You should also update docs at https://github.com/envoyproxy/envoy/blob/master/bazel/EXTERNAL_DEPS.md. For now, I would provide developers the option of using either new or old approach.

Docs updated. I added two sections, one for external Bazel-based (like protobuf) and one for external non-Bazel (like lightstep).

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. A few doc requests and other comments then I think we can ship.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty complicated for the average Envoy developer who isn't a Bazel expert. A build recipe was easy to understand, it's just a shell script. Can you provide some simple explanations above imagining the developer has never heard of a genrule? Even a link to Bazel genrule stuff would help, but we don't want folks to have to become Bazel ninjas to add deps.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a few tweaks, does this help? I added a link to the genrule docs, and phrased it as a "bash command with Bazel extensions" which should hopefully be less intimidating to devs unfamiliar with Bazel.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document how developers deal with external dependencies that depend on other external deps? It was a lot more direct before (we just has essentially a global prefix path).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to document this, because it'll be different for each dep -- some use Autotools and thus need flags to ./configure, others use CMake and need ... whatever CMake does. I added a link to the Lightstep build command to use as an example.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: inconsistent indentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about repository_locations.bzl? This was explicitly added to allow site-local redirects of deps.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to have one way to override dependencies, if possible. This implementation allows deps to be overridden by adding things to WORKSPACE, which lets us avoid making local changes to the Envoy source files.

@jmillikin-stripe
Copy link
Copy Markdown
Contributor Author

Sorry for the delay, end of Q3 was busy.

There's currently some merge conflicts with other changes. Would it be OK for me to rebase this to current master, or would you prefer a merge-to-branch?

@htuch
Copy link
Copy Markdown
Member

htuch commented Oct 5, 2017

Yeah, do a full rebase, that's fine!

@jmillikin-stripe jmillikin-stripe force-pushed the parallel-dependency-builds branch from 3285858 to 4aa93d6 Compare October 6, 2017 23:46
@jmillikin-stripe jmillikin-stripe changed the title [WIP] Start moving dependencies into their own Bazel externals. Start moving dependencies into their own Bazel externals. Oct 6, 2017
@jmillikin-stripe jmillikin-stripe force-pushed the parallel-dependency-builds branch from 4aa93d6 to 9a5513e Compare October 6, 2017 23:47
@jmillikin-stripe
Copy link
Copy Markdown
Contributor Author

OK, rebased to current head. The image builds but I haven't done a full build in it yet. Will do more poking on Monday.

@htuch
Copy link
Copy Markdown
Member

htuch commented Oct 13, 2017

@jmillikin-stripe can you get the builds to pass? I think this PR is in good shape to merge, we should try to make this happen.

@kyessenov
Copy link
Copy Markdown
Contributor

/subscribe

@jmillikin-stripe jmillikin-stripe force-pushed the parallel-dependency-builds branch 3 times, most recently from d16c142 to 8f6434a Compare October 13, 2017 20:59
@jmillikin-stripe jmillikin-stripe force-pushed the parallel-dependency-builds branch 3 times, most recently from 56421e2 to 2d5e194 Compare October 14, 2017 03:54
@htuch
Copy link
Copy Markdown
Member

htuch commented Oct 16, 2017

Good catch. I'm not sure how envoy::api::v2::Bootstrap has no dependencies or why it's lazy loaded (I thought the descriptor pool was populated by static initializers), but if there's some quick workaround while the upstream issue is sorted, I think that would unblock. Hopefully we don't need to go back to the bad days of maintaining our own protobuf branch.

@mattklein123
Copy link
Copy Markdown
Member

Peanut gallery question: Why are we hitting UBSAN issues when changing the build system? Why aren't we hitting this in the current build?

@jmillikin-stripe
Copy link
Copy Markdown
Contributor Author

Peanut gallery question: Why are we hitting UBSAN issues when changing the build system? Why aren't we hitting this in the current build?

The previous build didn't enable UBSAN in any of the separately-compiled dependencies. The new build has UBSAN in protobuf (because built with Bazel) and Lightstep (because it has to link its test binaries against Bazel-built protobuf).

@mattklein123
Copy link
Copy Markdown
Member

@jmillikin-stripe got it, thanks.

@jmillikin-stripe jmillikin-stripe force-pushed the parallel-dependency-builds branch from 2d5e194 to fab290d Compare October 16, 2017 17:05
@jmillikin-stripe
Copy link
Copy Markdown
Contributor Author

Hopefully we don't need to go back to the bad days of maintaining our own protobuf branch.

I've added a patched_http_archive repository rule that lets us maintain a local patch stack against upstream archived, similar to Debian packages. This should be easier to manage than one-off Git branches.

@jmillikin-stripe jmillikin-stripe force-pushed the parallel-dependency-builds branch 3 times, most recently from a384e60 to 8a9b19b Compare October 16, 2017 19:00
The eventual goal here is to have each dependency in its own @thing, so
Bazel can download and build them in parallel. This should also simplify
the build, because some dependencies (protobuf, boringssl) have their own
Bazel configs.

Reason these particular four deps were chosen as a starting point:

* `fmtlib` and `spdlog` are header-only libraries used by every
  `envoy_cc_library` target. Moving them out of the deps blob is trivial,
  and decouples most of the small libraries from the other huge deps.

* `protobuf` has its own BUILD file, which we should use.

* `lightstep` depends on `protobuf`, and therefore must also be moved
  out. This was relatively straightforward, by copying the existing
  "build recipe" shell script into a genrule.

I'm hopeful that we can eventually move these dependencies into
https://github.com/bazelbuild/bazel-packages when that project begins
accepting contributions.

Signed-off-by: John Millikin <jmillikin@stripe.com>
@jmillikin-stripe jmillikin-stripe force-pushed the parallel-dependency-builds branch from 8a9b19b to d76f5c3 Compare October 16, 2017 19:25
@jmillikin-stripe
Copy link
Copy Markdown
Contributor Author

All tests pass with patched protobuf library. Should be safe to merge once this last CI run finishes up.

@htuch htuch merged commit 0990830 into envoyproxy:master Oct 16, 2017
@jmillikin-stripe
Copy link
Copy Markdown
Contributor Author

Thank you all for your help in getting this marathon PR merged!

@jmillikin-stripe jmillikin-stripe deleted the parallel-dependency-builds branch October 16, 2017 19:57
cd /bazel-prebuilt
for BAZEL_MODE in opt dbg fastbuild; do
bazel ${BAZEL_OPTIONS} build -c "${BAZEL_MODE}" //bazel/external:all_external
done
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmillikin-stripe we should make sure we switch the main Envoy build (and CI) to the new image that results from this change. Can you do a PR to bump https://github.com/envoyproxy/envoy/blob/master/ci/envoy_build_sha.sh? Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mailed #1867

htuch added a commit to htuch/envoy that referenced this pull request Oct 20, 2017
Part of a fix for non-root invocation of do_ci.sh for regression
introduced in envoyproxy#1682.

Signed-off-by: Harvey Tuch <htuch@google.com>
htuch added a commit that referenced this pull request Oct 20, 2017
Part of a fix for non-root invocation of do_ci.sh for regression
introduced in #1682.

Signed-off-by: Harvey Tuch <htuch@google.com>
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: JP Simard <jp@jpsim.com>
mathetake added a commit that referenced this pull request Mar 3, 2026
**Description**
This adds an additional backward compatible pass for OpenAI's prefix
field handling

**Related Issues/PRs (if applicable)**
Follow up on #1666 and #1674

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants