Skip to content

Performance between 'Values API' and 'Serde Compatible API'. #370

@ZhaiMo15

Description

@ZhaiMo15

I noticed that simd-json offers two main entry points for usage: 'Values API' and 'Serde Compatible API'.
I ran benches/parse.rs to test the performance. I added code below to test simd_json::serde::from_slice:

fn simd_from_slice(data: &mut [u8]) {
    let _: serde_json::Value = simd_json::serde::from_slice(data).unwrap();
}

group.bench_with_input("simd_json::serde::from_slice", &vec, |b, data| {
    b.iter_batched(
        || data.clone(),
        |mut bytes| simd_from_slice(&mut bytes),
        BatchSize::SmallInput,
    )
});

Here's the result:

Throughput(MiB/s) simd_json:: to_borrowed_value simd_json:: to_borrowed_value_with_buffers simd_json:: to_owned_value simd_json:: serde::from_slice serde_json:: from_slice
apache_builds 378.61 323.86 170.99 164.81 140.08
event_stacktrace_10kb 983.51 1070.9 762.83 709.25 501.10
github_events 455.06 442.80 226.45 178.68 141.91
canada 142.38 164.17 146.48 114.10 152.69
citm_catalog 312.69 340.59 234.10 237.55 225.40
log 403.55 467.40 196.92 155.88 119.01
twitter 367.24 372.41 207.64 156.72 120.17

The 'Values API' is mostly better than serde except canada(146.48 vs 152.69). However, the performance of 'Serde Compatible API' seems not that good, the result of canada cannot be acceptable(114.10 vs 152.69). I'd like to use simdjson to increase the performance, so it's better to use 'Values API'? And if my data is similar to canada, it's better not to use simdjson?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions