Skip to content
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

Add in-memory cache for interpolation matrices #23

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from

Conversation

sandorkertesz
Copy link
Collaborator

@sandorkertesz sandorkertesz commented May 1, 2024

This PR adds an in-memory cache for the interpolation matrices. It can be controlled via the following methods:

  • set_memory_cache()
  • clear_memory_cache()
  • memory_cache_info()

See: https://earthkit-regrid.readthedocs.io/en/feature-mem-chache-matrix/set_memory_cache.html#memory-cache

By default the cache size is 300 MB and uses the "largest" policy.

With this cache repeated interpolations between the same input and output grids can be run much faster. The speed-up is around x10 on a MacBook using the largest interpolation matrix available at the moment:

  earthkit.regrid.interpolate(data, 
                        {"grid": "O2560"}, 
                        {"grid": [0.1,0.1]})

See:

@sandorkertesz sandorkertesz marked this pull request as draft May 1, 2024 16:02
@codecov-commenter
Copy link

codecov-commenter commented May 2, 2024

Codecov Report

Attention: Patch coverage is 93.09091% with 19 lines in your changes missing coverage. Please review.

Project coverage is 92.58%. Comparing base (1b91b2f) to head (4d63c8e).

Files with missing lines Patch % Lines
tests/test_memcache.py 94.09% 11 Missing and 5 partials ⚠️
tests/test_local.py 25.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #23      +/-   ##
===========================================
+ Coverage    92.03%   92.58%   +0.55%     
===========================================
  Files            7        8       +1     
  Lines          251      526     +275     
  Branches         7       15       +8     
===========================================
+ Hits           231      487     +256     
- Misses          18       32      +14     
- Partials         2        7       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@sandorkertesz sandorkertesz changed the title WIP: Add in-memory cache for interpolation matrices Add in-memory cache for interpolation matrices Oct 7, 2024
@sandorkertesz sandorkertesz marked this pull request as ready for review October 7, 2024 15:03
@iainrussell
Copy link
Member

This is a really great result @sandorkertesz!

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.

3 participants