Skip to content

Commit

Permalink
chore: added http execute benchmark (#1910)
Browse files Browse the repository at this point in the history
Co-authored-by: Tushar Mathur <[email protected]>
  • Loading branch information
laststylebender14 and tusharmath authored May 19, 2024
1 parent 7f9913d commit 71e789e
Show file tree
Hide file tree
Showing 12 changed files with 398 additions and 18 deletions.
180 changes: 172 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ opentelemetry-otlp = { version = "0.15.0", features = [
"tls-roots",
], optional = true }
opentelemetry-system-metrics = { version = "0.1.8", optional = true }
tailcall-http-cache = {path = "tailcall-http-cache", optional = true }


# dependencies safe for wasm:

Expand Down Expand Up @@ -193,7 +195,8 @@ cli = [
"opentelemetry_sdk/rt-tokio",
"dep:opentelemetry-otlp",
"dep:opentelemetry-system-metrics",
"dep:tailcall-tracker"
"dep:tailcall-tracker",
"dep:tailcall-http-cache",
]

# Feature flag to enable all default features.
Expand All @@ -214,7 +217,9 @@ members = [
"tailcall-fixtures",
"tailcall-upstream-grpc",
"tailcall-tracker",
"tailcall-hasher"]
"tailcall-hasher",
"tailcall-http-cache",
]

# Boost execution_spec snapshot diffing performance
[profile.dev.package]
Expand Down
29 changes: 29 additions & 0 deletions benches/http_execute_bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use criterion::Criterion;
use hyper::Method;
use tailcall::cli::runtime::NativeHttp;
use tailcall::core::blueprint::Blueprint;
use tailcall::core::HttpIO;

pub fn benchmark_http_execute_method(c: &mut Criterion) {
let tokio_runtime = tokio::runtime::Runtime::new().unwrap();

let mut blueprint = Blueprint::default();
blueprint.upstream.http_cache = true; // allow http caching for bench test.
let native_http = NativeHttp::init(&blueprint.upstream, &blueprint.telemetry);
let request_url = String::from("http://jsonplaceholder.typicode.com/users");

tokio_runtime.block_on(async {
// cache the 1st request in order the evaluate the perf of underlying cache.
let request = reqwest::Request::new(Method::GET, request_url.parse().unwrap());
let _result = native_http.execute(request).await;
});

c.bench_function("test_http_execute_method", |b| {
b.iter(|| {
tokio_runtime.block_on(async {
let request = reqwest::Request::new(Method::GET, request_url.parse().unwrap());
let _result = native_http.execute(request).await;
})
});
});
}
Loading

1 comment on commit 71e789e

@github-actions
Copy link

Choose a reason for hiding this comment

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

Running 30s test @ http://localhost:8000/graphql

4 threads and 100 connections

Thread Stats Avg Stdev Max +/- Stdev
Latency 6.71ms 3.01ms 76.58ms 72.01%
Req/Sec 3.77k 119.38 4.11k 81.83%

450162 requests in 30.00s, 2.26GB read

Requests/sec: 15003.88

Transfer/sec: 77.01MB

Please sign in to comment.