-
Notifications
You must be signed in to change notification settings - Fork 27
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
Setup benchmarks #64
Setup benchmarks #64
Conversation
Codecov Report
@@ Coverage Diff @@
## main #64 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 136 136
Branches 32 32
=========================================
Hits 136 136 Continue to review full report at Codecov.
|
@meghanrjones - can you explain a bit more about the |
Yes, there is one file per asv run. The structure is as follows:
Where Here is an example showing how to use the undocumented asv Python library for extracting the profiling information (copied from airspeed-velocity/asv#971 (comment)), which import pstats
from asv.results import Results
results = Results.load(<file_path_to_result_json>)
profile_data_bytes = results.get_profile(<benchmark_name>)
with open(<pstats_file>, "wb") as f:
f.write(profile_data_bytes)
p = pstats.Stats(<pstats_file>)
p.print_stats() For publishing the results as a snakeviz representation, are you hoping to get a snapshot of the performance right now, use snakeviz as a CI performance monitoring tool, or something else? If it's the former, it might work just to share a notebook as a gist with the snakeviz/pyinstrument results. Edit: It would also be simple to share the json files using the method above, although these wouldn't be useful for continuous comparisons due to differences in runtime environments. |
The current setup in this PR uses the |
This PR adds basic benchmarks using ASV, as proposed by @jhamman in #42. The steps for running the benchmarks are documented in a new contributing guide. This PR does not add any CI workflows for running the benchmarks because that could be configured separately and is not needed for the more immediate goal of identifying performance bottlenecks.
As @rabernat noted in #37 (comment), this is only one component of the optimization recipe. While
asv
can report cprofile results, the results are stored in.json
files which are possible but difficult to extract. Instead, it is generally easier to copy the benchmark and interpret separately using analyzers like snakeviz or pyinstrument. Here are couple notes from that approach:concat_input_dims
isFalse
, callingds.stack
on each batch is the slowest part https://github.com/pangeo-data/xbatcher/blob/34ca3f9b6acaf23b09ef140b69bc7c79d4f38feb/xbatcher/generators.py#L58-L65concat_input_dims
isTrue
, modifying the coordinates in_drop_input_dims
is the slowest parthttps://github.com/pangeo-data/xbatcher/blob/34ca3f9b6acaf23b09ef140b69bc7c79d4f38feb/xbatcher/generators.py#L44-L55
In either case, the main bottleneck is that these functions are called once per batch. Especially for (1), I do not think this is needed but would like to modify the tests to explicitly check indexes before submitting a proposed refactor.
Addresses #32 and #42