-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat(simd): use simd-json for deserialization #216
base: main
Are you sure you want to change the base?
Conversation
/// Reads a file from `path`. | ||
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.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
crates/jql/Cargo.toml
Outdated
mimalloc = "0.1.36" | ||
serde_json = { workspace = true } | ||
simd-json = "0.9.0" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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'
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. |
Based on the awesome feedback from @epage here ❤️ !