summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-07-29 09:23:20 +0200
committerLibravatar tobi <kipvandenbos@noreply.codeberg.org>2025-07-29 09:23:20 +0200
commite3dfd8889315af38c4eef1eb4247dc07a51899c7 (patch)
tree5841d80475be7a7336ae968057f3d4ffdd2e3627 /internal
parent[chore] Only display report comment forwarding notice when reporting account ... (diff)
downloadgotosocial-e3dfd8889315af38c4eef1eb4247dc07a51899c7.tar.xz
[performance] bump codeberg.org/gruf/go-kv to v2 (#4341)
updates our codeberg.org/gruf/go-kv log key-value formatting library to latest version, which comes with some maaaaaaajor speed boosts in the form of: - very minimal reflect.Value{} usage - caching prepared formatting functions per type ~~still a work-in-progress until i make a release tag on the go-kv repository, which itself is waiting on published benchmark results in the README and finishing writing some code comments~~ benchmarks so far show this to be ~3x faster than the "fmt" stdlib package on average, when run across a wide variety (106 different types) of test cases, while still creating more visually friendly log output and actually recursing down nested struct ptrs Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4341 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal')
-rw-r--r--internal/admin/domainperms.go2
-rw-r--r--internal/api/util/errorhandling.go2
-rw-r--r--internal/cache/timeline/status_test.go5
-rw-r--r--internal/config/config_test.go2
-rw-r--r--internal/db/bundb/hook.go2
-rw-r--r--internal/federation/authenticate.go2
-rw-r--r--internal/federation/dereferencing/thread.go2
-rw-r--r--internal/federation/federatingactor.go2
-rw-r--r--internal/federation/federatingprotocol.go2
-rw-r--r--internal/gtscontext/log_hooks.go2
-rw-r--r--internal/id/ulid.go2
-rw-r--r--internal/log/entry.go2
-rw-r--r--internal/log/format.go29
-rw-r--r--internal/log/log.go2
-rw-r--r--internal/media/processingmedia.go2
-rw-r--r--internal/middleware/logger.go2
-rw-r--r--internal/observability/tracing.go2
-rw-r--r--internal/processing/account/delete.go2
-rw-r--r--internal/processing/search/accounts.go2
-rw-r--r--internal/processing/search/get.go2
-rw-r--r--internal/processing/search/lookup.go2
-rw-r--r--internal/processing/stream/open.go2
-rw-r--r--internal/processing/workers/fromclientapi.go2
-rw-r--r--internal/processing/workers/fromfediapi.go2
-rw-r--r--internal/subscriptions/domainperms.go2
25 files changed, 26 insertions, 54 deletions
diff --git a/internal/admin/domainperms.go b/internal/admin/domainperms.go
index c54c1f93e..ca2da4a15 100644
--- a/internal/admin/domainperms.go
+++ b/internal/admin/domainperms.go
@@ -22,7 +22,7 @@ import (
"errors"
"time"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
"code.superseriousbusiness.org/gotosocial/internal/ap"
"code.superseriousbusiness.org/gotosocial/internal/config"
diff --git a/internal/api/util/errorhandling.go b/internal/api/util/errorhandling.go
index 3341e7399..7ffbbbf88 100644
--- a/internal/api/util/errorhandling.go
+++ b/internal/api/util/errorhandling.go
@@ -26,7 +26,7 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/gtscontext"
"code.superseriousbusiness.org/gotosocial/internal/gtserror"
"code.superseriousbusiness.org/gotosocial/internal/log"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
"github.com/gin-gonic/gin"
)
diff --git a/internal/cache/timeline/status_test.go b/internal/cache/timeline/status_test.go
index 93623f3ab..ff6dbe51b 100644
--- a/internal/cache/timeline/status_test.go
+++ b/internal/cache/timeline/status_test.go
@@ -29,8 +29,8 @@ import (
apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
"code.superseriousbusiness.org/gotosocial/internal/id"
- "code.superseriousbusiness.org/gotosocial/internal/log"
"code.superseriousbusiness.org/gotosocial/internal/paging"
+ "codeberg.org/gruf/go-kv/v2"
"codeberg.org/gruf/go-structr"
"github.com/stretchr/testify/assert"
)
@@ -440,7 +440,8 @@ func loadStatusIDsFrom(data []*StatusMeta) func(ids []string) ([]*gtsmodel.Statu
return s.ID == id
})
if i < 0 || i >= len(data) {
- panic(fmt.Sprintf("could not find %s in %v", id, log.VarDump(data)))
+ kv := kv.Field{K: "data", V: data} // use kv.Field for formatting
+ panic(fmt.Sprintf("could not find %s in %v", id, kv))
}
statuses = append(statuses, &gtsmodel.Status{
ID: data[i].ID,
diff --git a/internal/config/config_test.go b/internal/config/config_test.go
index 4e920700e..a23fc20f4 100644
--- a/internal/config/config_test.go
+++ b/internal/config/config_test.go
@@ -24,7 +24,7 @@ import (
"testing"
"code.superseriousbusiness.org/gotosocial/internal/config"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
diff --git a/internal/db/bundb/hook.go b/internal/db/bundb/hook.go
index 798868ccb..f02a1353d 100644
--- a/internal/db/bundb/hook.go
+++ b/internal/db/bundb/hook.go
@@ -22,7 +22,7 @@ import (
"time"
"code.superseriousbusiness.org/gotosocial/internal/log"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
"github.com/uptrace/bun"
)
diff --git a/internal/federation/authenticate.go b/internal/federation/authenticate.go
index 2355aaa03..f8515e649 100644
--- a/internal/federation/authenticate.go
+++ b/internal/federation/authenticate.go
@@ -38,7 +38,7 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
"code.superseriousbusiness.org/gotosocial/internal/log"
"code.superseriousbusiness.org/httpsig"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
)
var (
diff --git a/internal/federation/dereferencing/thread.go b/internal/federation/dereferencing/thread.go
index f9d6adb99..d426ee4bc 100644
--- a/internal/federation/dereferencing/thread.go
+++ b/internal/federation/dereferencing/thread.go
@@ -28,7 +28,7 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/gtserror"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
"code.superseriousbusiness.org/gotosocial/internal/log"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
)
// maxIter defines how many iterations of descendants or
diff --git a/internal/federation/federatingactor.go b/internal/federation/federatingactor.go
index 56bc0a416..2a68865aa 100644
--- a/internal/federation/federatingactor.go
+++ b/internal/federation/federatingactor.go
@@ -35,7 +35,7 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/log"
"code.superseriousbusiness.org/gotosocial/internal/uris"
errorsv2 "codeberg.org/gruf/go-errors/v2"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
)
// federatingActor wraps the pub.FederatingActor
diff --git a/internal/federation/federatingprotocol.go b/internal/federation/federatingprotocol.go
index 60ee48eaa..e1ec86b32 100644
--- a/internal/federation/federatingprotocol.go
+++ b/internal/federation/federatingprotocol.go
@@ -35,7 +35,7 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/log"
"code.superseriousbusiness.org/gotosocial/internal/uris"
"code.superseriousbusiness.org/gotosocial/internal/util/xslices"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
)
type errOtherIRIBlocked struct {
diff --git a/internal/gtscontext/log_hooks.go b/internal/gtscontext/log_hooks.go
index 3e8b166ff..a50f8fffa 100644
--- a/internal/gtscontext/log_hooks.go
+++ b/internal/gtscontext/log_hooks.go
@@ -21,7 +21,7 @@ import (
"context"
"code.superseriousbusiness.org/gotosocial/internal/log"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
)
func init() {
diff --git a/internal/id/ulid.go b/internal/id/ulid.go
index b281ef5b8..04afef8f0 100644
--- a/internal/id/ulid.go
+++ b/internal/id/ulid.go
@@ -23,7 +23,7 @@ import (
"time"
"code.superseriousbusiness.org/gotosocial/internal/log"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
"github.com/oklog/ulid"
)
diff --git a/internal/log/entry.go b/internal/log/entry.go
index 52e90caed..48059c3bf 100644
--- a/internal/log/entry.go
+++ b/internal/log/entry.go
@@ -21,7 +21,7 @@ import (
"context"
"fmt"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
)
type Entry struct {
diff --git a/internal/log/format.go b/internal/log/format.go
deleted file mode 100644
index e7468ed21..000000000
--- a/internal/log/format.go
+++ /dev/null
@@ -1,29 +0,0 @@
-// GoToSocial
-// Copyright (C) GoToSocial Authors admin@gotosocial.org
-// SPDX-License-Identifier: AGPL-3.0-or-later
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-package log
-
-import "codeberg.org/gruf/go-kv/format"
-
-// VarDump returns a serialized, useful log / error output of given variable.
-func VarDump(a any) string {
- buf := getBuf()
- format.Appendf(buf, "{:v}", a)
- s := string(buf.B)
- putBuf(buf)
- return s
-}
diff --git a/internal/log/log.go b/internal/log/log.go
index bf2259b50..afb1bcdb8 100644
--- a/internal/log/log.go
+++ b/internal/log/log.go
@@ -26,7 +26,7 @@ import (
"time"
"code.superseriousbusiness.org/gotosocial/internal/util/xslices"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
)
var (
diff --git a/internal/media/processingmedia.go b/internal/media/processingmedia.go
index 0bb145a02..bd0c1b7ee 100644
--- a/internal/media/processingmedia.go
+++ b/internal/media/processingmedia.go
@@ -22,7 +22,7 @@ import (
"os"
errorsv2 "codeberg.org/gruf/go-errors/v2"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
"codeberg.org/gruf/go-runners"
"code.superseriousbusiness.org/gotosocial/internal/config"
diff --git a/internal/middleware/logger.go b/internal/middleware/logger.go
index 350e7552c..d805e693f 100644
--- a/internal/middleware/logger.go
+++ b/internal/middleware/logger.go
@@ -28,7 +28,7 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/log"
"code.superseriousbusiness.org/gotosocial/internal/util"
"codeberg.org/gruf/go-bytesize"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
"github.com/gin-gonic/gin"
)
diff --git a/internal/observability/tracing.go b/internal/observability/tracing.go
index 25d5e27e8..99f426743 100644
--- a/internal/observability/tracing.go
+++ b/internal/observability/tracing.go
@@ -26,7 +26,7 @@ import (
"net/http"
"strconv"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
"github.com/gin-gonic/gin"
diff --git a/internal/processing/account/delete.go b/internal/processing/account/delete.go
index f812909c5..717c03fcc 100644
--- a/internal/processing/account/delete.go
+++ b/internal/processing/account/delete.go
@@ -31,7 +31,7 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/log"
"code.superseriousbusiness.org/gotosocial/internal/messages"
"code.superseriousbusiness.org/gotosocial/internal/util"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
"github.com/google/uuid"
"golang.org/x/crypto/bcrypt"
)
diff --git a/internal/processing/search/accounts.go b/internal/processing/search/accounts.go
index 9345aaba6..af84abc31 100644
--- a/internal/processing/search/accounts.go
+++ b/internal/processing/search/accounts.go
@@ -29,7 +29,7 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/id"
"code.superseriousbusiness.org/gotosocial/internal/log"
"code.superseriousbusiness.org/gotosocial/internal/util"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
)
// Accounts does a partial search for accounts that
diff --git a/internal/processing/search/get.go b/internal/processing/search/get.go
index 2051fb399..2e956b049 100644
--- a/internal/processing/search/get.go
+++ b/internal/processing/search/get.go
@@ -34,7 +34,7 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/log"
"code.superseriousbusiness.org/gotosocial/internal/text"
"code.superseriousbusiness.org/gotosocial/internal/util"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
)
const (
diff --git a/internal/processing/search/lookup.go b/internal/processing/search/lookup.go
index 3250f9848..39fddad77 100644
--- a/internal/processing/search/lookup.go
+++ b/internal/processing/search/lookup.go
@@ -28,7 +28,7 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
"code.superseriousbusiness.org/gotosocial/internal/log"
"code.superseriousbusiness.org/gotosocial/internal/util"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
)
// Lookup does a quick, non-resolving search for accounts that
diff --git a/internal/processing/stream/open.go b/internal/processing/stream/open.go
index bafa277a5..899e26896 100644
--- a/internal/processing/stream/open.go
+++ b/internal/processing/stream/open.go
@@ -24,7 +24,7 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
"code.superseriousbusiness.org/gotosocial/internal/log"
"code.superseriousbusiness.org/gotosocial/internal/stream"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
)
// Open returns a new Stream for the given account, which will contain a channel for passing messages back to the caller.
diff --git a/internal/processing/workers/fromclientapi.go b/internal/processing/workers/fromclientapi.go
index 32b3d8816..22e7780f6 100644
--- a/internal/processing/workers/fromclientapi.go
+++ b/internal/processing/workers/fromclientapi.go
@@ -36,7 +36,7 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/typeutils"
"code.superseriousbusiness.org/gotosocial/internal/uris"
"code.superseriousbusiness.org/gotosocial/internal/util"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
)
// clientAPI wraps processing functions
diff --git a/internal/processing/workers/fromfediapi.go b/internal/processing/workers/fromfediapi.go
index 1a42a04fb..09c1df480 100644
--- a/internal/processing/workers/fromfediapi.go
+++ b/internal/processing/workers/fromfediapi.go
@@ -29,7 +29,7 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/gtscontext"
"code.superseriousbusiness.org/gotosocial/internal/id"
"code.superseriousbusiness.org/gotosocial/internal/uris"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
"code.superseriousbusiness.org/gotosocial/internal/gtserror"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
diff --git a/internal/subscriptions/domainperms.go b/internal/subscriptions/domainperms.go
index 0f001620f..a1af8c152 100644
--- a/internal/subscriptions/domainperms.go
+++ b/internal/subscriptions/domainperms.go
@@ -30,7 +30,7 @@ import (
"strings"
"time"
- "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-kv/v2"
"code.superseriousbusiness.org/gotosocial/internal/admin"
apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model"