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

[perf] improve benchmark perf #1121

Merged
merged 19 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/bench/json_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def benchmark_no_return(data):
orjson.dumps(json_obj)


num_json_objects = 2000
num_json_objects = 100
json_length = 3000
data = [create_large_json(json_length) for _ in range(num_json_objects)]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,13 @@ fn benchmark_parallel(data: &[Value]) -> Vec<Vec<u8>> {

// into par iter
fn benchmark_into_par_iter(data: &[Value]) -> Vec<Vec<u8>> {
let start = std::time::Instant::now();
let meow = data.into_par_iter()
data.into_par_iter()
.map(|json| serde_json::to_vec(&json).expect("Failed to serialize JSON"))
.collect();
println!("into_par_iter: {:?}", start.elapsed());
meow
.collect()
}

fn json_benchmark(c: &mut Criterion) {
let num_json_objects = 2000;
let num_json_objects = 100;
let json_length = 3000;
let data: Vec<Value> = (0..num_json_objects)
.map(|_| create_large_json(json_length))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ fn bench_run_bytes_iter_custom(c: &mut Criterion) {
criterion_group! {
name = benches;
config = Criterion::default().sample_size(10);
targets = bench_run_create_iter_custom
targets = bench_run_bytes_iter_custom
}

criterion_main!(benches);
9 changes: 8 additions & 1 deletion rust/crates/langsmith_tracing_client/src/client/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl RunProcessor {

// async fn send_batch(&self, batch: Vec<QueuedRun>) -> Result<(), TracingClientError> {
// let mut form = Form::new();
// // git println!("Sending batch of {} runs", batch.len());
// // println!("Sending batch of {} runs", batch.len());
//
// for queued_run in batch {
// match queued_run {
Expand All @@ -102,6 +102,9 @@ impl RunProcessor {
// self.consume_run_update(run_update_extended, &mut form)
// .await?;
// }
// QueuedRun::RunBytes(run_event_bytes) => {
// self.consume_run_bytes(run_event_bytes, &mut form).await?;
// }
// QueuedRun::Shutdown => {
// return Err(TracingClientError::UnexpectedShutdown);
// }
Expand Down Expand Up @@ -370,6 +373,10 @@ impl RunProcessor {
}
}
}
QueuedRun::RunBytes(_) => {
// TODO: fix this
return Err(TracingClientError::UnexpectedShutdown);
}
QueuedRun::Shutdown => {
return Err(TracingClientError::UnexpectedShutdown);
}
Expand Down