mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-05 00:18:07 -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
|
|
@ -24,6 +24,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -485,6 +486,24 @@ func generateGetSetters(out io.Writer, fields []ConfigField) {
|
|||
fprintf(out, "// Set%s safely sets the value for global configuration '%s' field\n", name, field.Path)
|
||||
fprintf(out, "func Set%[1]s(v %[2]s) { global.Set%[1]s(v) }\n\n", name, fieldType)
|
||||
}
|
||||
|
||||
// Separate out the config fields (from a clone!!!) to get only the 'mem-ratio' members.
|
||||
memFields := slices.DeleteFunc(slices.Clone(fields), func(field ConfigField) bool {
|
||||
return !strings.Contains(field.Path, "MemRatio")
|
||||
})
|
||||
|
||||
fprintf(out, "// GetTotalOfMemRatios safely fetches the combined value for all the state's mem ratio fields\n")
|
||||
fprintf(out, "func (st *ConfigState) GetTotalOfMemRatios() (total float64) {\n")
|
||||
fprintf(out, "\tst.mutex.RLock()\n")
|
||||
for _, field := range memFields {
|
||||
fprintf(out, "\ttotal += st.config.%s\n", field.Path)
|
||||
}
|
||||
fprintf(out, "\tst.mutex.RUnlock()\n")
|
||||
fprintf(out, "\treturn\n")
|
||||
fprintf(out, "}\n\n")
|
||||
|
||||
fprintf(out, "// GetTotalOfMemRatios safely fetches the combined value for all the global state's mem ratio fields\n")
|
||||
fprintf(out, "func GetTotalOfMemRatios() (total float64) { return global.GetTotalOfMemRatios() }\n\n")
|
||||
}
|
||||
|
||||
func generateMapFlattener(out io.Writer, fields []ConfigField) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue