Speed up operations that use the Coord.cells method for time coordinates#4969
Merged
trexfeathers merged 4 commits intoSciTools:mainfrom Sep 29, 2022
Merged
Speed up operations that use the Coord.cells method for time coordinates#4969trexfeathers merged 4 commits intoSciTools:mainfrom
Coord.cells method for time coordinates#4969trexfeathers merged 4 commits intoSciTools:mainfrom
Conversation
Member
Author
|
I ran a few more experiments, and this implementation is faster if you generate more than roughly 100 cells. |
trexfeathers
requested changes
Sep 27, 2022
Contributor
trexfeathers
left a comment
There was a problem hiding this comment.
Thanks @bouweandela, looks like you've found some useful shortcuts here ❤
The minor slowdowns for the smaller cases are IMO acceptable, since these are known times for known sizes. Meanwhile the benefits of speed-up at scale get larger as the scale increases.
- I can replicate all the timing differences you report.
- I can confirm that the worse memory efficiency of a
Generatoris of little consequence - even10000-lengthCoords produceGenerators/Iterators<100B. - Functional test coverage provides assurance that this hasn't broken anything. No direct tests for
Coord.cells()(probably should be), but both_CoordConstraint.extract()andCoord.intersect()useCoord.cells()and these have plenty of coverage. - Our rudimentary benchmark suite means further coverage that will catch unexpected slowdowns for a variety of user cases (this runs nightly on any changes to
mainfrom the previous day).
Please can you add a What's New entry? Then I will merge.
Member
Author
|
Thanks! I added a what's new entry. |
trexfeathers
approved these changes
Sep 29, 2022
Contributor
|
I've just been manually re-running some benchmarks, congratulations! |
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 Pull Request
Description
This speeds up functions that make use of the
Coord.cellsmethod to generate many cells describing a time coordinate. This affects for exampleCube.extract,Cube.subset, andCoord.intersection.Here is a script that demonstrates this:
Before:
After:
Note that the changes in this pull request do slow down the case where only a few cells are actually generated:
Before:
After:
but you can still use
Coord.cellif you need just a few cells.Closes #4957.
Consult Iris pull request check list