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

Build buck//third-party/rust: up to openssl #25

Closed
wants to merge 33 commits into from
Closed

Conversation

aherrmann
Copy link
Contributor

With these fixups and changes I can build all third-party Rust deps up to openssl on Ubuntu 22.04.
Next to fixups this includes a change to the build_rs.py script and a change to the cxx toolchain.

To avoid error of the form
```
Action failed: buck//third-party/rust:typenum-1.15.0-build-script-main-srcs (genrule)
Local command returned non-zero exit code 1
Reproduce locally: `env -- "SRCS=" "ASAN_OPTIONS=detect_leaks=0,detect_odr_violation=0" "SRCDIR=./." "OUT=././../out/typ ...<omitted>... 2/gen/buck/c7e37843b7922818/third-party/rust/__typenum-1.15.0-build-script-main-srcs__/sh/genrule.sh (rerun your previous command with -v2 to view the untruncated command)`
stdout:
stderr:
Traceback (most recent call last):
  File "/home/aj/tweag.io/meta-buckv2/buck2/buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__typenum-1.15.0-build-script-main-srcs__/srcs/../../../macros/__build_rs__/build_rs.py", line 73, in <module>
    main()
  File "/home/aj/tweag.io/meta-buckv2/buck2/buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__typenum-1.15.0-build-script-main-srcs__/srcs/../../../macros/__build_rs__/build_rs.py", line 69, in main
    run_srcs(args)
  File "/home/aj/tweag.io/meta-buckv2/buck2/buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__typenum-1.15.0-build-script-main-srcs__/srcs/../../../macros/__build_rs__/build_rs.py", line 61, in run_srcs
    result = subprocess.run(args.buildscript, check=True, text=True, env=mk_env(args, False))
  File "/home/aj/tweag.io/meta-buckv2/buck2/buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__typenum-1.15.0-build-script-main-srcs__/srcs/../../../macros/__build_rs__/build_rs.py", line 40, in mk_env
    for x in args.feature:
TypeError: 'NoneType' object is not iterable
```
Resolves the error
```
error[E0425]: cannot find function `set_boxed_logger` in crate `log`
   --> third-party/rust/vendor/tracing-log-0.1.3/src/log_tracer.rs:292:14
    |
292 |         log::set_boxed_logger(logger)?;
    |              ^^^^^^^^^^^^^^^^ not found in `log`
```
caused by the `build.rs` script not running and [not
setting](https://github.com/rust-lang/log/blob/d6707108c6959ac7b60cdb60a005795ece6d82d6/build.rs#L14)
the `atomic_cas` configuration which [is
needed](https://github.com/rust-lang/log/blob/d6707108c6959ac7b60cdb60a005795ece6d82d6/src/lib.rs#L1262)
for `set_boxed_logger`.
See also [related
issue](tokio-rs/tracing#839 (comment)).
```
Action failed: buck//third-party/rust:async-condvar-fair (rustc rlib-pic-static_pic-link/async_condvar_fair-link rlib,pic,link [diag])
Local command returned non-zero exit code 1
Reproduce locally: `/usr/bin/env "PYTHONPATH=buck-out/v2/gen/ovr_config/c7e37843b7922818/rust/tools/__rustc_action__/__r ...<omitted>... /third-party/rust/__async-condvar-fair__/rlib-pic-static_pic-link/extras/libasync_condvar_fair.rlib" (rerun your previous command with -v2 to view the untruncated command)`
stdout:
stderr:
error: couldn't read buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__async-condvar-fair__/__srcs/vendor/async-condvar-fair-0.2.2/src/../README.md: No such file or directory (os error 2)
  --> third-party/rust/vendor/async-condvar-fair-0.2.2/src/lib.rs:15:10
   |
15 | #![doc = include_str!("../README.md")]
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info)
```
The files under `src/filter/env` where missing without the fixup.

```
Action failed: buck//third-party/rust:tracing-subscriber (rustc rlib-pic-static_pic-link/tracing_subscriber-link rlib,pic,link [diag])
Local command returned non-zero exit code 1
Reproduce locally: `/usr/bin/env "PYTHONPATH=buck-out/v2/gen/ovr_config/c7e37843b7922818/rust/tools/__rustc_action__/__r ...<omitted>... /third-party/rust/__tracing-subscriber__/rlib-pic-static_pic-link/extras/libtracing_subscriber.rlib" (rerun your previous command with -v2 to view the untruncated command)`
stdout:
stderr:
error[E0583]: file not found for module `env`
  --> third-party/rust/vendor/tracing-subscriber-0.3.16/src/filter/mod.rs:15:5
   |
15 |     mod env;
   |     ^^^^^^^^
   |
```
```
error[E0583]: file not found for module `unix`
  --> third-party/rust/vendor/mio-0.8.4/src/sys/mod.rs:56:5
   |
56 |     mod unix;
   |     ^^^^^^^^^
   |
```
```
stdout:
stderr:
error[E0433]: failed to resolve: could not find `sse2` in the crate root
   --> third-party/rust/vendor/blake3-0.3.8/src/platform.rs:118:24
    |
118 |                 crate::sse2::compress_in_place(cv, block, block_len, counter, flags)
    |                        ^^^^ could not find `sse2` in the crate root

```
The prelude doesn't contain arch constraints, so we can't define
constraints for the arm targets.
```
Action failed: buck//third-party/rust:tokio (rustc rlib-static-static-metadata/tokio-metadata rlib,static,metadata [diag])
Local command returned non-zero exit code 1
Reproduce locally: `/usr/bin/env "PYTHONPATH=buck-out/v2/gen/ovr_config/c7e37843b7922818/rust/tools/__rustc_action__/__r ...<omitted>... /buck/c7e37843b7922818/third-party/rust/__tokio__/rlib-static-static-metadata/extras/libtokio.rmeta" (rerun your previous command with -v2 to view the untruncated command)`
stdout:
stderr:
error[E0583]: file not found for module `select`
  --> third-party/rust/vendor/tokio-1.21.2/src/macros/mod.rs:32:5
   |
32 |     mod select;
   |     ^^^^^^^^^^^
   |
   = help: to create the module `select`, create file "buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__tokio__/__srcs/vendor/tokio-1.21.2/src/macros/select.rs" or "buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__tokio__/__srcs/vendor/tokio-1.21.2/src/macros/select/mod.rs"

```
```
Action failed: buck//third-party/rust:bstr-0.2.17 (rustc rlib-static-static-metadata/bstr-metadata rlib,static,metadata [diag])
Local command returned non-zero exit code 1
Reproduce locally: `/usr/bin/env "PYTHONPATH=buck-out/v2/gen/ovr_config/c7e37843b7922818/rust/tools/__rustc_action__/__r ...<omitted>... /c7e37843b7922818/third-party/rust/__bstr-0.2.17__/rlib-static-static-metadata/extras/libbstr.rmeta" (rerun your previous command with -v2 to view the untruncated command)`
stdout:
stderr:
error: couldn't read buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__bstr-0.2.17__/__srcs/vendor/bstr-0.2.17/src/unicode/fsm/grapheme_break_fwd.littleendian.dfa: No such file or directory (os error 2)
  --> third-party/rust/vendor/bstr-0.2.17/src/unicode/fsm/grapheme_break_fwd.rs:38:17
   |
38 |         bytes: *include_bytes!("grapheme_break_fwd.littleendian.dfa"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)
```
```
Action failed: buck//third-party/rust:lexical-core-0.7.6 (rustc rlib-static-static-metadata/lexical_core-metadata rlib,static,metadata [diag])
Local command returned non-zero exit code 1
Reproduce locally: `/usr/bin/env "PYTHONPATH=buck-out/v2/gen/ovr_config/c7e37843b7922818/rust/tools/__rustc_action__/__r ...<omitted>... 18/third-party/rust/__lexical-core-0.7.6__/rlib-static-static-metadata/extras/liblexical_core.rmeta" (rerun your previous command with -v2 to view the untruncated command)`
stdout:
stderr:
error[E0433]: failed to resolve: use of undeclared type `IntStorageType`
  --> third-party/rust/vendor/lexical-core-0.7.6/src/atof/algorithm/bignum.rs:90:41
   |
90 |         let mut bigint = Bigint { data: IntStorageType::default() };
   |                                         ^^^^^^^^^^^^^^ use of undeclared type `IntStorageType`
```
```
[2022-10-12T15:12:17.598+02:00] Stderr: error[E0583]: file not found for module `binary`
  --> third-party/rust/vendor/pest-2.4.0/src/unicode/mod.rs:18:9
   |
18 |           mod $module;
   |           ^^^^^^^^^^^^
...
25 | / char_property_functions! {
26 | |     mod binary;
27 | |     [
28 | |         // ASCII_HEX_DIGIT, // let this one be stripped out -- the full trie is wasteful for ASCII
...  |
51 | |     ];
52 | | }
   | |_- in this macro invocation
   |
   = help: to create the module `binary`, create file "buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__pest-2.4.0__/__srcs/vendor/pest-2.4.0/src/unicode/binary.rs" or "buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__pest-2.4.0__/__srcs/vendor/pest-2.4.0/src/unicode/binary/mod.rs"
   = note: this error originates in the macro `char_property_functions` (in Nightly builds, run with -Z macro-backtrace for more info)
```
```
[2022-10-12T15:15:07.480+02:00] Stderr: error: environment variable `PROTOC` not defined
    --> third-party/rust/vendor/prost-build-0.10.4/src/lib.rs:1194:31
     |
1194 |         None => PathBuf::from(env!("PROTOC")),
     |                               ^^^^^^^^^^^^^^
     |
     = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)

error: environment variable `PROTOC_INCLUDE` not defined
    --> third-party/rust/vendor/prost-build-0.10.4/src/lib.rs:1202:31
     |
1202 |         None => PathBuf::from(env!("PROTOC_INCLUDE")),
     |                               ^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
```
```
[2022-10-12T15:16:56.925+02:00] Stderr: error: environment variable `OUT_DIR` not defined
  --> third-party/rust/vendor/terminfo-0.7.3/src/names.rs:15:18
   |
15 | include!(concat!(env!("OUT_DIR"), "/names.rs"));
   |                  ^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
```
```
[2022-10-12T15:18:28.262+02:00] Stderr: error: environment variable `OUT_DIR` not defined
   --> third-party/rust/vendor/trybuild-1.0.69/src/cargo.rs:179:51
    |
179 |     const TARGET: Option<&str> = include!(concat!(env!("OUT_DIR"), "/target"));
    |                                                   ^^^^^^^^^^^^^^^
    |
    = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

```
error[E0583]: file not found for module `codec`
  --> third-party/rust/vendor/tokio-util-0.7.4/src/lib.rs:28:5
   |
28 |     pub mod codec;
   |     ^^^^^^^^^^^^^^
   |
   = help: to create the module `codec`, create file "buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__tokio-util__/__srcs/vendor/tokio-util-0.7.4/src/codec.rs" or "buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__tokio-util__/__srcs/vendor/tokio-util-0.7.4/src/codec/mod.rs"
```
error: environment variable `CARGO_PKG_VERSION_MAJOR` not defined
  --> third-party/rust/vendor/criterion-0.3.6/src/connection.rs:90:24
   |
90 |         hello_buf[i] = env!("CARGO_PKG_VERSION_MAJOR").parse().unwrap();
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
```
```
error: environment variable `CARGO_PKG_NAME` not defined
  --> third-party/rust/vendor/crossbeam-epoch-0.9.7/build.rs:25:17
   |
25 |                 env!("CARGO_PKG_NAME"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
```
```
stderr:
error: environment variable `CARGO_PKG_NAME` not defined
  --> third-party/rust/vendor/crossbeam-queue-0.3.6/build.rs:25:17
   |
25 |                 env!("CARGO_PKG_NAME"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
```
```
stderr:
error: environment variable `CARGO_PKG_NAME` not defined
  --> third-party/rust/vendor/crossbeam-utils-0.8.12/build.rs:37:17
   |
37 |                 env!("CARGO_PKG_NAME"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
```
```
stderr:
error: environment variable `CARGO_PKG_NAME` not defined
  --> third-party/rust/vendor/futures-channel-0.3.24/build.rs:25:17
   |
25 |                 env!("CARGO_PKG_NAME"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)

```
```
stderr:
error: environment variable `CARGO_PKG_NAME` not defined
  --> third-party/rust/vendor/futures-core-0.3.24/build.rs:25:17
   |
25 |                 env!("CARGO_PKG_NAME"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)

```
```
stderr:
error: environment variable `CARGO_PKG_NAME` not defined
  --> third-party/rust/vendor/futures-task-0.3.24/build.rs:25:17
   |
25 |                 env!("CARGO_PKG_NAME"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
```
```
stderr:
error: environment variable `CARGO_PKG_NAME` not defined
  --> third-party/rust/vendor/futures-util-0.3.24/build.rs:25:17
   |
25 |                 env!("CARGO_PKG_NAME"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
```
```
stderr:
error: environment variable `CARGO_PKG_VERSION` not defined
 --> third-party/rust/vendor/prettyplease-0.1.20/build.rs:2:40
  |
2 |     println!(concat!("cargo:VERSION=", env!("CARGO_PKG_VERSION")));
  |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
```
```
stderr:
error: proc-macro derive panicked
  --> third-party/rust/vendor/termwiz-0.18.0/src/tmux_cc/mod.rs:12:14
   |
12 |     #[derive(Parser)]
   |              ^^^^^^
   |
   = help: message: error opening "tmux.pest": No such file or directory (os error 2)
```
```
stderr:
error[E0583]: file not found for module `headers`
  --> third-party/rust/vendor/hyper-0.14.20/src/lib.rs:90:5
   |
90 |     mod headers;
   |     ^^^^^^^^^^^^
   |
   = help: to create the module `headers`, create file "buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__hyper-0.14.20__/__srcs/vendor/hyper-0.14.20/src/headers.rs" or "buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__hyper-0.14.20__/__srcs/vendor/hyper-0.14.20/src/headers/mod.rs"
```
```
stderr:
error[E0583]: file not found for module `broadcast`
  --> third-party/rust/vendor/tokio-stream-0.1.10/src/wrappers.rs:17:5
   |
17 |     mod broadcast;
   |     ^^^^^^^^^^^^^^
   |
   = help: to create the module `broadcast`, create file "buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__tokio-stream__/__srcs/vendor/tokio-stream-0.1.10/src/wrappers/broadcast.rs" or "buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__tokio-stream__/__srcs/vendor/tokio-stream-0.1.10/src/wrappers/broadcast/mod.rs"
```
```
stderr:
error: couldn't read buck-out/v2/gen/buck/c7e37843b7922818/third-party/rust/__axum-0.5.16__/__srcs/vendor/axum-0.5.16/src/docs/handlers_intro.md: No such file or directory (os error 2)
  --> third-party/rust/vendor/axum-0.5.16/src/lib.rs:90:10
   |
90 | #![doc = include_str!("docs/handlers_intro.md")]
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info)
```
```
stderr:
error: environment variable `CARGO_PKG_VERSION` not defined
 --> third-party/rust/vendor/tonic-0.7.2/src/transport/service/user_agent.rs:5:50
  |
5 | const TONIC_USER_AGENT: &str = concat!("tonic/", env!("CARGO_PKG_VERSION"));
  |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)

```
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 13, 2022
@facebook-github-bot
Copy link
Contributor

@ndmitchell has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@aherrmann aherrmann deleted the build-buck2 branch October 14, 2022 16:15
facebook-github-bot pushed a commit that referenced this pull request Feb 15, 2024
Summary:
The stack around D42099161 introduced the ability to dynamically set the log level via a debug-command. This requires using `tracing_subscriber::reload::Layer`. The implementation of that machinery is backed by a `RwLock` [here](https://fburl.com/code/4xv0ihpn). This `RwLock` is read locked once on every single `#[instrumentation]` call to check whether the instrumentation is active or not.

On top of that, something in our fbsource third-party config enables the `parking_lot` feature of `tracing_subscriber`. This means that this is a `parking_lot::RwLock`, not a `std::sync::RwLock`, which is bad because it's well known that parking lot has problems with excessive spinning.

What all that adds up to is that when you put `#[instrument]` on a super hot function in dice, you get dozens of threads that are all simultaneously doing this:

```
  thread #23, name = 'buck2-rt', stop reason = signal SIGSTOP
    frame #0: 0x000000000c94a1fa buck2`<parking_lot::raw_rwlock::RawRwLock>::lock_shared_slow + 122
    frame #1: 0x0000000007a80b54 buck2`<tracing_subscriber::layer::layered::Layered<tracing_subscriber::reload::Layer<tracing_subscriber::filter::layer_filters::Filtered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry, tracing_subscriber::fmt::format::DefaultFields, tracing_subscriber::fmt::format::Format, std::io::stdio::stderr>, tracing_subscriber::filter::env::EnvFilter, tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::enabled + 292
    frame #2: 0x000000000a172d77 buck2`<dice::legacy::incremental::dep_trackers::internals::Dep<dice::legacy::key::StoragePropertiesForKey<buck2_build_api::actions::calculation::BuildKey>> as dice::legacy::incremental::graph::dependencies::Dependency>::recompute::{closure#0} + 183
    frame #3: 0x000000000a03606c buck2`<futures_util::stream::futures_unordered::FuturesUnordered<core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = core::result::Result<(alloc::boxed::Box<dyn dice::legacy::incremental::graph::dependencies::ComputedDependency>, alloc::sync::Arc<dyn dice::legacy::incremental::graph::GraphNodeDyn>), dice::api::error::DiceError>> + core::marker::Send>>> as futures_util::stream::stream::StreamExt>::poll_next_unpin + 444
    frame #4: 0x0000000009fc4755 buck2`<dice::legacy::incremental::IncrementalEngine<dice::legacy::key::StoragePropertiesForKey<buck2_build_api::actions::calculation::BuildKey>>>::compute_whether_dependencies_changed::{closure#0} (.llvm.4229350879637282184) + 1733
    frame #5: 0x0000000009ef30d4 buck2`<dice::legacy::incremental::IncrementalEngine<dice::legacy::key::StoragePropertiesForKey<buck2_build_api::actions::calculation::BuildKey>>>::compute_whether_versioned_dependencies_changed::{closure#0}::{closure#0} + 228
    frame #6: 0x0000000009f194ec buck2`<buck2_futures::cancellable_future::CancellableFuture<<dice::legacy::incremental::IncrementalEngine<dice::legacy::key::StoragePropertiesForKey<buck2_build_api::actions::calculation::BuildKey>>>::new_dice_task::{closure#0}> as core::future::future::Future>::poll (.llvm.11181184606289051452) + 3500
    frame #7: 0x0000000009f04bbf buck2`<futures_util::future::future::map::Map<buck2_futures::cancellable_future::CancellableFuture<<dice::legacy::incremental::IncrementalEngine<dice::legacy::key::StoragePropertiesForKey<buck2_build_api::actions::calculation::BuildKey>>>::new_dice_task::{closure#0}>, buck2_futures::spawn::spawn_inner<<dice::legacy::incremental::IncrementalEngine<dice::legacy::key::StoragePropertiesForKey<buck2_build_api::actions::calculation::BuildKey>>>::new_dice_task::{closure#0}, dice::api::user_data::UserComputationData, futures_util::future::ready::Ready<()>>::{closure#0}> as core::future::future::Future>::poll + 31
    frame #8: 0x0000000009ff0339 buck2`<futures_util::future::future::flatten::Flatten<futures_util::future::future::Map<futures_util::future::ready::Ready<()>, buck2_futures::spawn::spawn_inner<<dice::legacy::incremental::IncrementalEngine<dice::legacy::key::StoragePropertiesForKey<buck2_build_api::actions::calculation::BuildKey>>>::new_dice_task::{closure#0}, dice::api::user_data::UserComputationData, futures_util::future::ready::Ready<()>>::{closure#1}>, <futures_util::future::future::Map<futures_util::future::ready::Ready<()>, buck2_futures::spawn::spawn_inner<<dice::legacy::incremental::IncrementalEngine<dice::legacy::key::StoragePropertiesForKey<buck2_build_api::actions::calculation::BuildKey>>>::new_dice_task::{closure#0}, dice::api::user_data::UserComputationData, futures_util::future::ready::Ready<()>>::{closure#1}> as core::future::future::Future>::Output> as core::future::future::Future>::poll + 201
    frame #9: 0x00000000093f9f22 buck2`<tokio::task::task_local::TaskLocalFuture<buck2_events::dispatch::EventDispatcher, core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = alloc::boxed::Box<dyn core::any::Any + core::marker::Send>> + core::marker::Send>>> as core::future::future::Future>::poll + 130
    frame #10: 0x000000000939fdcb buck2`<tracing::instrument::Instrumented<<buck2_build_api::spawner::BuckSpawner as buck2_futures::spawner::Spawner<dice::api::user_data::UserComputationData>>::spawn::{closure#0}> as core::future::future::Future>::poll + 139
    frame #11: 0x00000000091ca5a9 buck2`<tokio::runtime::task::core::Core<tracing::instrument::Instrumented<<buck2_build_api::spawner::BuckSpawner as buck2_futures::spawner::Spawner<dice::api::user_data::UserComputationData>>::spawn::{closure#0}>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle>>>::poll + 169
    frame #12: 0x00000000091c1b22 buck2`<tokio::runtime::task::harness::Harness<tracing::instrument::Instrumented<<buck2_build_api::spawner::BuckSpawner as buck2_futures::spawner::Spawner<dice::api::user_data::UserComputationData>>::spawn::{closure#0}>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle>>>::poll + 146
    frame #13: 0x000000000c920f6f buck2`<tokio::runtime::scheduler::multi_thread::worker::Context>::run_task + 895
    frame #14: 0x000000000c91f847 buck2`<tokio::runtime::scheduler::multi_thread::worker::Context>::run + 2103
    frame #15: 0x000000000c932264 buck2`<tokio::runtime::context::scoped::Scoped<tokio::runtime::scheduler::Context>>::set::<tokio::runtime::scheduler::multi_thread::worker::run::{closure#0}::{closure#0}, ()> + 52
    frame #16: 0x000000000c932169 buck2`tokio::runtime::context::runtime::enter_runtime::<tokio::runtime::scheduler::multi_thread::worker::run::{closure#0}, ()> + 441
    frame #17: 0x000000000c91efa6 buck2`tokio::runtime::scheduler::multi_thread::worker::run + 70
    frame #18: 0x000000000c906a50 buck2`<tracing::instrument::Instrumented<tokio::runtime::blocking::task::BlockingTask<<tokio::runtime::scheduler::multi_thread::worker::Launch>::launch::{closure#0}>> as core::future::future::Future>::poll + 160
    frame #19: 0x000000000c8f8af9 buck2`<tokio::loom::std::unsafe_cell::UnsafeCell<tokio::runtime::task::core::Stage<tracing::instrument::Instrumented<tokio::runtime::blocking::task::BlockingTask<<tokio::runtime::scheduler::multi_thread::worker::Launch>::launch::{closure#0}>>>>>::with_mut::<core::task::poll::Poll<()>, <tokio::runtime::task::core::Core<tracing::instrument::Instrumented<tokio::runtime::blocking::task::BlockingTask<<tokio::runtime::scheduler::multi_thread::worker::Launch>::launch::{closure#0}>>, tokio::runtime::blocking::schedule::BlockingSchedule>>::poll::{closure#0}> + 153
    frame #20: 0x000000000c90166b buck2`<tokio::runtime::task::core::Core<tracing::instrument::Instrumented<tokio::runtime::blocking::task::BlockingTask<<tokio::runtime::scheduler::multi_thread::worker::Launch>::launch::{closure#0}>>, tokio::runtime::blocking::schedule::BlockingSchedule>>::poll + 43
    frame #21: 0x000000000c90d9b8 buck2`<tokio::runtime::task::harness::Harness<tracing::instrument::Instrumented<tokio::runtime::blocking::task::BlockingTask<<tokio::runtime::scheduler::multi_thread::worker::Launch>::launch::{closure#0}>>, tokio::runtime::blocking::schedule::BlockingSchedule>>::poll + 152
    frame #22: 0x000000000c90b848 buck2`<tokio::runtime::blocking::pool::Inner>::run + 216
    frame #23: 0x000000000c9002ab buck2`std::sys_common::backtrace::__rust_begin_short_backtrace::<<tokio::runtime::blocking::pool::Spawner>::spawn_thread::{closure#0}, ()> + 187
    frame #24: 0x000000000c90042e buck2`<<std::thread::Builder>::spawn_unchecked_<<tokio::runtime::blocking::pool::Spawner>::spawn_thread::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} + 158
    frame #25: 0x000000000757e4b5 buck2`std::sys::unix::thread::Thread::new::thread_start::h618b0b8e7bda0b2b + 37
    frame #26: 0x00007f2ba1e9abaf
```

This hit an open source user super hard over in #555 .

This diff approaches this issue by putting all the `#[instrument]`s in dice behind `#[cfg(debug_assertions)]`. This allows them to still be used in debug mode, but keeps them out of any hot paths. I do not have numbers to show that most of these matter. The only one I know matters for sure is `recompute`.

Alternatives are to either try and tailor this to the callsites we know are hot (that sounds error prone) or to revert the stack that inadvertently introduced the RwLock. Even if we did that though, it's probably still safer to keep `#[instrument]` out of super hot paths like this.

Reviewed By: stepancheg

Differential Revision: D53744041

fbshipit-source-id: 85bce9af2fec8ad1d50adc241d3b8e2bfc5cec87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants