From 4f2aa792b33fdd5fb4b22dec813b3668d7190522 Mon Sep 17 00:00:00 2001 From: kim Date: Tue, 1 Jul 2025 16:00:04 +0200 Subject: [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 Co-committed-by: kim --- internal/typeutils/util_test.go | 60 ----------------------------------------- 1 file changed, 60 deletions(-) (limited to 'internal/typeutils/util_test.go') diff --git a/internal/typeutils/util_test.go b/internal/typeutils/util_test.go index 42a86372f..7ebecd232 100644 --- a/internal/typeutils/util_test.go +++ b/internal/typeutils/util_test.go @@ -23,7 +23,6 @@ import ( "code.superseriousbusiness.org/gotosocial/internal/config" "code.superseriousbusiness.org/gotosocial/internal/gtsmodel" "code.superseriousbusiness.org/gotosocial/internal/language" - "github.com/stretchr/testify/assert" ) func TestMisskeyReportContentURLs1(t *testing.T) { @@ -157,62 +156,3 @@ func TestContentToContentLanguage(t *testing.T) { } } } - -func TestFilterableText(t *testing.T) { - type testcase struct { - status *gtsmodel.Status - expectedFields []string - } - - for _, testcase := range []testcase{ - { - status: >smodel.Status{ - ContentWarning: "This is a test status", - Content: `

Import / export of account data via CSV files will be coming in 0.17.0 :) No more having to run scripts + CLI tools to import a list of accounts you follow, after doing a migration to a #GoToSocial instance.

`, - }, - expectedFields: []string{ - "This is a test status", - "Import / export of account data via CSV files will be coming in 0.17.0 :) No more having to run scripts + CLI tools to import a list of accounts you follow, after doing a migration to a #GoToSocial instance.", - }, - }, - { - status: >smodel.Status{ - Content: `

@zlatko currently we used modernc/sqlite3 for our sqlite driver, but we've been experimenting with wasm sqlite, and will likely move to that permanently in future; in the meantime, both options are available (the latter with a build tag)

https://codeberg.org/superseriousbusiness/gotosocial/pulls/2863

`, - }, - expectedFields: []string{ - "@zlatko currently we used modernc/sqlite3 for our sqlite driver, but we've been experimenting with wasm sqlite, and will likely move to that permanently in future; in the meantime, both options are available (the latter with a build tag)\n\nhttps://codeberg.org/superseriousbusiness/gotosocial/pulls/2863 ", - }, - }, - { - status: >smodel.Status{ - ContentWarning: "Nerd stuff", - Content: `

Latest graphs for #GoToSocial on Wasm sqlite3 with embedded Wasm ffmpeg, both running on Wazero, and configured with a 50MiB db cache target. This is the version we'll be releasing soonish, now we're happy with how we've tamed everything.

`, - Attachments: []*gtsmodel.MediaAttachment{ - { - Description: `Graph showing GtS using between 150-300 MiB of memory, steadily, over a few days.`, - }, - { - Description: `Another media attachment`, - }, - }, - Poll: >smodel.Poll{ - Options: []string{ - "Poll option 1", - "Poll option 2", - }, - }, - }, - expectedFields: []string{ - "Nerd stuff", - "Latest graphs for #GoToSocial on Wasm sqlite3 with embedded Wasm ffmpeg , both running on Wazero , and configured with a 50MiB db cache target . This is the version we'll be releasing soonish, now we're happy with how we've tamed everything.", - "Graph showing GtS using between 150-300 MiB of memory, steadily, over a few days.", - "Another media attachment", - "Poll option 1", - "Poll option 2", - }, - }, - } { - fields := filterableFields(testcase.status) - assert.Equal(t, testcase.expectedFields, fields) - } -} -- cgit v1.2.3