-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
280 additions
and
161 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
//! Different ways to create a [`crate::DbgClient`] | ||
use super::*; | ||
use crate::app::types::*; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//! Benchmarking for syncing functions | ||
use crate::tracing::Instrument; | ||
use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; | ||
use tokio::runtime::{Builder, Runtime}; | ||
use xmtp_mls::utils::bench::{bench_async_setup, BENCH_ROOT_SPAN}; | ||
use xmtp_mls::utils::bench::{clients, init_logging}; | ||
|
||
#[macro_use] | ||
extern crate tracing; | ||
|
||
fn setup() -> Runtime { | ||
Builder::new_multi_thread() | ||
.enable_time() | ||
.enable_io() | ||
.thread_name("xmtp-bencher") | ||
.build() | ||
.unwrap() | ||
} | ||
|
||
fn start_sync_worker(c: &mut Criterion) { | ||
init_logging(); | ||
|
||
let runtime = setup(); | ||
let mut benchmark_group = c.benchmark_group("start_sync_worker"); | ||
benchmark_group.sample_size(10); | ||
benchmark_group.bench_function("start_sync_worker", |b| { | ||
let span = trace_span!(BENCH_ROOT_SPAN); | ||
b.to_async(&runtime).iter_batched( | ||
|| { | ||
bench_async_setup(|| async { | ||
let client = clients::new_client(true).await; | ||
let provider = client.mls_provider().unwrap(); | ||
// set history sync URL | ||
(client, provider, span.clone()) | ||
}) | ||
}, | ||
|(client, provider, span)| async move { | ||
client | ||
.start_sync_worker(&provider) | ||
.instrument(span) | ||
.await | ||
.unwrap() | ||
}, | ||
BatchSize::SmallInput, | ||
) | ||
}); | ||
|
||
benchmark_group.finish(); | ||
} | ||
|
||
criterion_group!( | ||
name = sync; | ||
config = Criterion::default().sample_size(10); | ||
targets = start_sync_worker | ||
); | ||
criterion_main!(sync); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
use crate::utils::test::{TestClient as TestApiClient, HISTORY_SYNC_URL}; | ||
use crate::{client::Client, identity::IdentityStrategy}; | ||
use ethers::signers::LocalWallet; | ||
use xmtp_id::{ | ||
associations::{ | ||
builder::SignatureRequest, | ||
generate_inbox_id, | ||
unverified::{UnverifiedRecoverableEcdsaSignature, UnverifiedSignature}, | ||
}, | ||
InboxOwner, | ||
}; | ||
use xmtp_proto::api_client::XmtpTestClient; | ||
|
||
pub type BenchClient = Client<TestApiClient>; | ||
|
||
/// Create a new, yet-unregistered client | ||
pub async fn new_unregistered_client(history_sync: bool) -> (BenchClient, LocalWallet) { | ||
let _ = fdlimit::raise_fd_limit(); | ||
|
||
let nonce = 1; | ||
let wallet = xmtp_cryptography::utils::generate_local_wallet(); | ||
let inbox_id = generate_inbox_id(&wallet.get_address(), &nonce).unwrap(); | ||
|
||
let dev = std::env::var("DEV_GRPC"); | ||
let is_dev_network = matches!(dev, Ok(d) if d == "true" || d == "1"); | ||
|
||
let api_client = if is_dev_network { | ||
tracing::info!("Using Dev GRPC"); | ||
<TestApiClient as XmtpTestClient>::create_dev().await | ||
} else { | ||
tracing::info!("Using Local GRPC"); | ||
<TestApiClient as XmtpTestClient>::create_local().await | ||
}; | ||
|
||
let client = BenchClient::builder(IdentityStrategy::new( | ||
inbox_id, | ||
wallet.get_address(), | ||
nonce, | ||
None, | ||
)); | ||
|
||
let mut client = client.temp_store().await.api_client(api_client); | ||
if history_sync { | ||
client = client.history_sync_url(HISTORY_SYNC_URL); | ||
} | ||
let client = client.build().await.unwrap(); | ||
|
||
(client, wallet) | ||
} | ||
|
||
/// Add ECDSA Signature to a client | ||
pub async fn ecdsa_signature(client: &BenchClient, owner: impl InboxOwner) -> SignatureRequest { | ||
let mut signature_request = client.context().signature_request().unwrap(); | ||
let signature_text = signature_request.signature_text(); | ||
let unverified_signature = UnverifiedSignature::RecoverableEcdsa( | ||
UnverifiedRecoverableEcdsaSignature::new(owner.sign(&signature_text).unwrap().into()), | ||
); | ||
signature_request | ||
.add_signature(unverified_signature, client.scw_verifier()) | ||
.await | ||
.unwrap(); | ||
|
||
signature_request | ||
} | ||
|
||
/// Create a new registered client with an EOA | ||
pub async fn new_client(history_sync: bool) -> BenchClient { | ||
let (client, wallet) = new_unregistered_client(history_sync).await; | ||
let signature_request = ecdsa_signature(&client, wallet).await; | ||
client.register_identity(signature_request).await.unwrap(); | ||
client | ||
} |
Oops, something went wrong.