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

chore(cache): default to SimpleCache in debug mode #18976

Merged
merged 15 commits into from
Mar 2, 2022

Conversation

villebro
Copy link
Member

@villebro villebro commented Mar 1, 2022

SUMMARY

Changes:

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Mar 1, 2022

Codecov Report

Merging #18976 (4a6a9e0) into master (bd63a1b) will increase coverage by 0.00%.
The diff coverage is 88.88%.

❗ Current head 4a6a9e0 differs from pull request most recent head d5f8d42. Consider uploading reports for the commit d5f8d42 to get more accurate results

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #18976   +/-   ##
=======================================
  Coverage   66.58%   66.58%           
=======================================
  Files        1641     1641           
  Lines       63533    63548   +15     
  Branches     6424     6424           
=======================================
+ Hits        42303    42315   +12     
- Misses      19551    19554    +3     
  Partials     1679     1679           
Flag Coverage Δ
hive 52.61% <88.88%> (+0.01%) ⬆️
mysql 81.83% <88.88%> (-0.01%) ⬇️
postgres 81.88% <88.88%> (-0.01%) ⬇️
presto 52.45% <88.88%> (+0.01%) ⬆️
python 82.31% <88.88%> (-0.01%) ⬇️
sqlite 81.57% <88.88%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/utils/cache_manager.py 93.75% <86.36%> (-6.25%) ⬇️
superset/config.py 91.92% <100.00%> (ø)
superset/typing.py 97.95% <100.00%> (-0.09%) ⬇️
superset/utils/cache.py 74.52% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd63a1b...d5f8d42. Read the comment docs.

@villebro villebro force-pushed the villebro/default-cache branch from bab168a to 7b1926e Compare March 1, 2022 10:34
@pull-request-size pull-request-size bot added size/L and removed size/M labels Mar 1, 2022
@villebro villebro force-pushed the villebro/default-cache branch 2 times, most recently from 62cd84f to 8b71ba1 Compare March 1, 2022 13:21
@villebro villebro changed the title [WIP] chore(cache): default to SimpleCache in debug mode chore(cache): default to SimpleCache in debug mode Mar 1, 2022
@villebro villebro mentioned this pull request Mar 1, 2022
9 tasks
Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

This is awesome. Thanks for the improvements. Left a comment.

superset/utils/cache_manager.py Outdated Show resolved Hide resolved
superset/config.py Outdated Show resolved Hide resolved
superset/config.py Outdated Show resolved Hide resolved
superset/utils/cache.py Outdated Show resolved Hide resolved
@villebro villebro force-pushed the villebro/default-cache branch from a976056 to c7b7c2e Compare March 1, 2022 21:13
superset/config.py Outdated Show resolved Hide resolved
superset/config.py Outdated Show resolved Hide resolved
@villebro villebro force-pushed the villebro/default-cache branch from c7b7c2e to 05f0c80 Compare March 2, 2022 10:55
@villebro villebro force-pushed the villebro/default-cache branch from 05f0c80 to 9c5f209 Compare March 2, 2022 11:01
@villebro villebro force-pushed the villebro/default-cache branch from 61e9a11 to 501fb98 Compare March 2, 2022 13:51
@villebro villebro force-pushed the villebro/default-cache branch from 501fb98 to d44a85d Compare March 2, 2022 13:59
@villebro villebro force-pushed the villebro/default-cache branch from d44a85d to d5f8d42 Compare March 2, 2022 15:38
if app.debug and cache_type is None:
cache_threshold = cache_config.get("CACHE_THRESHOLD", math.inf)
cache_config.update(
{"CACHE_TYPE": "SimpleCache", "CACHE_THRESHOLD": cache_threshold,}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{"CACHE_TYPE": "SimpleCache", "CACHE_THRESHOLD": cache_threshold,}
{"CACHE_TYPE": "SimpleCache", "CACHE_THRESHOLD": cache_threshold}

Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised this is not catched by black.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah this has been annoying me for a long time. I'm sure it's been fixed in a new version of black, would be nice to take a stab at updating it.

Comment on lines +67 to +71
self._init_cache(app, self._cache, "CACHE_CONFIG")
self._init_cache(app, self._data_cache, "DATA_CACHE_CONFIG")
self._init_cache(app, self._thumbnail_cache, "THUMBNAIL_CACHE_CONFIG")
self._init_cache(
app, self._filter_state_cache, "FILTER_STATE_CACHE_CONFIG", required=True
Copy link
Member

@michael-s-molina michael-s-molina Mar 2, 2022

Choose a reason for hiding this comment

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

Not required but it would be a good idea to extract these strings into constants to avoid typing errors.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea - If I need to push changes to this PR I'll add that

@@ -26,6 +26,7 @@ assists people when migrating to a new version.

### Breaking Changes

- [18976](https://github.com/apache/superset/pull/18976): When running the app in debug mode, the app will default to use `SimpleCache` for `FILTER_STATE_CACHE_CONFIG` and `EXPLORE_FORM_DATA_CACHE_CONFIG`. When running in non-debug mode, a cache backend will need to be defined, otherwise the application will fail to start. For installations using Redis or other caching backends, it is recommended to use the same backend for both cache configs.
Copy link
Member

@ktmud ktmud Mar 2, 2022

Choose a reason for hiding this comment

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

For installations using Redis or other caching backends, it is recommended to use the same backend for both cache configs.

I'm wondering if there is a real need in configuring different cache expiration for both cache storages? If not, maybe we should just merge them---into something like SEMI_PERSISTENT_CACHE_CONFIG (albeit it'd be a bigger breaking change)? I don't think it matters if we save explore state cache for 23 days more.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ktmud I think the jury is still out on a few aspects of this feature:

  • will people predominantly use direct URLs or permalinks for sharing
  • what's the sweet spot timeout for these caches
  • will we ever need multiple key-value states on a resource, or can we just collapse them into one key-value pair per resource

etc. I'm happy to keep iterating on this, and when we do a 3.0 release, I think it would be a perfect time to clean up some of the cruft we've accumulated here.

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

I really liked how this PR progressed with the suggestions. It's clean and well documented. Thanks for all the hard work @villebro 👏🏼

@villebro villebro merged commit a04f1d4 into apache:master Mar 2, 2022
@villebro villebro deleted the villebro/default-cache branch March 2, 2022 19:53
villebro added a commit that referenced this pull request Apr 3, 2022
* chore(cache): default to SimpleCache in debug mode

* lint

* clean up type

* use util

* fix integration test cache configs

* remove util from cache manager

* remove trailing comma

* fix more tests

* fix truthiness check

* fix tests and improve deprecation notice

* fix default cache threshold

* move debug check to cache_manager

* remove separate getter

* update docs

* remove default cache config

(cherry picked from commit a04f1d4)
@mistercrunch mistercrunch added 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels lts-v1 preset-io size/L 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants