2023-08-03 09:34:35 +00:00
|
|
|
// 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 cache
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/rsa"
|
2024-07-23 19:44:31 +00:00
|
|
|
"strings"
|
2023-08-03 09:34:35 +00:00
|
|
|
"time"
|
|
|
|
"unsafe"
|
|
|
|
|
|
|
|
"codeberg.org/gruf/go-cache/v3/simple"
|
|
|
|
"github.com/DmitriyVTitov/size"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/config"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/id"
|
2024-03-22 13:03:46 +00:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/util"
|
2023-08-03 09:34:35 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// example data values.
|
|
|
|
exampleID = id.Highest
|
|
|
|
exampleURI = "https://social.bbc/users/ItsMePrinceCharlesInit"
|
|
|
|
exampleText = `
|
|
|
|
oh no me nan's gone and done it :shocked:
|
|
|
|
|
|
|
|
she fuckin killed the king :regicide:
|
|
|
|
|
|
|
|
nan what have you done :shocked:
|
|
|
|
|
|
|
|
no nan put down the knife, don't go after the landlords next! :knife:
|
|
|
|
|
|
|
|
you'll make society more equitable for all if you're not careful! :hammer_sickle:
|
|
|
|
|
|
|
|
#JustNanProblems #WhatWillSheDoNext #MaybeItWasntSuchABadThingAfterAll
|
|
|
|
`
|
|
|
|
|
|
|
|
exampleTextSmall = "Small problem lads, me nan's gone on a bit of a rampage"
|
|
|
|
exampleUsername = "@SexHaver1969"
|
|
|
|
|
|
|
|
// ID string size in memory (is always 26 char ULID).
|
|
|
|
sizeofIDStr = unsafe.Sizeof(exampleID)
|
|
|
|
|
|
|
|
// URI string size in memory (use some random example URI).
|
|
|
|
sizeofURIStr = unsafe.Sizeof(exampleURI)
|
|
|
|
|
|
|
|
// ID slice size in memory (using some estimate of length = 250).
|
|
|
|
sizeofIDSlice = unsafe.Sizeof([]string{}) + 250*sizeofIDStr
|
|
|
|
|
|
|
|
// result cache key size estimate which is tricky. it can
|
|
|
|
// be a serialized string of almost any type, so we pick a
|
|
|
|
// nice serialized key size on the upper end of normal.
|
|
|
|
sizeofResultKey = 2 * sizeofIDStr
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
var (
|
|
|
|
// Example time calculated at ~ 14th August, 2023. Because if
|
|
|
|
// we use `time.Now()` in our structs below, it populates
|
|
|
|
// them with locale data which throws-off size calculations.
|
|
|
|
//
|
|
|
|
// This is because the locale data is (relatively) very large
|
|
|
|
// in-memory, but it's global "singletons" ptr'd to by the time
|
|
|
|
// structs, so inconsequential to our calculated cache size.
|
|
|
|
// Unfortunately the size.Of() function is not aware of this!
|
|
|
|
exampleTime = time.Time{}.Add(1692010328 * time.Second)
|
|
|
|
|
|
|
|
// stop trying to collapse this var
|
|
|
|
// block, gofmt, you motherfucker.
|
|
|
|
_ = interface{}(nil)
|
|
|
|
)
|
|
|
|
|
2023-08-03 09:34:35 +00:00
|
|
|
// calculateSliceCacheMax calculates the maximum capacity for a slice cache with given individual ratio.
|
|
|
|
func calculateSliceCacheMax(ratio float64) int {
|
|
|
|
return calculateCacheMax(sizeofIDStr, sizeofIDSlice, ratio)
|
|
|
|
}
|
|
|
|
|
|
|
|
// calculateResultCacheMax calculates the maximum cache capacity for a result
|
|
|
|
// cache's individual ratio number, and the size of the struct model in memory.
|
|
|
|
func calculateResultCacheMax(structSz uintptr, ratio float64) int {
|
|
|
|
// Estimate a worse-case scenario of extra lookup hash maps,
|
|
|
|
// where lookups are the no. "keys" each result can be found under
|
|
|
|
const lookups = 10
|
|
|
|
|
|
|
|
// Calculate the extra cache lookup map overheads.
|
|
|
|
totalLookupKeySz := uintptr(lookups) * sizeofResultKey
|
|
|
|
totalLookupValSz := uintptr(lookups) * unsafe.Sizeof(uint64(0))
|
|
|
|
|
|
|
|
// Primary cache sizes.
|
|
|
|
pkeySz := unsafe.Sizeof(uint64(0))
|
|
|
|
pvalSz := structSz
|
|
|
|
|
|
|
|
// The result cache wraps each struct result in a wrapping
|
|
|
|
// struct with further information, and possible error. This
|
|
|
|
// also needs to be taken into account when calculating value.
|
2023-08-14 16:08:19 +00:00
|
|
|
resultValueOverhead := uintptr(size.Of(&struct {
|
2023-08-03 09:34:35 +00:00
|
|
|
_ int64
|
|
|
|
_ []any
|
|
|
|
_ any
|
|
|
|
_ error
|
2023-08-14 16:08:19 +00:00
|
|
|
}{}))
|
2023-08-03 09:34:35 +00:00
|
|
|
|
|
|
|
return calculateCacheMax(
|
|
|
|
pkeySz+totalLookupKeySz,
|
|
|
|
pvalSz+totalLookupValSz+resultValueOverhead,
|
|
|
|
ratio,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// calculateCacheMax calculates the maximum cache capacity for a cache's
|
|
|
|
// individual ratio number, and key + value object sizes in memory.
|
|
|
|
func calculateCacheMax(keySz, valSz uintptr, ratio float64) int {
|
|
|
|
if ratio < 0 {
|
|
|
|
// Negative ratios are a secret little trick
|
|
|
|
// to manually set the cache capacity sizes.
|
|
|
|
return int(-1 * ratio)
|
|
|
|
}
|
|
|
|
|
|
|
|
// see: https://golang.org/src/runtime/map.go
|
|
|
|
const emptyBucketOverhead = 10.79
|
|
|
|
|
|
|
|
// This takes into account (roughly) that the underlying simple cache library wraps
|
|
|
|
// elements within a simple.Entry{}, and the ordered map wraps each in a linked list elem.
|
|
|
|
const cacheElemOverhead = unsafe.Sizeof(simple.Entry{}) + unsafe.Sizeof(struct {
|
|
|
|
key, value interface{}
|
|
|
|
next, prev uintptr
|
|
|
|
}{})
|
|
|
|
|
|
|
|
// 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()
|
|
|
|
|
|
|
|
// TODO: we should also further weight this ratio depending
|
|
|
|
// on the combined keySz + valSz as a ratio of all available
|
|
|
|
// cache model memories. otherwise you can end up with a
|
|
|
|
// low-ratio cache of tiny models with larger capacity than
|
|
|
|
// a high-ratio cache of large models.
|
|
|
|
|
|
|
|
// Get max available cache memory, calculating max for
|
|
|
|
// this cache by multiplying by this cache's mem ratio.
|
|
|
|
maxMem := config.GetCacheMemoryTarget()
|
|
|
|
fMaxMem := float64(maxMem) * totalRatio
|
|
|
|
|
|
|
|
// Cast to useable types.
|
|
|
|
fKeySz := float64(keySz)
|
|
|
|
fValSz := float64(valSz)
|
|
|
|
|
|
|
|
// Calculated using the internal cache map size:
|
|
|
|
// (($keysz + $valsz) * $len) + ($len * $allOverheads) = $memSz
|
|
|
|
return int(fMaxMem / (fKeySz + fValSz + emptyBucketOverhead + float64(cacheElemOverhead)))
|
|
|
|
}
|
|
|
|
|
|
|
|
// totalOfRatios returns the total of all cache ratios added together.
|
|
|
|
func totalOfRatios() float64 {
|
2024-09-16 16:46:09 +00:00
|
|
|
|
2023-08-03 09:34:35 +00:00
|
|
|
// 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() +
|
2024-05-06 21:29:31 +00:00
|
|
|
config.GetCacheAccountSettingsMemRatio() +
|
|
|
|
config.GetCacheAccountStatsMemRatio() +
|
2023-08-10 14:08:41 +00:00
|
|
|
config.GetCacheApplicationMemRatio() +
|
2023-08-03 09:34:35 +00:00
|
|
|
config.GetCacheBlockMemRatio() +
|
|
|
|
config.GetCacheBlockIDsMemRatio() +
|
2023-08-06 09:55:04 +00:00
|
|
|
config.GetCacheBoostOfIDsMemRatio() +
|
2024-04-15 13:22:21 +00:00
|
|
|
config.GetCacheClientMemRatio() +
|
2023-08-03 09:34:35 +00:00
|
|
|
config.GetCacheEmojiMemRatio() +
|
|
|
|
config.GetCacheEmojiCategoryMemRatio() +
|
2024-05-06 21:29:31 +00:00
|
|
|
config.GetCacheFilterMemRatio() +
|
|
|
|
config.GetCacheFilterKeywordMemRatio() +
|
|
|
|
config.GetCacheFilterStatusMemRatio() +
|
2023-08-03 09:34:35 +00:00
|
|
|
config.GetCacheFollowMemRatio() +
|
|
|
|
config.GetCacheFollowIDsMemRatio() +
|
|
|
|
config.GetCacheFollowRequestMemRatio() +
|
|
|
|
config.GetCacheFollowRequestIDsMemRatio() +
|
2024-09-16 16:46:09 +00:00
|
|
|
config.GetCacheFollowingTagIDsMemRatio() +
|
|
|
|
config.GetCacheInReplyToIDsMemRatio() +
|
2023-08-03 09:34:35 +00:00
|
|
|
config.GetCacheInstanceMemRatio() +
|
2024-08-24 09:49:37 +00:00
|
|
|
config.GetCacheInteractionRequestMemRatio() +
|
2023-08-03 09:34:35 +00:00
|
|
|
config.GetCacheListMemRatio() +
|
2024-09-16 16:46:09 +00:00
|
|
|
config.GetCacheListIDsMemRatio() +
|
|
|
|
config.GetCacheListedIDsMemRatio() +
|
2023-08-03 09:34:35 +00:00
|
|
|
config.GetCacheMarkerMemRatio() +
|
|
|
|
config.GetCacheMediaMemRatio() +
|
|
|
|
config.GetCacheMentionMemRatio() +
|
2024-05-06 21:29:31 +00:00
|
|
|
config.GetCacheMoveMemRatio() +
|
2023-08-03 09:34:35 +00:00
|
|
|
config.GetCacheNotificationMemRatio() +
|
2023-11-08 14:32:17 +00:00
|
|
|
config.GetCachePollMemRatio() +
|
|
|
|
config.GetCachePollVoteMemRatio() +
|
2024-09-16 16:46:09 +00:00
|
|
|
config.GetCachePollVoteIDsMemRatio() +
|
2023-08-03 09:34:35 +00:00
|
|
|
config.GetCacheReportMemRatio() +
|
2024-09-16 16:46:09 +00:00
|
|
|
config.GetCacheSinBinStatusMemRatio() +
|
2023-08-03 09:34:35 +00:00
|
|
|
config.GetCacheStatusMemRatio() +
|
2024-06-06 10:44:43 +00:00
|
|
|
config.GetCacheStatusBookmarkMemRatio() +
|
|
|
|
config.GetCacheStatusBookmarkIDsMemRatio() +
|
2023-08-03 09:34:35 +00:00
|
|
|
config.GetCacheStatusFaveMemRatio() +
|
2023-08-06 09:55:04 +00:00
|
|
|
config.GetCacheStatusFaveIDsMemRatio() +
|
2023-08-03 09:34:35 +00:00
|
|
|
config.GetCacheTagMemRatio() +
|
2023-10-25 14:04:53 +00:00
|
|
|
config.GetCacheThreadMuteMemRatio() +
|
2024-04-15 13:22:21 +00:00
|
|
|
config.GetCacheTokenMemRatio() +
|
2023-08-03 09:34:35 +00:00
|
|
|
config.GetCacheTombstoneMemRatio() +
|
|
|
|
config.GetCacheUserMemRatio() +
|
2024-09-16 16:46:09 +00:00
|
|
|
config.GetCacheUserMuteMemRatio() +
|
|
|
|
config.GetCacheUserMuteIDsMemRatio() +
|
2023-08-03 09:34:35 +00:00
|
|
|
config.GetCacheWebfingerMemRatio() +
|
|
|
|
config.GetCacheVisibilityMemRatio()
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofAccount() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Account{
|
|
|
|
ID: exampleID,
|
|
|
|
Username: exampleUsername,
|
|
|
|
AvatarMediaAttachmentID: exampleID,
|
|
|
|
HeaderMediaAttachmentID: exampleID,
|
|
|
|
DisplayName: exampleUsername,
|
|
|
|
Note: exampleText,
|
|
|
|
NoteRaw: exampleText,
|
|
|
|
Memorial: func() *bool { ok := false; return &ok }(),
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
FetchedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
Bot: func() *bool { ok := true; return &ok }(),
|
|
|
|
Locked: func() *bool { ok := true; return &ok }(),
|
|
|
|
Discoverable: func() *bool { ok := false; return &ok }(),
|
|
|
|
URI: exampleURI,
|
|
|
|
URL: exampleURI,
|
|
|
|
InboxURI: exampleURI,
|
|
|
|
OutboxURI: exampleURI,
|
|
|
|
FollowersURI: exampleURI,
|
|
|
|
FollowingURI: exampleURI,
|
|
|
|
FeaturedCollectionURI: exampleURI,
|
|
|
|
ActorType: ap.ActorPerson,
|
|
|
|
PrivateKey: &rsa.PrivateKey{},
|
|
|
|
PublicKey: &rsa.PublicKey{},
|
|
|
|
PublicKeyURI: exampleURI,
|
2023-08-14 16:08:19 +00:00
|
|
|
SensitizedAt: exampleTime,
|
|
|
|
SilencedAt: exampleTime,
|
|
|
|
SuspendedAt: exampleTime,
|
2023-08-10 14:08:41 +00:00
|
|
|
SuspensionOrigin: exampleID,
|
2023-08-03 09:34:35 +00:00
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofAccountNote() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.AccountNote{
|
|
|
|
ID: exampleID,
|
|
|
|
AccountID: exampleID,
|
|
|
|
TargetAccountID: exampleID,
|
|
|
|
Comment: exampleTextSmall,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2024-03-22 13:03:46 +00:00
|
|
|
func sizeofAccountSettings() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.AccountSettings{
|
|
|
|
AccountID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
Privacy: gtsmodel.VisibilityFollowersOnly,
|
|
|
|
Sensitive: util.Ptr(true),
|
|
|
|
Language: "fr",
|
|
|
|
StatusContentType: "text/plain",
|
|
|
|
CustomCSS: exampleText,
|
|
|
|
EnableRSS: util.Ptr(true),
|
|
|
|
HideCollections: util.Ptr(false),
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2024-04-16 11:10:13 +00:00
|
|
|
func sizeofAccountStats() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.AccountStats{
|
|
|
|
AccountID: exampleID,
|
|
|
|
FollowersCount: util.Ptr(100),
|
|
|
|
FollowingCount: util.Ptr(100),
|
|
|
|
StatusesCount: util.Ptr(100),
|
|
|
|
StatusesPinnedCount: util.Ptr(100),
|
|
|
|
LastStatusAt: exampleTime,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2023-08-10 14:08:41 +00:00
|
|
|
func sizeofApplication() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Application{
|
|
|
|
ID: exampleID,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
2023-08-10 14:08:41 +00:00
|
|
|
Name: exampleUsername,
|
|
|
|
Website: exampleURI,
|
|
|
|
RedirectURI: exampleURI,
|
|
|
|
ClientID: exampleID,
|
|
|
|
ClientSecret: exampleID,
|
|
|
|
Scopes: exampleTextSmall,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2023-08-03 09:34:35 +00:00
|
|
|
func sizeofBlock() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Block{
|
|
|
|
ID: exampleID,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
URI: exampleURI,
|
|
|
|
AccountID: exampleID,
|
|
|
|
TargetAccountID: exampleID,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2024-04-15 13:22:21 +00:00
|
|
|
func sizeofClient() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Client{
|
|
|
|
ID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
Secret: exampleID,
|
|
|
|
Domain: exampleURI,
|
|
|
|
UserID: exampleID,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2024-07-23 19:44:31 +00:00
|
|
|
func sizeofConversation() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Conversation{
|
|
|
|
ID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
AccountID: exampleID,
|
|
|
|
OtherAccountIDs: []string{exampleID, exampleID, exampleID},
|
|
|
|
OtherAccountsKey: strings.Join([]string{exampleID, exampleID, exampleID}, ","),
|
|
|
|
ThreadID: exampleID,
|
|
|
|
LastStatusID: exampleID,
|
|
|
|
Read: util.Ptr(true),
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2024-10-28 13:52:09 +00:00
|
|
|
func sizeofDomainPermissionDraft() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.DomainPermissionDraft{
|
|
|
|
ID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
PermissionType: gtsmodel.DomainPermissionBlock,
|
|
|
|
Domain: "example.org",
|
|
|
|
CreatedByAccountID: exampleID,
|
|
|
|
PrivateComment: exampleTextSmall,
|
|
|
|
PublicComment: exampleTextSmall,
|
|
|
|
Obfuscate: util.Ptr(false),
|
|
|
|
SubscriptionID: exampleID,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofDomainPermissionSubscription() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.DomainPermissionSubscription{
|
|
|
|
ID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
PermissionType: gtsmodel.DomainPermissionBlock,
|
|
|
|
CreatedByAccountID: exampleID,
|
|
|
|
URI: exampleURI,
|
|
|
|
FetchUsername: "username",
|
|
|
|
FetchPassword: "password",
|
|
|
|
FetchedAt: exampleTime,
|
|
|
|
AsDraft: util.Ptr(true),
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2023-08-03 09:34:35 +00:00
|
|
|
func sizeofEmoji() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Emoji{
|
|
|
|
ID: exampleID,
|
|
|
|
Shortcode: exampleTextSmall,
|
|
|
|
Domain: exampleURI,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
ImageRemoteURL: exampleURI,
|
|
|
|
ImageStaticRemoteURL: exampleURI,
|
|
|
|
ImageURL: exampleURI,
|
|
|
|
ImagePath: exampleURI,
|
|
|
|
ImageStaticURL: exampleURI,
|
|
|
|
ImageStaticPath: exampleURI,
|
|
|
|
ImageContentType: "image/png",
|
|
|
|
ImageStaticContentType: "image/png",
|
|
|
|
Disabled: func() *bool { ok := false; return &ok }(),
|
|
|
|
URI: "http://localhost:8080/emoji/01F8MH9H8E4VG3KDYJR9EGPXCQ",
|
|
|
|
VisibleInPicker: func() *bool { ok := true; return &ok }(),
|
|
|
|
CategoryID: "01GGQ8V4993XK67B2JB396YFB7",
|
|
|
|
Cached: func() *bool { ok := true; return &ok }(),
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofEmojiCategory() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.EmojiCategory{
|
|
|
|
ID: exampleID,
|
|
|
|
Name: exampleUsername,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2024-03-06 10:15:58 +00:00
|
|
|
func sizeofFilter() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Filter{
|
|
|
|
ID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
ExpiresAt: exampleTime,
|
|
|
|
AccountID: exampleID,
|
|
|
|
Title: exampleTextSmall,
|
|
|
|
Action: gtsmodel.FilterActionHide,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofFilterKeyword() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.FilterKeyword{
|
|
|
|
ID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
FilterID: exampleID,
|
|
|
|
Keyword: exampleTextSmall,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofFilterStatus() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.FilterStatus{
|
|
|
|
ID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
FilterID: exampleID,
|
|
|
|
StatusID: exampleID,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2023-08-03 09:34:35 +00:00
|
|
|
func sizeofFollow() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Follow{
|
|
|
|
ID: exampleID,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
AccountID: exampleID,
|
|
|
|
TargetAccountID: exampleID,
|
|
|
|
ShowReblogs: func() *bool { ok := true; return &ok }(),
|
|
|
|
URI: exampleURI,
|
|
|
|
Notify: func() *bool { ok := false; return &ok }(),
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofFollowRequest() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.FollowRequest{
|
|
|
|
ID: exampleID,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
AccountID: exampleID,
|
|
|
|
TargetAccountID: exampleID,
|
|
|
|
ShowReblogs: func() *bool { ok := true; return &ok }(),
|
|
|
|
URI: exampleURI,
|
|
|
|
Notify: func() *bool { ok := false; return &ok }(),
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofInstance() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Instance{
|
|
|
|
ID: exampleID,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
Domain: exampleURI,
|
|
|
|
URI: exampleURI,
|
|
|
|
Title: exampleTextSmall,
|
|
|
|
ShortDescription: exampleText,
|
|
|
|
Description: exampleText,
|
|
|
|
ContactEmail: exampleUsername,
|
|
|
|
ContactAccountUsername: exampleUsername,
|
|
|
|
ContactAccountID: exampleID,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2024-08-24 09:49:37 +00:00
|
|
|
func sizeofInteractionRequest() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.InteractionRequest{
|
2024-07-11 14:44:29 +00:00
|
|
|
ID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
2024-08-24 09:49:37 +00:00
|
|
|
StatusID: exampleID,
|
|
|
|
TargetAccountID: exampleID,
|
2024-07-11 14:44:29 +00:00
|
|
|
InteractingAccountID: exampleID,
|
|
|
|
InteractionURI: exampleURI,
|
|
|
|
InteractionType: gtsmodel.InteractionAnnounce,
|
|
|
|
URI: exampleURI,
|
2024-08-24 09:49:37 +00:00
|
|
|
AcceptedAt: exampleTime,
|
2024-07-11 14:44:29 +00:00
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2023-08-03 09:34:35 +00:00
|
|
|
func sizeofList() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.List{
|
|
|
|
ID: exampleID,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
Title: exampleTextSmall,
|
|
|
|
AccountID: exampleID,
|
|
|
|
RepliesPolicy: gtsmodel.RepliesPolicyFollowed,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofMarker() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Marker{
|
|
|
|
AccountID: exampleID,
|
|
|
|
Name: gtsmodel.MarkerNameHome,
|
2023-08-14 16:08:19 +00:00
|
|
|
UpdatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
Version: 0,
|
|
|
|
LastReadID: exampleID,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofMedia() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.MediaAttachment{
|
|
|
|
ID: exampleID,
|
|
|
|
StatusID: exampleID,
|
|
|
|
URL: exampleURI,
|
|
|
|
RemoteURL: exampleURI,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
Type: gtsmodel.FileTypeImage,
|
|
|
|
AccountID: exampleID,
|
|
|
|
Description: exampleText,
|
|
|
|
ScheduledStatusID: exampleID,
|
|
|
|
Blurhash: exampleTextSmall,
|
|
|
|
File: gtsmodel.File{
|
|
|
|
Path: exampleURI,
|
|
|
|
ContentType: "image/jpeg",
|
|
|
|
},
|
|
|
|
Thumbnail: gtsmodel.Thumbnail{
|
|
|
|
Path: exampleURI,
|
|
|
|
ContentType: "image/jpeg",
|
|
|
|
URL: exampleURI,
|
|
|
|
RemoteURL: exampleURI,
|
|
|
|
},
|
|
|
|
Avatar: func() *bool { ok := false; return &ok }(),
|
|
|
|
Header: func() *bool { ok := false; return &ok }(),
|
|
|
|
Cached: func() *bool { ok := true; return &ok }(),
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofMention() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Mention{
|
|
|
|
ID: exampleURI,
|
|
|
|
StatusID: exampleURI,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
OriginAccountID: exampleURI,
|
|
|
|
OriginAccountURI: exampleURI,
|
|
|
|
TargetAccountID: exampleID,
|
|
|
|
NameString: exampleUsername,
|
|
|
|
TargetAccountURI: exampleURI,
|
|
|
|
TargetAccountURL: exampleURI,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2024-03-06 10:18:57 +00:00
|
|
|
func sizeofMove() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Move{
|
|
|
|
ID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
AttemptedAt: exampleTime,
|
|
|
|
SucceededAt: exampleTime,
|
|
|
|
OriginURI: exampleURI,
|
|
|
|
TargetURI: exampleURI,
|
|
|
|
URI: exampleURI,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2023-08-03 09:34:35 +00:00
|
|
|
func sizeofNotification() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Notification{
|
|
|
|
ID: exampleID,
|
|
|
|
NotificationType: gtsmodel.NotificationFave,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
TargetAccountID: exampleID,
|
|
|
|
OriginAccountID: exampleID,
|
|
|
|
StatusID: exampleID,
|
|
|
|
Read: func() *bool { ok := false; return &ok }(),
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2023-11-08 14:32:17 +00:00
|
|
|
func sizeofPoll() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Poll{
|
|
|
|
ID: exampleID,
|
|
|
|
Multiple: func() *bool { ok := false; return &ok }(),
|
|
|
|
HideCounts: func() *bool { ok := false; return &ok }(),
|
|
|
|
Options: []string{exampleTextSmall, exampleTextSmall, exampleTextSmall, exampleTextSmall},
|
|
|
|
StatusID: exampleID,
|
|
|
|
ExpiresAt: exampleTime,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofPollVote() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.PollVote{
|
|
|
|
ID: exampleID,
|
|
|
|
Choices: []int{69, 420, 1337},
|
|
|
|
AccountID: exampleID,
|
|
|
|
PollID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2023-08-03 09:34:35 +00:00
|
|
|
func sizeofReport() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Report{
|
|
|
|
ID: exampleID,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
URI: exampleURI,
|
|
|
|
AccountID: exampleID,
|
|
|
|
TargetAccountID: exampleID,
|
|
|
|
Comment: exampleText,
|
|
|
|
StatusIDs: []string{exampleID, exampleID, exampleID},
|
|
|
|
Forwarded: func() *bool { ok := true; return &ok }(),
|
|
|
|
ActionTaken: exampleText,
|
2023-08-14 16:08:19 +00:00
|
|
|
ActionTakenAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
ActionTakenByAccountID: exampleID,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2024-09-10 12:34:49 +00:00
|
|
|
func sizeofSinBinStatus() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.SinBinStatus{
|
|
|
|
ID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
URI: exampleURI,
|
|
|
|
URL: exampleURI,
|
|
|
|
Domain: exampleURI,
|
|
|
|
AccountURI: exampleURI,
|
|
|
|
InReplyToURI: exampleURI,
|
|
|
|
Content: exampleText,
|
|
|
|
AttachmentLinks: []string{exampleURI, exampleURI},
|
|
|
|
MentionTargetURIs: []string{exampleURI},
|
|
|
|
EmojiLinks: []string{exampleURI},
|
|
|
|
PollOptions: []string{exampleTextSmall, exampleTextSmall, exampleTextSmall, exampleTextSmall},
|
|
|
|
ContentWarning: exampleTextSmall,
|
|
|
|
Visibility: gtsmodel.VisibilityPublic,
|
|
|
|
Sensitive: util.Ptr(false),
|
|
|
|
Language: "en",
|
|
|
|
ActivityStreamsType: ap.ObjectNote,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2023-08-03 09:34:35 +00:00
|
|
|
func sizeofStatus() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Status{
|
2024-06-06 10:44:43 +00:00
|
|
|
ID: exampleID,
|
2023-08-03 09:34:35 +00:00
|
|
|
URI: exampleURI,
|
|
|
|
URL: exampleURI,
|
|
|
|
Content: exampleText,
|
|
|
|
Text: exampleText,
|
|
|
|
AttachmentIDs: []string{exampleID, exampleID, exampleID},
|
|
|
|
TagIDs: []string{exampleID, exampleID, exampleID},
|
|
|
|
MentionIDs: []string{},
|
|
|
|
EmojiIDs: []string{exampleID, exampleID, exampleID},
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
FetchedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
Local: func() *bool { ok := false; return &ok }(),
|
|
|
|
AccountURI: exampleURI,
|
|
|
|
AccountID: exampleID,
|
|
|
|
InReplyToID: exampleID,
|
|
|
|
InReplyToURI: exampleURI,
|
|
|
|
InReplyToAccountID: exampleID,
|
|
|
|
BoostOfID: exampleID,
|
|
|
|
BoostOfAccountID: exampleID,
|
|
|
|
ContentWarning: exampleUsername, // similar length
|
|
|
|
Visibility: gtsmodel.VisibilityPublic,
|
|
|
|
Sensitive: func() *bool { ok := false; return &ok }(),
|
|
|
|
Language: "en",
|
|
|
|
CreatedWithApplicationID: exampleID,
|
|
|
|
Federated: func() *bool { ok := true; return &ok }(),
|
|
|
|
ActivityStreamsType: ap.ObjectNote,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2024-06-06 10:44:43 +00:00
|
|
|
func sizeofStatusBookmark() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.StatusBookmark{
|
|
|
|
ID: exampleID,
|
|
|
|
AccountID: exampleID,
|
|
|
|
Account: nil,
|
|
|
|
TargetAccountID: exampleID,
|
|
|
|
TargetAccount: nil,
|
|
|
|
StatusID: exampleID,
|
|
|
|
Status: nil,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2023-08-03 09:34:35 +00:00
|
|
|
func sizeofStatusFave() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.StatusFave{
|
|
|
|
ID: exampleID,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
AccountID: exampleID,
|
|
|
|
TargetAccountID: exampleID,
|
|
|
|
StatusID: exampleID,
|
|
|
|
URI: exampleURI,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofTag() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Tag{
|
|
|
|
ID: exampleID,
|
|
|
|
Name: exampleUsername,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
Useable: func() *bool { ok := true; return &ok }(),
|
|
|
|
Listable: func() *bool { ok := true; return &ok }(),
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2024-04-15 13:22:21 +00:00
|
|
|
func sizeofThreadMute() uintptr {
|
2023-10-25 14:04:53 +00:00
|
|
|
return uintptr(size.Of(>smodel.ThreadMute{
|
|
|
|
ID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
ThreadID: exampleID,
|
|
|
|
AccountID: exampleID,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2024-04-15 13:22:21 +00:00
|
|
|
func sizeofToken() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Token{
|
|
|
|
ID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
ClientID: exampleID,
|
|
|
|
UserID: exampleID,
|
|
|
|
RedirectURI: exampleURI,
|
|
|
|
Scope: "r:w",
|
|
|
|
Code: "", // TODO
|
|
|
|
CodeChallenge: "", // TODO
|
|
|
|
CodeChallengeMethod: "", // TODO
|
|
|
|
CodeCreateAt: exampleTime,
|
|
|
|
CodeExpiresAt: exampleTime,
|
|
|
|
Access: exampleID + exampleID,
|
|
|
|
AccessCreateAt: exampleTime,
|
|
|
|
AccessExpiresAt: exampleTime,
|
|
|
|
Refresh: "", // TODO: clients don't really support this very well yet
|
|
|
|
RefreshCreateAt: exampleTime,
|
|
|
|
RefreshExpiresAt: exampleTime,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2023-08-03 09:34:35 +00:00
|
|
|
func sizeofTombstone() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.Tombstone{
|
|
|
|
ID: exampleID,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
2023-08-03 09:34:35 +00:00
|
|
|
Domain: exampleUsername,
|
|
|
|
URI: exampleURI,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofVisibility() uintptr {
|
|
|
|
return uintptr(size.Of(&CachedVisibility{
|
|
|
|
ItemID: exampleID,
|
|
|
|
RequesterID: exampleID,
|
|
|
|
Type: VisibilityTypeAccount,
|
|
|
|
Value: false,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func sizeofUser() uintptr {
|
2023-08-10 14:08:41 +00:00
|
|
|
return uintptr(size.Of(>smodel.User{
|
|
|
|
ID: exampleID,
|
2023-08-14 16:08:19 +00:00
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
2023-08-10 14:08:41 +00:00
|
|
|
Email: exampleURI,
|
|
|
|
AccountID: exampleID,
|
|
|
|
EncryptedPassword: exampleTextSmall,
|
|
|
|
InviteID: exampleID,
|
2024-04-11 09:45:53 +00:00
|
|
|
Reason: exampleText,
|
2023-08-10 14:08:41 +00:00
|
|
|
Locale: "en",
|
|
|
|
CreatedByApplicationID: exampleID,
|
2023-08-14 16:08:19 +00:00
|
|
|
LastEmailedAt: exampleTime,
|
2023-08-10 14:08:41 +00:00
|
|
|
ConfirmationToken: exampleTextSmall,
|
2023-08-14 16:08:19 +00:00
|
|
|
ConfirmationSentAt: exampleTime,
|
|
|
|
ConfirmedAt: exampleTime,
|
2023-08-10 14:08:41 +00:00
|
|
|
UnconfirmedEmail: exampleURI,
|
2024-04-11 09:45:53 +00:00
|
|
|
Moderator: util.Ptr(false),
|
|
|
|
Admin: util.Ptr(false),
|
|
|
|
Disabled: util.Ptr(false),
|
|
|
|
Approved: util.Ptr(false),
|
2023-08-10 14:08:41 +00:00
|
|
|
ResetPasswordToken: exampleTextSmall,
|
2023-08-14 16:08:19 +00:00
|
|
|
ResetPasswordSentAt: exampleTime,
|
2023-08-10 14:08:41 +00:00
|
|
|
ExternalID: exampleID,
|
|
|
|
}))
|
2023-08-03 09:34:35 +00:00
|
|
|
}
|
2024-06-06 16:38:02 +00:00
|
|
|
|
|
|
|
func sizeofUserMute() uintptr {
|
|
|
|
return uintptr(size.Of(>smodel.UserMute{
|
|
|
|
ID: exampleID,
|
|
|
|
CreatedAt: exampleTime,
|
|
|
|
UpdatedAt: exampleTime,
|
|
|
|
ExpiresAt: exampleTime,
|
|
|
|
AccountID: exampleID,
|
|
|
|
TargetAccountID: exampleID,
|
|
|
|
Notifications: util.Ptr(false),
|
|
|
|
}))
|
|
|
|
}
|