-
Notifications
You must be signed in to change notification settings - Fork 73
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
Validate: improve performance #164
Comments
Awesome! BTW, while I was revamping qsv's benchmarks last year, i found cargo-flamegraph very useful in quickly finding the hotspots to focus tuning. You may want to check it out. |
@jqnatividad I played around with Rayon instead of using threadpool, which seems unmaintained. Please let me know your thoughts. |
@mhuang74 , indeed, rayon is the current goto crate for parallelism. Last year, I was thinking of enabling parallelism on other commands but I also found threadpool support lacking. Let's go with rayon, and migrate the other commands to it over time so we can remove the threadpool dependency. |
Thanks @jqnatividad. Follow-up PR to mainly fix |
Merged! Just in time for this week's release... |
Generated flamegraph, but haven't studied in depth. Some thoughts:
https://github.com/mhuang74/qsv/blob/flamegraph/docs/flamegraph-validate-command.svg command used
|
Avoiding calling serde_json on every row should improve performance. As for profiling rayon-enabled code, it seems to be a known issue (rayon-rs/rayon#591). It's a little better with
It's still useful though as it gives you some insight as to where most of the time is spent - per the flamegraph above - about 33% of the time on jsonschema stuff, and 24% on serde::ser::SerializeMap::serialize_entry. Regardless, the
|
Thanks @jqnatividad. That indeed made a huge difference (~2.6X faster). I also simplified error output format for readability. validate feels much more production ready now. |
@mhuang74 It's blazing fast!
Yep! It's production-ready indeed. The throughput is amazing - from 9,500 records/sec on v0.32.1 pre-rayon to 280,000 records/sec after all your performance tweaking. It'd be interesting to see how it performs with regex patterns, but even then, that will be in the jsonschema engine, so I think we can close this. WDYT? |
Hi @mhuang74 , I tweaked it a little more and managed to squeeze a little more performance - #173
|
Thanks @jqnatividad . #173 looks good. Take 3-4 seconds to write the files while user reads the message. |
Closing this for now until the next round of performance tweaks. |
Validate currently runs under a single-thread and could become a bottleneck for data validation pipelines.
Concurrency should be controlled via--jobs
option orQSV_MAX_JOBS
env varConcurrency should not exceed CPU countWhen jobs is set to 0, apply same rules asstats
to calculate optimal concurrencyThe text was updated successfully, but these errors were encountered: