diff options
Diffstat (limited to 'internal/cache/size.go')
| -rw-r--r-- | internal/cache/size.go | 73 |
1 files changed, 13 insertions, 60 deletions
diff --git a/internal/cache/size.go b/internal/cache/size.go index 7898f9dfd..ef9259f88 100644 --- a/internal/cache/size.go +++ b/internal/cache/size.go @@ -150,7 +150,7 @@ func calculateCacheMax(keySz, valSz uintptr, ratio float64) int { // The inputted memory ratio does not take into account the // total of all ratios, so divide it here to get perc. ratio. - totalRatio := ratio / totalOfRatios() + totalRatio := ratio / config.GetTotalOfMemRatios() // TODO: we should also further weight this ratio depending // on the combined keySz + valSz as a ratio of all available @@ -172,65 +172,6 @@ func calculateCacheMax(keySz, valSz uintptr, ratio float64) int { return int(fMaxMem / (fKeySz + fValSz + emptyBucketOverhead + float64(cacheElemOverhead))) } -// totalOfRatios returns the total of all cache ratios added together. -func totalOfRatios() float64 { - - // NOTE: this is not performant calculating - // this every damn time (mainly the mutex unlocks - // required to access each config var). fortunately - // we only do this on init so fuck it :D - return 0 + - config.GetCacheAccountMemRatio() + - config.GetCacheAccountNoteMemRatio() + - config.GetCacheAccountSettingsMemRatio() + - config.GetCacheAccountStatsMemRatio() + - config.GetCacheApplicationMemRatio() + - config.GetCacheBlockMemRatio() + - config.GetCacheBlockIDsMemRatio() + - config.GetCacheBoostOfIDsMemRatio() + - config.GetCacheClientMemRatio() + - config.GetCacheEmojiMemRatio() + - config.GetCacheEmojiCategoryMemRatio() + - config.GetCacheFilterMemRatio() + - config.GetCacheFilterKeywordMemRatio() + - config.GetCacheFilterStatusMemRatio() + - config.GetCacheFollowMemRatio() + - config.GetCacheFollowIDsMemRatio() + - config.GetCacheFollowRequestMemRatio() + - config.GetCacheFollowRequestIDsMemRatio() + - config.GetCacheFollowingTagIDsMemRatio() + - config.GetCacheInReplyToIDsMemRatio() + - config.GetCacheInstanceMemRatio() + - config.GetCacheInteractionRequestMemRatio() + - config.GetCacheListMemRatio() + - config.GetCacheListIDsMemRatio() + - config.GetCacheListedIDsMemRatio() + - config.GetCacheMarkerMemRatio() + - config.GetCacheMediaMemRatio() + - config.GetCacheMentionMemRatio() + - config.GetCacheMoveMemRatio() + - config.GetCacheNotificationMemRatio() + - config.GetCachePollMemRatio() + - config.GetCachePollVoteMemRatio() + - config.GetCachePollVoteIDsMemRatio() + - config.GetCacheReportMemRatio() + - config.GetCacheSinBinStatusMemRatio() + - config.GetCacheStatusMemRatio() + - config.GetCacheStatusBookmarkMemRatio() + - config.GetCacheStatusBookmarkIDsMemRatio() + - config.GetCacheStatusFaveMemRatio() + - config.GetCacheStatusFaveIDsMemRatio() + - config.GetCacheTagMemRatio() + - config.GetCacheThreadMuteMemRatio() + - config.GetCacheTokenMemRatio() + - config.GetCacheTombstoneMemRatio() + - config.GetCacheUserMemRatio() + - config.GetCacheUserMuteMemRatio() + - config.GetCacheUserMuteIDsMemRatio() + - config.GetCacheWebfingerMemRatio() + - config.GetCacheVisibilityMemRatio() -} - func sizeofAccount() uintptr { return uintptr(size.Of(>smodel.Account{ ID: exampleID, @@ -769,6 +710,18 @@ func sizeofTombstone() uintptr { })) } +func sizeofMute() uintptr { + return uintptr(size.Of(&CachedMute{ + StatusID: exampleID, + ThreadID: exampleID, + RequesterID: exampleID, + Mute: true, + MuteExpiry: exampleTime, + Notifications: true, + NotificationExpiry: exampleTime, + })) +} + func sizeofVisibility() uintptr { return uintptr(size.Of(&CachedVisibility{ ItemID: exampleID, |
