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

Use simd-json for faster parsing #80

Open
fsktom opened this issue Aug 23, 2024 · 4 comments
Open

Use simd-json for faster parsing #80

fsktom opened this issue Aug 23, 2024 · 4 comments
Assignees
Labels
dependency Waiting for a change in a dependency library Regarding `endsong` crate low prio Low priority question Further information is requested refactor

Comments

@fsktom
Copy link
Owner

fsktom commented Aug 23, 2024

https://purplesyringa.moe/blog/i-sped-up-serde-json-strings-by-20-percent/

See how well it works on ARM-based M1, WSL and Windows

@fsktom fsktom added question Further information is requested refactor library Regarding `endsong` crate labels Aug 23, 2024
@fsktom fsktom self-assigned this Aug 23, 2024
@fsktom
Copy link
Owner Author

fsktom commented Aug 23, 2024

https://lib.rs/crates/simd-json

For best performance, we highly suggest using mimalloc or jemalloc instead of the system allocator used by default. Another recent allocator that works well (but we have yet to test it in production) is snmalloc.

hmm
maybe also a custom allocator? xd
probably not

@fsktom
Copy link
Owner Author

fsktom commented Aug 25, 2024

base currently for 1 .json file

parse                   time:   [16.680 ms 16.727 ms 16.779 ms]
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high severe

for 10:

parse                   time:   [167.50 ms 169.41 ms 171.46 ms]
Found 6 outliers among 100 measurements (6.00%)
  6 (6.00%) high mild

@fsktom
Copy link
Owner Author

fsktom commented Aug 25, 2024

My first try:

parse                   time:   [20.865 ms 20.928 ms 21.001 ms]
Found 9 outliers among 100 measurements (9.00%)
  2 (2.00%) high mild
  7 (7.00%) high severe

ok something went wrong xd

let mut file_contents: Vec<u8> = vec![];
File::open(path)?.read_to_end(&mut file_contents)?;
let full_entries: Vec<Entry> = simd_json::serde::from_slice(&mut file_contents)?;

is not the way to go...

@fsktom
Copy link
Owner Author

fsktom commented Aug 26, 2024

simd-lite/simd-json#375 (comment)

ehh
I'd have to use https://github.com/simd-lite/simd-json-derive ?
but it doesn't support skip_deserializing attribute yet...?

so I guess I'll have to let it go for a while?

@fsktom fsktom added low prio Low priority dependency Waiting for a change in a dependency labels Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency Waiting for a change in a dependency library Regarding `endsong` crate low prio Low priority question Further information is requested refactor
Projects
None yet
Development

No branches or pull requests

1 participant