1
0
mirror of https://github.com/facebook/proxygen.git synced 2025-08-05 19:55:47 +03:00

20 Commits

Author SHA1 Message Date
ben--
603a3a6686 fix(fbcode_builder): fail the build when cmake build fails
Summary:
This change causes fbcode_builder (getdeps.py) to fail immediately on most non-zero error codes from delegated commands.

While internal tools may be able to surface failures in a build that doesn't fail fast, the debug cycle is difficult externally -- this makes failures pop out more easily and has been instrumental in debugging OSS build issues.

X-link: https://github.com/facebook/sapling/pull/1099

Differential Revision: D77608371

Pulled By: quark-zju

fbshipit-source-id: e9fc00a574bc64fbc165a22e51406e85d015e2ae
2025-07-03 14:28:13 -07:00
Alex Hornby
d4355c4300 add github actions caching
Summary:
X-link: https://github.com/facebook/sapling/pull/1005

Speed up github builds with github actions CI caching based on the cache-key mechanism already present in getdeps.

Cached fizz windows build completed in 22% of original time,  linux build in 54% of the original time,  and mac in 72% of original time.  This saves a lot of waiting around for PR builds on OSS changes as windows signal is usually the lagging one.  Speed ups will vary across the different Meta OSS projects.

Windows benefits most from caching dependencies as we don't use system packages there at all,  linux next as its default runner is slower than mac, and then finaly mac (the strongest hardware of the default github runners).

Github allows [up to 10GB cache per repo](https://github.blog/changelog/2021-11-23-github-actions-cache-size-is-now-increased-to-10gb-per-repository/), expiring data over capacity.  You can see the size of the caches generated in the [caches view of githhub actions UX](https://github.com/ahornby/fizz/actions/caches?query=sort%3Asize-desc),  looks like our usage is pretty small so far.

More background:
Github actions caching decides its own compression format (currently it prefers zstd), but they are free to change that in future, hence no .zstd suffix or similar on the cache keys.

Github actions caches from main are used from feature branches but not vice versa, hence a PR can't pollute cache for the trunk build.  This allows us to benefit from caching on main and PRs where dependency versions match.

The final item being built, and dependencies inside the same repo as the final are not cached.  A different mechanism would be necessary for those (e.g. using a tool like ccache/sccache or caching cargo/buck2 output).  This means that when building EdenFS, sapling could not be cached (its in the same repo), but folly could be as we have a key for it based on the folly-rev.txt file.

When there is a cache hit the build step is skipped using extension of the conditionals introduced in previous diff D67839708

Reviewed By: bigfootjon

Differential Revision: D67839730

fbshipit-source-id: c384a216eb27ccd3f816e3c31b167232bda571a6
2025-01-06 15:15:49 -08:00
Alex Hornby
18fefedec8 speed up file copy on windows
Summary:
X-link: https://github.com/facebookincubator/fizz/pull/155

X-link: https://github.com/facebookincubator/zstrong/pull/1085

getdeps windows file copy is very slow, speed it up

Reviewed By: bigfootjon

Differential Revision: D66830544

fbshipit-source-id: 43213e258c71ae706bb059600619e276e7491a90
2024-12-06 01:30:06 -08:00
Alex Hornby
5a007c0e3b getdeps: add env subcommand
Summary:
X-link: https://github.com/facebookincubator/zstrong/pull/1025

Add getdeps.py `env` subcommand to get the environment from getdeps in a sourcable form so that its easier to run/test/debug the binaries

There is an existing `debug` subcommand, but it starts an interactive shell inside getdeps, which isn't so useful for programatic use.

To get the output clean enough to source I switched getdeps print() logging to go to stderr.

example usage:
```
$ (source <(./build/fbcode_builder/getdeps.py --allow-system-packages env mononoke_integration); which mononoke)
```

Reviewed By: jdelliot

Differential Revision: D64982397

fbshipit-source-id: 65212936d42185e4d395557b56d3dba499caa128
2024-10-27 05:01:22 -07:00
Alex Hornby
088e2d0e6f allow repeat runs of cargo build
Summary:
The cargo config was being unconditionally added, resutling in "duplicate key `crates-io` in table `source`" error

check if snippet is present before writing

Reviewed By: mzr

Differential Revision: D59803494

fbshipit-source-id: 701773d604c91fd6724069b0451b212cf0018251
2024-07-16 06:20:01 -07:00
Simon Marlow
6790282a52 Refactoring
Summary:
X-link: https://github.com/facebookincubator/zstrong/pull/897

Builder refactoring: instead of providing `install_dirs` to `build()`, `test()` etc., provide `loader` and `dep_manifests` when creating the builder. This is a cleaner API because we were computing `install_dirs` in multiple places before.

Furthermore this lets us do things that need to see the manifests of the dependencies, not just the list of `install_dirs`, such as treating direct dependencies differently from indirect dependencies (see D58244928).

Reviewed By: chadaustin

Differential Revision: D58200528

fbshipit-source-id: e52d35e84161b83ab49ab43099c3e3b9bb03f36e
2024-06-26 17:02:17 -07:00
Conner Nilsen
cf2e8bc5d4 Pyre Configurationless migration for] [batch:88/244] (#723)
Summary: Pull Request resolved: https://github.com/facebookincubator/zstrong/pull/723

Reviewed By: grievejia

Differential Revision: D54471437

fbshipit-source-id: bc644553e31464ceb632034e4ce3f05ba30fbbcd
2024-03-04 18:15:44 -08:00
Amethyst Reese
6393c2daf3 apply Black 2024 style in fbcode (5/16)
Summary:
Formats the covered files with pyfmt.

paintitblack

Reviewed By: aleivag

Differential Revision: D54447730

fbshipit-source-id: 85ed104b2f8f5e26ae0dea9ee17392ecad8b9407
2024-03-02 17:31:19 -08:00
Alex Hornby
f15e30b787 getdeps: add --build-type option to build in Debug or RelWithDebInfo mode
Summary:
X-link: https://github.com/facebookincubator/zstrong/pull/653

getdeps: add --build-type option to build in Debug or RelWithDebInfo mode

Adds a --build-type option so one can force RelWithDebInfo or Debug explicity

Default remains RelWithDebInfo for cmake.

cargo default is updated to --release to match cmake more closely, if you don't want release use --build-type Debug.

If you want to run github CI in Debug mode (faster build, but tests will run slower), then can pass --build-type Debug to getdeps.py generate-github-actions

X-link: https://github.com/facebook/sapling/pull/786

Reviewed By: mitrandir77

Differential Revision: D51564770

Pulled By: bigfootjon

fbshipit-source-id: ef30332ca193d9805bce005d12b5dbc9f58fcafc
2023-12-19 12:24:39 -08:00
Alex Hornby
bb7ff7f245 fix mononoke linux local cargo build with lld
Summary:
X-link: https://github.com/facebookincubator/velox/pull/6923

fix mononoke linux local cargo build with lld

During my recent reviewstack changes I noticed that mononoke links fine on macOS, but github PRs are failing on linux with duplicate zstd symbols during linking.

To fix this, switch to lld for the final link on linux by setting the cargo options, which needs a getdeps cargo.py change to ensure they aren't overwritten

It works locally but looks like its running our of disk space on github.  Next change in stack addresses github CI diskspace

X-link: https://github.com/facebook/sapling/pull/697

Reviewed By: sggutier

Differential Revision: D49875277

Pulled By: genevievehelsel

fbshipit-source-id: 998f525fd71333b31747d0ad0e0dda3ebe2b0796
2023-10-06 21:20:06 -07:00
Christian Clauss
d3102141dc Fix typos discovered by codespell
Summary:
`codespell --ignore-words-list=arithmetics,atleast,crate,crated,deriver,ect,hel,onl,startin,whats --skip="*.lock"`
* https://pypi.org/project/codespell

X-link: https://github.com/facebookincubator/mvfst/pull/307

Reviewed By: hanidamlaj, lnicco

Differential Revision: D47809078

Pulled By: kvtsoy

fbshipit-source-id: 566557f2389746db541ff265a5dec8d6404b3701
2023-07-26 17:10:41 -07:00
Konstantin Tsoy
55f4585d07 Back out "Fix typos discovered by codespell"
Summary:
Original commit changeset: 337824bc37bc

Original Phabricator Diff: D47722462

Reviewed By: jbeshay, terrelln, lnicco

Differential Revision: D47801753

fbshipit-source-id: 795ffcccbc2223608e2a707ec2e5bcc7dd974eb3
2023-07-26 12:49:13 -07:00
Facebook Community Bot
4246f00ff1 Re-sync with internal repository (#456)
Co-authored-by: Facebook Community Bot <6422482+facebook-github-bot@users.noreply.github.com>
2023-07-25 10:04:09 -07:00
David Tolnay
8e65cb4434 Let cargo handle its own git fetches
Summary:
Context: https://fb.workplace.com/groups/rust.foundation.team/posts/1613252192522755

In D43983384 it was observed that "Build rust-shed" fails in `oss-mononoke-linux-getdeps` if you vendor a particular commit from https://github.com/jimblandy/perf-event.git. See this job on V7 of that diff: https://www.internalfb.com/intern/sandcastle/job/18014399413710280/insights

```
    Updating git repository `https://github.com/jimblandy/perf-event.git`
error: failed to load source for dependency `perf-event`

Caused by:
  Unable to update https://github.com/jimblandy/perf-event.git?rev=f15d5fa9c82a59d6134ca706b047a6baa2c24e58

Caused by:
  revspec 'f15d5fa9c82a59d6134ca706b047a6baa2c24e58' not found; class=Reference (4); code=NotFound (-3)
```

In D44095532, I confirmed that without `git-fetch-with-cli = true` in getdeps the same code succeeds the "Build rust-shed" step.
https://www.internalfb.com/intern/sandcastle/job/906715711/insights

The only difference between V7 of krallin's diff and V1 of my working diff is:

```
$ hg diff -r 14b25d1e64dbbf6d627eb8243e2c9c9146ebb75f -r 5320eb7617dc4367184508058386020c5ea52eb7
 diff --git a/fbcode/opensource/fbcode_builder/getdeps/cargo.py b/fbcode/opensource/fbcode_builder/getdeps/cargo.py
 --- a/fbcode/opensource/fbcode_builder/getdeps/cargo.py
+++ b/fbcode/opensource/fbcode_builder/getdeps/cargo.py
@@ -45,6 +45,8 @@
         # Enable using nightly features with stable compiler
         env["RUSTC_BOOTSTRAP"] = "1"
         env["LIBZ_SYS_STATIC"] = "1"
+        cmd = ["cargo", "--version"]
+        self._run_cmd(cmd, cwd=self.workspace_dir(), env=env)
         cmd = [
             "cargo",
             operation,
@@ -88,9 +90,6 @@
 [build]
 target-dir = '''{}'''

-[net]
-git-fetch-with-cli = true
-
 [profile.dev]
 debug = false
 incremental = false
```

Ultimately I guess the `git` CLI on the Sandcastle host must be ancient/problematic because I tested that Cargo is able to handle the following Cargo.toml even with `[net] get-fetch-with-cli = true` in .cargo/config.toml, with both git 2.34.1 (on my devserver) and git 2.39.2 (on my laptop).

```
[package]
name = "repro"
version = "0.0.0"

[dependencies]
perf-event = { git = "https://github.com/jimblandy/perf-event.git", rev = "f15d5fa9c82a59d6134ca706b047a6baa2c24e58", version = "0.4" }
```

I don't know why `[net] git-fetch-with-cli = true` is being used by getdeps. It showed up 3 years ago in D19193954 with no discussion.

Reviewed By: zertosh

Differential Revision: D44098634

fbshipit-source-id: 41b3fd81ed0ce71c31ed8199fed7864215f7a485
2023-03-15 12:09:12 -07:00
Chad Austin
bf8ab89efe don't try to use vendored crates in non-fbsource builds
Summary:
Watchman's vagrant images rely on mapping a watchman source directory
fetched from fbsource into the VM. Thus, they sometimes look like
fbsource, and that's largely okay. However, the vendored cargo support
breaks. Instead, explicitly skip vendored cargo when there is no
fbsource dir.

Reviewed By: xavierd

Differential Revision: D36386674

fbshipit-source-id: 61f2af19507fecd2342cfc94bbb7120ab91c33b4
2022-05-19 16:37:03 -07:00
Pyre Bot Jr
1f77084c8e Add annotations to opensource/fbcode_builder
Reviewed By: shannonzhu

Differential Revision: D34332682

fbshipit-source-id: 498c63851f98dd76502a20a9d1589df5b0c4e7b9
2022-02-17 22:55:51 -08:00
Alex Hornby
fa26d2a99b improve crate vendoring (#110)
Summary:
Pull Request resolved: https://github.com/facebookexperimental/eden/pull/110

Pull Request resolved: https://github.com/facebookexperimental/rust-shed/pull/27

Make it so that changes to rust-shed or other common rust source are used locally vendored, so they don't need to be pushed to github before they are visible in a build.

There was already some support for cargo vendoring in getdeps, but it was limited to dependencies between manifests built with cargo builder.  This wasn't enough to build something like eden (cmake is main entry point, with later calls cargo) or eden_scm (make is main entry point, with later calls to cargo), so this diff adds a cargo prepare step for getdeps other primary build systems.

The cargo vendoring is done by using a cargo config file to point to the source files used by getdeps.  It has two modes:

1. per crate, existing mode which is already automatic for cargo to cargo manifest dependencies.  To use it for a non cargo build manifest, add crate.pathmap
2. per git url, existing mode which was only use for crates.io third-party crates, now can be enabled by setting cargo.cargo_config_file

Reviewed By: yancouto

Differential Revision: D33895469

fbshipit-source-id: 7b13c0b679532492a336ce217de875c25fe1be90
2022-02-16 01:09:01 -08:00
Pyre Bot Jr
e77a9fe43a Add annotations to opensource/fbcode_builder
Reviewed By: shannonzhu

Differential Revision: D34224272

fbshipit-source-id: 52e19886ab3d4fb015a557244660dd4357a35c17
2022-02-14 16:22:09 -08:00
Chad Austin
a89428646a limit parallelism based on available RAM
Summary:
A long time ago, getdeps scheduled each build up to the number of hardware threads. For some builds, that was too heavy, so it got throttled back to only ever use half the hardware threads. This left parallelism on the table for CPU-bound projects that don't use much RAM per compilation.

This commit makes better use of the hardware with finer-grained logic that allows each manifest to specify a `job_weight_mib` estimate in MiB, and limit concurrency to `available_ram / job_weight`.

Reviewed By: ahornby

Differential Revision: D33754018

fbshipit-source-id: 785bed6c6cfe3c473244e0806a77cec1fc119e1f
2022-02-01 17:12:47 -08:00
Alex Hornby
c09d84789d move cargo logic to cargo.py
Summary:
Move cargo logic to separate file as builder.py was getting a bit large

It's just a move of source file for CargoBuilder.  Diff looks a bit big as I did hg cp to preserve history

Differential Revision: D33888925

fbshipit-source-id: 2d57343535ab087e09876edba4d00a6f0234fcd0
2022-01-31 13:52:11 -08:00