summaryrefslogtreecommitdiff
path: root/internal/config/helpers.gen.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-07-01 16:00:04 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-07-01 16:00:04 +0200
commit4f2aa792b33fdd5fb4b22dec813b3668d7190522 (patch)
tree1148a9322d04bf43c1c159df3079fb1790c5c154 /internal/config/helpers.gen.go
parent[chore] update go dependencies (#4304) (diff)
downloadgotosocial-4f2aa792b33fdd5fb4b22dec813b3668d7190522.tar.xz
[performance] add statusfilter cache to cache calculated status filtering results (#4303)
this adds another 'filter' type cache, similar to the visibility and mute caches, to cache the results of status filtering checks. for the moment this keeps all the check calls themselves within the frontend typeconversion code, but i may move this out of the typeconverter in a future PR (also removing the ErrHideStatus means of propagating a hidden status). also tweaks some of the cache invalidation hooks to not make unnecessary calls. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4303 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/config/helpers.gen.go')
-rw-r--r--internal/config/helpers.gen.go47
1 files changed, 46 insertions, 1 deletions
diff --git a/internal/config/helpers.gen.go b/internal/config/helpers.gen.go
index 7dfe1db23..36dd927f8 100644
--- a/internal/config/helpers.gen.go
+++ b/internal/config/helpers.gen.go
@@ -211,6 +211,7 @@ const (
CacheWebPushSubscriptionMemRatioFlag = "cache-web-push-subscription-mem-ratio"
CacheWebPushSubscriptionIDsMemRatioFlag = "cache-web-push-subscription-ids-mem-ratio"
CacheMutesMemRatioFlag = "cache-mutes-mem-ratio"
+ CacheStatusFilterMemRatioFlag = "cache-status-filter-mem-ratio"
CacheVisibilityMemRatioFlag = "cache-visibility-mem-ratio"
AdminAccountUsernameFlag = "username"
AdminAccountEmailFlag = "email"
@@ -404,11 +405,12 @@ func (cfg *Configuration) RegisterFlags(flags *pflag.FlagSet) {
flags.Float64("cache-web-push-subscription-mem-ratio", cfg.Cache.WebPushSubscriptionMemRatio, "")
flags.Float64("cache-web-push-subscription-ids-mem-ratio", cfg.Cache.WebPushSubscriptionIDsMemRatio, "")
flags.Float64("cache-mutes-mem-ratio", cfg.Cache.MutesMemRatio, "")
+ flags.Float64("cache-status-filter-mem-ratio", cfg.Cache.StatusFilterMemRatio, "")
flags.Float64("cache-visibility-mem-ratio", cfg.Cache.VisibilityMemRatio, "")
}
func (cfg *Configuration) MarshalMap() map[string]any {
- cfgmap := make(map[string]any, 190)
+ cfgmap := make(map[string]any, 191)
cfgmap["log-level"] = cfg.LogLevel
cfgmap["log-timestamp-format"] = cfg.LogTimestampFormat
cfgmap["log-db-queries"] = cfg.LogDbQueries
@@ -591,6 +593,7 @@ func (cfg *Configuration) MarshalMap() map[string]any {
cfgmap["cache-web-push-subscription-mem-ratio"] = cfg.Cache.WebPushSubscriptionMemRatio
cfgmap["cache-web-push-subscription-ids-mem-ratio"] = cfg.Cache.WebPushSubscriptionIDsMemRatio
cfgmap["cache-mutes-mem-ratio"] = cfg.Cache.MutesMemRatio
+ cfgmap["cache-status-filter-mem-ratio"] = cfg.Cache.StatusFilterMemRatio
cfgmap["cache-visibility-mem-ratio"] = cfg.Cache.VisibilityMemRatio
cfgmap["username"] = cfg.AdminAccountUsername
cfgmap["email"] = cfg.AdminAccountEmail
@@ -2098,6 +2101,14 @@ func (cfg *Configuration) UnmarshalMap(cfgmap map[string]any) error {
}
}
+ if ival, ok := cfgmap["cache-status-filter-mem-ratio"]; ok {
+ var err error
+ cfg.Cache.StatusFilterMemRatio, err = cast.ToFloat64E(ival)
+ if err != nil {
+ return fmt.Errorf("error casting %#v -> float64 for 'cache-status-filter-mem-ratio': %w", ival, err)
+ }
+ }
+
if ival, ok := cfgmap["cache-visibility-mem-ratio"]; ok {
var err error
cfg.Cache.VisibilityMemRatio, err = cast.ToFloat64E(ival)
@@ -6197,6 +6208,28 @@ func GetCacheMutesMemRatio() float64 { return global.GetCacheMutesMemRatio() }
// SetCacheMutesMemRatio safely sets the value for global configuration 'Cache.MutesMemRatio' field
func SetCacheMutesMemRatio(v float64) { global.SetCacheMutesMemRatio(v) }
+// GetCacheStatusFilterMemRatio safely fetches the Configuration value for state's 'Cache.StatusFilterMemRatio' field
+func (st *ConfigState) GetCacheStatusFilterMemRatio() (v float64) {
+ st.mutex.RLock()
+ v = st.config.Cache.StatusFilterMemRatio
+ st.mutex.RUnlock()
+ return
+}
+
+// SetCacheStatusFilterMemRatio safely sets the Configuration value for state's 'Cache.StatusFilterMemRatio' field
+func (st *ConfigState) SetCacheStatusFilterMemRatio(v float64) {
+ st.mutex.Lock()
+ defer st.mutex.Unlock()
+ st.config.Cache.StatusFilterMemRatio = v
+ st.reloadToViper()
+}
+
+// GetCacheStatusFilterMemRatio safely fetches the value for global configuration 'Cache.StatusFilterMemRatio' field
+func GetCacheStatusFilterMemRatio() float64 { return global.GetCacheStatusFilterMemRatio() }
+
+// SetCacheStatusFilterMemRatio safely sets the value for global configuration 'Cache.StatusFilterMemRatio' field
+func SetCacheStatusFilterMemRatio(v float64) { global.SetCacheStatusFilterMemRatio(v) }
+
// GetCacheVisibilityMemRatio safely fetches the Configuration value for state's 'Cache.VisibilityMemRatio' field
func (st *ConfigState) GetCacheVisibilityMemRatio() (v float64) {
st.mutex.RLock()
@@ -6433,6 +6466,7 @@ func (st *ConfigState) GetTotalOfMemRatios() (total float64) {
total += st.config.Cache.WebPushSubscriptionMemRatio
total += st.config.Cache.WebPushSubscriptionIDsMemRatio
total += st.config.Cache.MutesMemRatio
+ total += st.config.Cache.StatusFilterMemRatio
total += st.config.Cache.VisibilityMemRatio
st.mutex.RUnlock()
return
@@ -7396,6 +7430,17 @@ func flattenConfigMap(cfgmap map[string]any) {
}
for _, key := range [][]string{
+ {"cache", "status-filter-mem-ratio"},
+ } {
+ ival, ok := mapGet(cfgmap, key...)
+ if ok {
+ cfgmap["cache-status-filter-mem-ratio"] = ival
+ nestedKeys[key[0]] = struct{}{}
+ break
+ }
+ }
+
+ for _, key := range [][]string{
{"cache", "visibility-mem-ratio"},
} {
ival, ok := mapGet(cfgmap, key...)