Skip to content

Commit a151eb6

Browse files
committed
Merge remote-tracking branch 'origin/mc/thread-safe-groups' into mc/thread-safe-groups
2 parents 9144b65 + 6a1f73c commit a151eb6

File tree

3 files changed

+128
-77
lines changed

3 files changed

+128
-77
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings_ffi/benches/create_client.rs

+46-26
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
use crate::tracing::Instrument;
77
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
88
use tokio::runtime::{Builder, Runtime};
9-
use xmtp_common::{bench::BENCH_ROOT_SPAN, tmp_path};
9+
use xmtp_common::{
10+
bench::{bench_async_setup, BENCH_ROOT_SPAN},
11+
tmp_path,
12+
};
1013
use xmtp_id::InboxOwner;
1114
use xmtp_mls::utils::test::HISTORY_SYNC_URL;
1215
use xmtpv3::generate_inbox_id;
@@ -43,30 +46,32 @@ fn create_ffi_client(c: &mut Criterion) {
4346
let mut benchmark_group = c.benchmark_group("create_client");
4447

4548
// benchmark_group.sample_size(10);
46-
benchmark_group.sampling_mode(criterion::SamplingMode::Flat);
4749
benchmark_group.bench_function("create_ffi_client", |b| {
4850
let span = trace_span!(BENCH_ROOT_SPAN);
4951
b.to_async(&runtime).iter_batched(
5052
|| {
51-
let wallet = xmtp_cryptography::utils::generate_local_wallet();
52-
let nonce = 1;
53-
let inbox_id = generate_inbox_id(wallet.get_address(), nonce).unwrap();
54-
let path = tmp_path();
55-
let (network, is_secure) = network_url();
56-
(
57-
inbox_id,
58-
wallet.get_address(),
59-
nonce,
60-
path,
61-
network,
62-
is_secure,
63-
span.clone(),
64-
)
53+
bench_async_setup(|| async {
54+
let wallet = xmtp_cryptography::utils::generate_local_wallet();
55+
let nonce = 1;
56+
let inbox_id = generate_inbox_id(wallet.get_address(), nonce).unwrap();
57+
let path = tmp_path();
58+
let (url, is_secure) = network_url();
59+
let api = xmtpv3::mls::connect_to_backend(url, is_secure)
60+
.await
61+
.unwrap();
62+
(
63+
api,
64+
inbox_id,
65+
wallet.get_address(),
66+
nonce,
67+
path,
68+
span.clone(),
69+
)
70+
})
6571
},
66-
|(inbox_id, address, nonce, path, network, is_secure, span)| async move {
72+
|(api, inbox_id, address, nonce, path, span)| async move {
6773
xmtpv3::mls::create_client(
68-
network,
69-
is_secure,
74+
api,
7075
Some(path),
7176
Some(vec![0u8; 32]),
7277
&inbox_id,
@@ -98,29 +103,44 @@ fn cached_create_ffi_client(c: &mut Criterion) {
98103
let inbox_id = generate_inbox_id(wallet.get_address(), nonce).unwrap();
99104
let address = wallet.get_address();
100105
let path = tmp_path();
106+
let (url, is_secure) = network_url();
107+
let api = runtime.block_on(async {
108+
let api = xmtpv3::mls::connect_to_backend(url.clone(), is_secure)
109+
.await
110+
.unwrap();
111+
xmtpv3::mls::create_client(
112+
api.clone(),
113+
Some(path.clone()),
114+
Some(vec![0u8; 32]),
115+
&inbox_id.clone(),
116+
address.clone(),
117+
nonce,
118+
None,
119+
Some(HISTORY_SYNC_URL.to_string()),
120+
)
121+
.await
122+
.unwrap();
123+
api
124+
});
101125

102126
// benchmark_group.sample_size(10);
103-
benchmark_group.sampling_mode(criterion::SamplingMode::Flat);
104127
benchmark_group.bench_function("cached_create_ffi_client", |b| {
105128
let span = trace_span!(BENCH_ROOT_SPAN);
106129
b.to_async(&runtime).iter_batched(
107130
|| {
108-
let (network, is_secure) = network_url();
109131
(
132+
api.clone(),
110133
inbox_id.clone(),
111134
address.clone(),
112135
nonce,
113136
path.clone(),
114137
HISTORY_SYNC_URL.to_string(),
115-
network,
116-
is_secure,
117138
span.clone(),
118139
)
119140
},
120-
|(inbox_id, address, nonce, path, history_sync, network, is_secure, span)| async move {
141+
|(api, inbox_id, address, nonce, path, history_sync, span)| async move {
121142
xmtpv3::mls::create_client(
122-
network,
123-
is_secure,
143+
api,
124144
Some(path),
125145
Some(vec![0u8; 32]),
126146
&inbox_id,

0 commit comments

Comments
 (0)