Skip to content

feat(simd): use simd-json for deserialization#216

Open
yamafaktory wants to merge 6 commits intomainfrom
feat/simd-json
Open

feat(simd): use simd-json for deserialization#216
yamafaktory wants to merge 6 commits intomainfrom
feat/simd-json

Conversation

@yamafaktory
Copy link
Owner

  • Use simd-json for faster deserialization
  • Use mimalloc instead of the default system allocator for performance

Based on the awesome feedback from @epage here ❤️ !

@yamafaktory yamafaktory self-assigned this Apr 24, 2023
async fn read_file(path: impl AsRef<Path>) -> Result<String> {
async fn read_file(path: impl AsRef<Path>) -> Result<Vec<u8>> {
let display_path = path.as_ref().display();
let mut file = File::open(&path)

This comment was marked as resolved.

This comment was marked as resolved.

Comment on lines +19 to +21
mimalloc = "0.1.36"
serde_json = { workspace = true }
simd-json = "0.9.0"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't see it mentioned in the PR; how much did this improve performance?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the missing piece, not tested yet :)

Copy link
Owner Author

@yamafaktory yamafaktory Apr 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a small hyperfine shell script comparing the current binary from main and a release build from this branch.

There's definitely some improvement. Ideally this should be tested against a way bigger JSON file.

Benchmark 1: cat /home/yamafaktory/dev/jql/assets/github-repositories.json | jql '|>{"name","full_name"}' > /dev/null
  Time (mean ± σ):     597.2 ms ±  12.1 ms    [User: 880.7 ms, System: 165.1 ms]
  Range (min … max):   569.9 ms … 629.4 ms    100 runs
 
Benchmark 2: cat /home/yamafaktory/dev/jql/assets/github-repositories.json | /home/yamafaktory/dev/jql/target/release/jql '|>{"name","full_name"}' > /de
v/null
  Time (mean ± σ):     555.8 ms ±  13.9 ms    [User: 1001.4 ms, System: 130.3 ms]
  Range (min … max):   531.7 ms … 648.2 ms    100 runs
 
Summary
  'cat /home/yamafaktory/dev/jql/assets/github-repositories.json | /home/yamafaktory/dev/jql/target/release/jql '|>{"name","full_name"}' > /dev/null' ra
n
    1.07 ± 0.03 times faster than 'cat /home/yamafaktory/dev/jql/assets/github-repositories.json | jql '|>{"name","full_name"}' > /dev/null'

@yamafaktory
Copy link
Owner Author

For the record, this can't be used yet sadly since there's no way to preserve the order of the keys, see simd-lite/simd-json#270.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants