mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 04:02:24 -06:00
[performance] cache mute check results (#4202)
This separates our the user mute handling from the typeconverter code, and creates a new "mutes" filter type (in a similar vein to the visibility filter) subpkg with its own result cache. This is a heavy mix of both chore given that mute calculation shouldn't have been handled in the conversion to frontend API types, and a performance bonus since we don't need to load and calculate so many things each time, just the single result each time with all necessary invalidation handled by database cache hooks. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4202 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
a82d574acc
commit
faed35c938
65 changed files with 1645 additions and 766 deletions
73
internal/cache/size.go
vendored
73
internal/cache/size.go
vendored
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue