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

DM-48288: Do not cache collection summaries by default in queries #1138

Merged
merged 2 commits into from
Jan 13, 2025

Conversation

dhirving
Copy link
Contributor

@dhirving dhirving commented Jan 3, 2025

We now enable the collection summary cache separately from the collection record cache. In the Butler.query() context, only the collection record cache is now enabled by default. When Butler.registry.caching_context() is called, both caches are enabled (as before.)

More often than not, the query context manager is used to execute one query and then exited. The collection summary cache was often a pessimization in this case -- fetching tens of thousands of rows when only a few were needed.

Also added explicit caching context calls to a few places in the Butler internals where we are doing repeated dataset queries that will benefit from the cache.

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes
  • (if changing dimensions.yaml) make a copy of dimensions.yaml in configs/old_dimensions

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

Attention: Patch coverage is 93.15068% with 5 lines in your changes missing coverage. Please review.

Project coverage is 89.50%. Comparing base (6259bf8) to head (409b870).
Report is 3 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
python/lsst/daf/butler/_query_all_datasets.py 85.71% 1 Missing and 1 partial ⚠️
...on/lsst/daf/butler/direct_butler/_direct_butler.py 80.00% 1 Missing and 1 partial ⚠️
python/lsst/daf/butler/script/removeRuns.py 94.73% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1138   +/-   ##
=======================================
  Coverage   89.50%   89.50%           
=======================================
  Files         366      366           
  Lines       49007    49015    +8     
  Branches     5941     5941           
=======================================
+ Hits        43863    43872    +9     
+ Misses       3729     3728    -1     
  Partials     1415     1415           

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

@dhirving dhirving changed the title DM-48288: Do not enable caching context by default in queries DM-48288: Do not cache collection summaries by default in queries Jan 13, 2025
@dhirving dhirving marked this pull request as ready for review January 13, 2025 19:12
Copy link
Contributor

@andy-slac andy-slac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one comment.

self._depth -= 1
else:
raise AssertionError("Bad caching context management detected.")
return self._collection_records.enable()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be _collection_summaries?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.... yes it should.

We now enable the collection summary cache separately from the collection record cache.  In the Butler.query() context, only the collection record cache is enabled by default.

More often than not, the query context manager is used to execute one query and then exited.  The collection summary cache was often a pessimization in this case -- fetching tens of thousands of rows when only a few were needed.
Enable the caching context a few places where we do repeated dataset queries over the same collections.  This allows us to avoid repeated collection summary lookups.
@dhirving dhirving merged commit c03a7ff into main Jan 13, 2025
19 checks passed
@dhirving dhirving deleted the tickets/DM-48288 branch January 13, 2025 22:20
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.

2 participants