Skip to content

Commit

Permalink
Enable all benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
bantonsson committed Jul 9, 2024
1 parent 6f91123 commit b630e91
Show file tree
Hide file tree
Showing 37 changed files with 140 additions and 26 deletions.
3 changes: 3 additions & 0 deletions alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ features = [
[dev-dependencies]
allocator-api2 = { version = "0.2", default-features = false, features = ["alloc"] }
bolero = "0.10.1"

[lib]
bench = false
6 changes: 1 addition & 5 deletions benchmark/run_benchmarks_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ OUTPUT_DIR="${1:-}"
pushd "${PROJECT_DIR}" > /dev/null

# Run benchmarks
# TODO https://datadoghq.atlassian.net/browse/APMSP-1228
# Right now we are only running a single benchmark to test the CI setup, and there is only
# support for the Criterion SamplingMode::Flat in the new benchmarking framework. This will be
# worked on going forward.
message "Running benchmarks"
cargo bench -p datadog-trace-obfuscation --bench trace_obfuscation -- sql/obfuscate_sql_string
cargo bench --workspace -- --sample-size=200
message "Finished running benchmarks"

# Copy the benchmark results to the output directory
Expand Down
13 changes: 13 additions & 0 deletions bin_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,21 @@ serde_json = { version = "1.0" }
hyper = { version = "0.14", default-features = false }
strum = { version = "0.26.2", features = ["derive"] }

[lib]
bench = false

[[bin]]
name = "crashtracker_bin_test"
bench = false

[[bin]]
name = "test_the_tests"
bench = false

[[bin]]
name = "crashtracker_receiver"
bench = false

[[bin]]
name = "crashtracker_unix_socket_receiver"
bench = false
3 changes: 3 additions & 0 deletions build-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ cbindgen = []
cbindgen = {version = "0.26"}
serde = "1.0"
serde_json = "1.0"

[lib]
bench = false
1 change: 1 addition & 0 deletions crashtracker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ license.workspace = true

[lib]
crate-type = ["lib"]
bench = false

[target.'cfg(unix)'.dependencies]
# Should be kept in sync with the libdatadog symbolizer crate (also using blasesym)
Expand Down
1 change: 1 addition & 0 deletions data-pipeline-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ license.workspace = true

[lib]
crate-type = ["lib", "staticlib", "cdylib"]
bench = false

[features]
default = ["cbindgen"]
Expand Down
3 changes: 3 additions & 0 deletions data-pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ ddcommon = { path = "../ddcommon" }
datadog-trace-protobuf = { path = "../trace-protobuf" }
datadog-trace-utils = { path = "../trace-utils" }
datadog-trace-normalization = { path = "../trace-normalization" }

[lib]
bench = false
3 changes: 3 additions & 0 deletions ddcommon-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ version.workspace = true
rust-version.workspace = true
license.workspace = true

[lib]
bench =false

[features]
default = ["cbindgen"]
cbindgen = ["build_common/cbindgen"]
Expand Down
1 change: 1 addition & 0 deletions ddcommon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license.workspace = true

[lib]
crate-type = ["lib"]
bench =false

[dependencies]
anyhow = "1.0"
Expand Down
3 changes: 3 additions & 0 deletions ddsketch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ protoc-bin-vendored = { version = "3.0.0", optional = true }

[features]
generate-protobuf = ["dep:prost-build", "dep:protoc-bin-vendored"]

[lib]
bench = false
1 change: 1 addition & 0 deletions ddtelemetry-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license.workspace = true

[lib]
crate-type = ["lib", "staticlib", "cdylib"]
bench = false

[features]
default = ["cbindgen", "expanded_builder_macros"]
Expand Down
3 changes: 3 additions & 0 deletions ddtelemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ version.workspace = true
rust-version.workspace = true
license.workspace = true

[lib]
bench = false

[features]
default = []
tracing = ["tracing/std"]
Expand Down
3 changes: 3 additions & 0 deletions ipc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ winapi = { version = "0.3.9", features = ["handleapi", "memoryapi", "winbase", "
windows-sys = { version = "0.48.0", features = ["Win32_System", "Win32_System_WindowsProgramming", "Win32_Foundation"] }
tokio = { version = "1.23", features = ["sync", "io-util", "signal", "net"] }

[lib]
bench = false

[[bench]]
harness = false
name = "ipc"
Expand Down
21 changes: 14 additions & 7 deletions ipc/benches/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

#[cfg(not(windows))]
use criterion::{criterion_group, criterion_main, Criterion};
#[cfg(all(not(windows), not(target_arch = "aarch64")))]
use datadog_ipc::example_interface::ExampleInterfaceResponse;
#[cfg(not(windows))]
use datadog_ipc::{
example_interface::{
ExampleInterfaceRequest, ExampleInterfaceResponse, ExampleServer, ExampleTransport,
},
example_interface::{ExampleInterfaceRequest, ExampleServer, ExampleTransport},
platform::Channel,
};

#[cfg(not(windows))]
use std::{
os::unix::net::UnixStream,
Expand Down Expand Up @@ -41,17 +42,23 @@ fn criterion_benchmark(c: &mut Criterion) {
b.iter(|| transport.send(ExampleInterfaceRequest::Notify {}).unwrap())
});

// This consistently blocks on aarch64 (both MacOS and Linux), is there an issue with the
// optimized code?
#[cfg(not(target_arch = "aarch64"))]
c.bench_function("two way interface", |b| {
b.iter(|| transport.call(ExampleInterfaceRequest::ReqCnt {}).unwrap())
});

let requests_received = match transport.call(ExampleInterfaceRequest::ReqCnt {}).unwrap() {
ExampleInterfaceResponse::ReqCnt(cnt) => cnt,
// This consistently blocks on aarch64 (both MacOS and Linux), is there an issue with the
// optimized code?
#[cfg(not(target_arch = "aarch64"))]
match transport.call(ExampleInterfaceRequest::ReqCnt {}).unwrap() {
ExampleInterfaceResponse::ReqCnt(cnt) => {
println!("Total requests handled: {cnt}");
}
_ => panic!("shouldn't happen"),
};

println!("Total requests handled: {requests_received}");

drop(transport);
worker.join().unwrap();
}
Expand Down
1 change: 1 addition & 0 deletions ipc/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version = "0.0.1"

[lib]
proc-macro = true
bench = false

[dependencies]
syn = "^2"
Expand Down
1 change: 1 addition & 0 deletions ipc/tarpc/plugins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ syn = { version = "1.0", features = ["full"] }

[lib]
proc-macro = true
bench = false

[dev-dependencies]
assert-type-eq = "0.1.0"
Expand Down
3 changes: 3 additions & 0 deletions ipc/tarpc/tarpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ categories = ["asynchronous", "network-programming"]
readme = "README.md"
description = "An RPC framework for Rust with a focus on ease of use."

[lib]
bench = false

[features]
default = []

Expand Down
1 change: 1 addition & 0 deletions profiling-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ license.workspace = true
# LTO is ignored if "lib" is added as crate type
# cf. https://github.com/rust-lang/rust/issues/51009
crate-type = ["staticlib", "cdylib"]
bench = false

[features]
default = []
Expand Down
4 changes: 4 additions & 0 deletions profiling-replayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ clap = { version = "4.3.21", features = ["cargo", "color", "derive"] }
datadog-profiling = { path = "../profiling"}
prost = "0.12"
sysinfo = {version = "0.29.8", default-features = false}

[[bin]]
name = "datadog-profiling-replayer"
bench = false
2 changes: 2 additions & 0 deletions profiling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ edition.workspace = true
version.workspace = true
rust-version.workspace = true
license.workspace = true
autobenches = false

[lib]
crate-type = ["lib"]
bench = false

[[bench]]
name = "main"
Expand Down
6 changes: 5 additions & 1 deletion serverless/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ log = "0.4"
env_logger = "0.10.0"
datadog-trace-mini-agent = { path = "../trace-mini-agent" }
datadog-trace-protobuf = { path = "../trace-protobuf" }
datadog-trace-utils = { path = "../trace-utils" }
datadog-trace-utils = { path = "../trace-utils" }

[[bin]]
name = "datadog-serverless-trace-mini-agent"
bench = false
1 change: 1 addition & 0 deletions sidecar-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"

[lib]
crate-type = ["lib", "staticlib", "cdylib"]
bench = false

[dependencies]
ddtelemetry = { path = "../ddtelemetry" }
Expand Down
3 changes: 3 additions & 0 deletions sidecar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ license = "Apache 2.0"
name = "datadog-sidecar"
version = "0.0.1"

[lib]
bench = false

[features]
default = ["tracing"]
tracing = ["tracing/std", "tracing-log", "tracing-subscriber"]
Expand Down
1 change: 1 addition & 0 deletions sidecar/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version = "0.0.1"

[lib]
proc-macro = true
bench = false

[dependencies]
syn = { version = "^2", features = ["full"] }
Expand Down
3 changes: 3 additions & 0 deletions spawn_worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ edition = "2021"
name = "spawn_worker"
version = "0.0.1"

[lib]
bench = false

[dependencies]
anyhow = { version = "1.0" }
io-lifetimes = { version = "1.0" }
Expand Down
1 change: 1 addition & 0 deletions symbolizer-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ build_common = { path = "../build-common" }

[lib]
crate-type = ["lib"]
bench = false

[target.'cfg(not(target_os = "windows"))'.dependencies]
# Should be kept in sync with the libdatadog crashtracker crate (also using blasesym)
Expand Down
1 change: 1 addition & 0 deletions tests/spawn_from_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version = "0.0.1"
[lib]
# needs to by dylib for the trampoline tests to work correctly
crate-type = ["rlib", "dylib"]
bench = false

[features]
# hack to avoid compilation and testing by default
Expand Down
4 changes: 4 additions & 0 deletions tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
bench = false

[dependencies]
regex = "1"
lazy_static = "1.4"

[[bin]]
name = "dedup_headers"
bench = false
4 changes: 4 additions & 0 deletions tools/cc_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ version = "0.1.0"
[dependencies]
anyhow = {version = "1.0"}
cc = {version = "1.0"}

[lib]
bench = false

25 changes: 24 additions & 1 deletion tools/docker/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,30 @@ COPY "data-pipeline/Cargo.toml" "data-pipeline/"
COPY "data-pipeline-ffi/Cargo.toml" "data-pipeline-ffi/"
COPY "bin_tests/Cargo.toml" "bin_tests/"
RUN find -name "Cargo.toml" | sed -e s#Cargo.toml#src/lib.rs#g | xargs -n 1 sh -c 'mkdir -p $(dirname $1); touch $1; echo $1' create_stubs
RUN echo trace-normalization/benches/normalization_utils.rs profiling/benches/main.rs profiling/benches/interning_strings.rs trace-obfuscation/benches/trace_obfuscation.rs tools/src/bin/dedup_headers.rs tools/sidecar_mockgen/src/bin/sidecar_mockgen.rs ddtelemetry/examples/tm-worker-test.rs ipc/benches/ipc.rs ipc/tarpc/tarpc/examples/compression.rs ipc/tarpc/tarpc/examples/custom_transport.rs ipc/tarpc/tarpc/examples/pubsub.rs ipc/tarpc/tarpc/examples/readme.rs ipc/tarpc/tarpc/examples/tracing.rs ipc/tarpc/tarpc/tests/compile_fail.rs ipc/tarpc/tarpc/tests/dataservice.rs ipc/tarpc/tarpc/tests/service_functional.rs bin_tests/src/bin/crashtracker_bin_test.rs bin_tests/src/bin/test_the_tests.rs | xargs -n 1 sh -c 'mkdir -p $(dirname $1); touch $1; echo $1' create_stubs
RUN echo \
bin_tests/src/bin/crashtracker_bin_test.rs \
bin_tests/src/bin/crashtracker_receiver.rs \
bin_tests/src/bin/crashtracker_unix_socket_receiver.rs \
bin_tests/src/bin/test_the_tests.rs \
ddtelemetry/examples/tm-worker-test.rs \
ipc/benches/ipc.rs \
ipc/tarpc/tarpc/examples/compression.rs \
ipc/tarpc/tarpc/examples/custom_transport.rs \
ipc/tarpc/tarpc/examples/pubsub.rs \
ipc/tarpc/tarpc/examples/readme.rs \
ipc/tarpc/tarpc/examples/tracing.rs \
ipc/tarpc/tarpc/tests/compile_fail.rs \
ipc/tarpc/tarpc/tests/dataservice.rs \
ipc/tarpc/tarpc/tests/service_functional.rs \
profiling-replayer/src/main.rs \
profiling/benches/interning_strings.rs \
profiling/benches/main.rs \
serverless/src/main.rs \
tools/sidecar_mockgen/src/bin/sidecar_mockgen.rs \
tools/src/bin/dedup_headers.rs \
trace-normalization/benches/normalization_utils.rs \
trace-obfuscation/benches/trace_obfuscation.rs \
| xargs -n 1 sh -c 'mkdir -p $(dirname $1); touch $1; echo $1' create_stubs

# cache dependencies
RUN cargo fetch --locked
Expand Down
4 changes: 4 additions & 0 deletions tools/sidecar_mockgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ edition = "2021"
name = "sidecar_mockgen"
version = "0.1.0"

[lib]
bench = false

[dependencies]
object = {version = "0.31.0"}

[[bin]]
name = "sidecar_mockgen"
bench = false
4 changes: 4 additions & 0 deletions trace-mini-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name = "datadog-trace-mini-agent"
description = "A subset of the trace agent that is shipped alongside tracers in a few serverless use cases (Google Cloud Functions and Azure Functions)"
version = "0.4.2"
edition = "2021"
autobenches = false

[lib]
bench = false

[dependencies]
anyhow = "1.0"
Expand Down
3 changes: 3 additions & 0 deletions trace-normalization/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ version.workspace = true
rust-version.workspace = true
license.workspace = true

[lib]
bench = false

[dependencies]
anyhow = "1.0"
datadog-trace-protobuf = { path = "../trace-protobuf" }
Expand Down
3 changes: 3 additions & 0 deletions trace-obfuscation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ duplicate = "0.4.1"
criterion = { version = "0.5", features = [ "csv_output"] }
datadog-trace-utils = { path = "../trace-utils", features = ["test-utils"] }

[lib]
bench = false

[[bench]]
name = "trace_obfuscation"
harness = false
Loading

0 comments on commit b630e91

Please sign in to comment.