From 7ded6000f356ae5fe4e1fd73c6a2e278affd1777 Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Mon, 24 Nov 2025 14:58:51 -0800 Subject: [PATCH] add options to control caching --- src/sentry/options/defaults.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/sentry/options/defaults.py b/src/sentry/options/defaults.py index 00b3e00d8fe80e..950e31fc7fbcbf 100644 --- a/src/sentry/options/defaults.py +++ b/src/sentry/options/defaults.py @@ -2863,6 +2863,39 @@ flags=FLAG_AUTOMATOR_MODIFIABLE, ) +# When handling grouphashes during ingest, use the cache to reduce postgres load. With secondary +# grouphashes we want to use ones which are already there but not create new ones, so we track the +# boolean result of their `.exists()` check. For all existing grouphashes, secondary or not, we know +# that if they already have a group assigned they won't be modified, so in that case we also cache +# the full `GroupHash` object. The killswitch below controls both caches, but they have separate +# expiry times because the secondary grouphash existence cache is used less frequently and has a +# lighter memory footprint, so we can afford to cache things there for longer. +# +# TODO: Check hit/miss rates for both caches and adjust the two expiry options accordingly. +register( + "grouping.use_ingest_grouphash_caching", + type=Bool, + default=True, + flags=FLAG_AUTOMATOR_MODIFIABLE, +) + +# How long to cache a boolean indicating whether or not a grouphash exists for a given secondary +# hash value +register( + "grouping.ingest_grouphash_existence_cache_expiry", + type=Int, + default=60, # seconds + flags=FLAG_AUTOMATOR_MODIFIABLE, +) + +# How long to cache actual `GroupHash` objects +register( + "grouping.ingest_grouphash_object_cache_expiry", + type=Int, + default=60, # seconds + flags=FLAG_AUTOMATOR_MODIFIABLE, +) + # Sample rate for double writing to experimental dsn register(