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

Merged
merged 25 commits into from
Nov 27, 2024

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/develop/set_memory_cache.html#memory-cache

By default the cache size is 500 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.11594% with 19 lines in your changes missing coverage. Please review.

Project coverage is 92.59%. Comparing base (1b91b2f) to head (e4ec855).

Files with missing lines Patch % Lines
tests/test_memcache.py 94.11% 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.59%   +0.56%     
===========================================
  Files            7        8       +1     
  Lines          251      527     +276     
  Branches         7       15       +8     
===========================================
+ Hits           231      488     +257     
- Misses          18       32      +14     
- Partials         2        7       +5     

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

@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!

@sandorkertesz sandorkertesz requested a review from pmaciel October 8, 2024 15:04
@sandorkertesz sandorkertesz merged commit b4e3825 into develop Nov 27, 2024
103 checks passed
@sandorkertesz sandorkertesz deleted the feature/mem-chache-matrix branch November 27, 2024 09:54
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