sizegen: calculate malloc block sizes

Signed-off-by: Vicent Marti <vmg@strn.cat>
This commit is contained in:
Vicent Marti 2021-09-10 15:24:57 +02:00
Родитель be861d541e
Коммит 670d3c9251
18 изменённых файлов: 493 добавлений и 449 удалений

2
go/cache/ristretto/cache.go поставляемый
Просмотреть файл

@ -46,7 +46,7 @@ func defaultStringHash(key string) (uint64, uint64) {
type itemCallback func(*Item)
// CacheItemSize is the overhead in bytes for every stored cache item
const CacheItemSize = int64(unsafe.Sizeof(storeItem{}))
var CacheItemSize = hack.RuntimeAllocSize(int64(unsafe.Sizeof(storeItem{})))
// Cache is a thread-safe implementation of a hashmap with a TinyLFU admission
// policy and a Sampled LFU eviction policy. You can use the same Cache instance

Просмотреть файл

@ -43,3 +43,11 @@ func RuntimeMemhash(b []byte, seed uint64) uint64 {
func RuntimeStrhash(str string, seed uint64) uint64 {
return uint64(strhash(unsafe.Pointer(&str), uintptr(seed)))
}
//go:linkname roundupsize runtime.roundupsize
func roundupsize(size uintptr) uintptr
// RuntimeAllocSize returns size of the memory block that mallocgc will allocate if you ask for the size.
func RuntimeAllocSize(size int64) int64 {
return int64(roundupsize(uintptr(size)))
}

Просмотреть файл

@ -17,23 +17,25 @@ limitations under the License.
package sqltypes
import hack "vitess.io/vitess/go/hack"
func (cached *PlanValue) CachedSize(alloc bool) int64 {
if cached == nil {
return int64(0)
}
size := int64(0)
if alloc {
size += int64(88)
size += int64(96)
}
// field Key string
size += int64(len(cached.Key))
size += hack.RuntimeAllocSize(int64(len(cached.Key)))
// field Value vitess.io/vitess/go/sqltypes.Value
size += cached.Value.CachedSize(false)
// field ListKey string
size += int64(len(cached.ListKey))
size += hack.RuntimeAllocSize(int64(len(cached.ListKey)))
// field Values []vitess.io/vitess/go/sqltypes.PlanValue
{
size += int64(cap(cached.Values)) * int64(88)
size += hack.RuntimeAllocSize(int64(cap(cached.Values)) * int64(88))
for _, elem := range cached.Values {
size += elem.CachedSize(false)
}
@ -46,21 +48,21 @@ func (cached *Result) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(82)
size += int64(96)
}
// field Fields []*vitess.io/vitess/go/vt/proto/query.Field
{
size += int64(cap(cached.Fields)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Fields)) * int64(8))
for _, elem := range cached.Fields {
size += elem.CachedSize(true)
}
}
// field Rows [][]vitess.io/vitess/go/sqltypes.Value
{
size += int64(cap(cached.Rows)) * int64(24)
size += hack.RuntimeAllocSize(int64(cap(cached.Rows)) * int64(24))
for _, elem := range cached.Rows {
{
size += int64(cap(elem)) * int64(32)
size += hack.RuntimeAllocSize(int64(cap(elem)) * int64(32))
for _, elem := range elem {
size += elem.CachedSize(false)
}
@ -68,7 +70,7 @@ func (cached *Result) CachedSize(alloc bool) int64 {
}
}
// field SessionStateChanges string
size += int64(len(cached.SessionStateChanges))
size += hack.RuntimeAllocSize(int64(len(cached.SessionStateChanges)))
return size
}
func (cached *Value) CachedSize(alloc bool) int64 {
@ -80,6 +82,6 @@ func (cached *Value) CachedSize(alloc bool) int64 {
size += int64(32)
}
// field val []byte
size += int64(cap(cached.val))
size += hack.RuntimeAllocSize(int64(cap(cached.val)))
return size
}

Просмотреть файл

@ -21,6 +21,7 @@ import (
"math"
"reflect"
"unsafe"
hack "vitess.io/vitess/go/hack"
)
type cachedObject interface {
@ -71,7 +72,7 @@ func (cached *D) CachedSize(alloc bool) int64 {
}
// field field1 *vitess.io/vitess/go/tools/sizegen/integration.Bimpl
if cached.field1 != nil {
size += int64(8)
size += hack.RuntimeAllocSize(int64(8))
}
return size
}
@ -91,9 +92,9 @@ func (cached *Map1) CachedSize(alloc bool) int64 {
hmap := reflect.ValueOf(cached.field1)
numBuckets := int(math.Pow(2, float64((*(*uint8)(unsafe.Pointer(hmap.Pointer() + uintptr(9)))))))
numOldBuckets := (*(*uint16)(unsafe.Pointer(hmap.Pointer() + uintptr(10))))
size += int64(numOldBuckets * 32)
size += hack.RuntimeAllocSize(int64(numOldBuckets * 32))
if len(cached.field1) > 0 || numBuckets > 1 {
size += int64(numBuckets * 32)
size += hack.RuntimeAllocSize(int64(numBuckets * 32))
}
}
return size
@ -114,9 +115,9 @@ func (cached *Map2) CachedSize(alloc bool) int64 {
hmap := reflect.ValueOf(cached.field1)
numBuckets := int(math.Pow(2, float64((*(*uint8)(unsafe.Pointer(hmap.Pointer() + uintptr(9)))))))
numOldBuckets := (*(*uint16)(unsafe.Pointer(hmap.Pointer() + uintptr(10))))
size += int64(numOldBuckets * 208)
size += hack.RuntimeAllocSize(int64(numOldBuckets * 208))
if len(cached.field1) > 0 || numBuckets > 1 {
size += int64(numBuckets * 208)
size += hack.RuntimeAllocSize(int64(numBuckets * 208))
}
}
return size
@ -137,9 +138,9 @@ func (cached *Map3) CachedSize(alloc bool) int64 {
hmap := reflect.ValueOf(cached.field1)
numBuckets := int(math.Pow(2, float64((*(*uint8)(unsafe.Pointer(hmap.Pointer() + uintptr(9)))))))
numOldBuckets := (*(*uint16)(unsafe.Pointer(hmap.Pointer() + uintptr(10))))
size += int64(numOldBuckets * 208)
size += hack.RuntimeAllocSize(int64(numOldBuckets * 208))
if len(cached.field1) > 0 || numBuckets > 1 {
size += int64(numBuckets * 208)
size += hack.RuntimeAllocSize(int64(numBuckets * 208))
}
for _, v := range cached.field1 {
if cc, ok := v.(cachedObject); ok {
@ -169,7 +170,7 @@ func (cached *Slice1) CachedSize(alloc bool) int64 {
}
// field field1 []vitess.io/vitess/go/tools/sizegen/integration.A
{
size += int64(cap(cached.field1)) * int64(16)
size += hack.RuntimeAllocSize(int64(cap(cached.field1)) * int64(16))
}
return size
}
@ -183,7 +184,7 @@ func (cached *Slice2) CachedSize(alloc bool) int64 {
}
// field field1 []vitess.io/vitess/go/tools/sizegen/integration.B
{
size += int64(cap(cached.field1)) * int64(16)
size += hack.RuntimeAllocSize(int64(cap(cached.field1)) * int64(16))
for _, elem := range cached.field1 {
if cc, ok := elem.(cachedObject); ok {
size += cc.CachedSize(true)
@ -202,10 +203,10 @@ func (cached *Slice3) CachedSize(alloc bool) int64 {
}
// field field1 []*vitess.io/vitess/go/tools/sizegen/integration.Bimpl
{
size += int64(cap(cached.field1)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.field1)) * int64(8))
for _, elem := range cached.field1 {
if elem != nil {
size += int64(8)
size += hack.RuntimeAllocSize(int64(8))
}
}
}
@ -220,6 +221,6 @@ func (cached *String1) CachedSize(alloc bool) int64 {
size += int64(24)
}
// field field1 string
size += int64(len(cached.field1))
size += hack.RuntimeAllocSize(int64(len(cached.field1)))
return size
}

Просмотреть файл

@ -19,15 +19,17 @@ package integration
import (
"fmt"
"testing"
"vitess.io/vitess/go/hack"
)
func TestTypeSizes(t *testing.T) {
const PtrSize = 8
const SliceHeaderSize = 3 * PtrSize
const FatPointerSize = 2 * PtrSize
const BucketHeaderSize = 8
const BucketSize = 8
const HashMapHeaderSize = 48
var PtrSize = hack.RuntimeAllocSize(8)
var SliceHeaderSize = hack.RuntimeAllocSize(3 * PtrSize)
var FatPointerSize = hack.RuntimeAllocSize(2 * PtrSize)
var BucketHeaderSize = hack.RuntimeAllocSize(8)
var BucketSize = hack.RuntimeAllocSize(8)
var HashMapHeaderSize = hack.RuntimeAllocSize(48)
cases := []struct {
obj cachedObject
@ -70,8 +72,8 @@ func TestTypeSizes(t *testing.T) {
{&Map3{field1: map[uint64]B{0: &Bimpl{}}}, PtrSize + HashMapHeaderSize + BucketHeaderSize + 8*BucketSize + FatPointerSize*BucketSize + PtrSize + 8},
{&Map3{field1: map[uint64]B{0: nil}}, PtrSize + HashMapHeaderSize + BucketHeaderSize + 8*BucketSize + FatPointerSize*BucketSize + PtrSize},
{&String1{}, PtrSize*2 + 8},
{&String1{field1: "1234"}, PtrSize*2 + 8 + 4},
{&String1{}, hack.RuntimeAllocSize(PtrSize*2 + 8)},
{&String1{field1: "1234"}, hack.RuntimeAllocSize(PtrSize*2+8) + hack.RuntimeAllocSize(4)},
}
for _, tt := range cases {

Просмотреть файл

@ -27,6 +27,7 @@ import (
"sort"
"strings"
"vitess.io/vitess/go/hack"
"vitess.io/vitess/go/tools/common"
"github.com/dave/jennifer/jen"
@ -259,7 +260,7 @@ func (sizegen *sizegen) sizeImplForStruct(name *types.TypeName, st *types.Struct
b.Add(jen.If(jen.Id("cached").Op("==").Nil()).Block(jen.Return(jen.Lit(int64(0)))))
b.Add(jen.Id("size").Op(":=").Lit(int64(0)))
b.Add(jen.If(jen.Id("alloc")).Block(
jen.Id("size").Op("+=").Lit(sizegen.sizes.Sizeof(st)),
jen.Id("size").Op("+=").Lit(hack.RuntimeAllocSize(sizegen.sizes.Sizeof(st))),
))
for _, s := range stmt {
b.Add(s)
@ -294,7 +295,7 @@ func (sizegen *sizegen) sizeStmtForMap(fieldName *jen.Statement, m *types.Map) [
)
return []jen.Code{
jen.Id("size").Op("+=").Lit(sizeofHmap),
jen.Id("size").Op("+=").Lit(hack.RuntimeAllocSize(sizeofHmap)),
jen.Id("hmap").Op(":=").Qual("reflect", "ValueOf").Call(fieldName),
@ -308,11 +309,16 @@ func (sizegen *sizegen) sizeStmtForMap(fieldName *jen.Statement, m *types.Map) [
jen.Qual("unsafe", "Pointer").Call(
jen.Id("hmap").Dot("Pointer").Call().Op("+").Id("uintptr").Call(jen.Lit(10))))),
jen.Id("size").Op("+=").Id("int64").Call(jen.Id("numOldBuckets").Op("*").Lit(sizeOfBucket)),
jen.Id("size").Op("+=").Do(mallocsize(jen.Int64().Call(jen.Id("numOldBuckets").Op("*").Lit(sizeOfBucket)))),
jen.If(jen.Id("len").Call(fieldName).Op(">").Lit(0).Op("||").Id("numBuckets").Op(">").Lit(1)).Block(
jen.Id("size").Op("+=").Id("int64").Call(
jen.Id("numBuckets").Op("*").Lit(sizeOfBucket))),
jen.Id("size").Op("+=").Do(mallocsize(jen.Int64().Call(jen.Id("numBuckets").Op("*").Lit(sizeOfBucket))))),
}
}
func mallocsize(sizeStmt *jen.Statement) func(*jen.Statement) {
return func(parent *jen.Statement) {
parent.Qual("vitess.io/vitess/go/hack", "RuntimeAllocSize").Call(sizeStmt)
}
}
@ -331,7 +337,7 @@ func (sizegen *sizegen) sizeStmtForType(fieldName *jen.Statement, field types.Ty
return nil, 0
case 1:
return jen.Id("size").Op("+=").Int64().Call(jen.Cap(fieldName)), 0
return jen.Id("size").Op("+=").Do(mallocsize(jen.Int64().Call(jen.Cap(fieldName)))), 0
default:
stmt, flag := sizegen.sizeStmtForType(jen.Id("elem"), elemT, false)
@ -339,9 +345,10 @@ func (sizegen *sizegen) sizeStmtForType(fieldName *jen.Statement, field types.Ty
b.Add(
jen.Id("size").
Op("+=").
Int64().Call(jen.Cap(fieldName)).
Op("*").
Lit(sizegen.sizes.Sizeof(elemT)))
Do(mallocsize(jen.Int64().Call(jen.Cap(fieldName)).
Op("*").
Lit(sizegen.sizes.Sizeof(elemT))),
))
if stmt != nil {
b.Add(jen.For(jen.List(jen.Id("_"), jen.Id("elem")).Op(":=").Range().Add(fieldName)).Block(stmt))
@ -391,7 +398,7 @@ func (sizegen *sizegen) sizeStmtForType(fieldName *jen.Statement, field types.Ty
log.Printf("WARNING: size of external type %s cannot be fully calculated", node)
}
return jen.If(fieldName.Clone().Op("!=").Nil()).Block(
jen.Id("size").Op("+=").Lit(sizegen.sizes.Sizeof(node.Underlying())),
jen.Id("size").Op("+=").Do(mallocsize(jen.Lit(sizegen.sizes.Sizeof(node.Underlying())))),
), 0
}
return nil, 0
@ -422,11 +429,11 @@ func (sizegen *sizegen) sizeStmtForType(fieldName *jen.Statement, field types.Ty
case *types.Basic:
if !alloc {
if node.Info()&types.IsString != 0 {
return jen.Id("size").Op("+=").Int64().Call(jen.Len(fieldName)), 0
return jen.Id("size").Op("+=").Do(mallocsize(jen.Int64().Call(jen.Len(fieldName)))), 0
}
return nil, 0
}
return jen.Id("size").Op("+=").Lit(sizegen.sizes.Sizeof(node)), 0
return jen.Id("size").Op("+=").Do(mallocsize(jen.Lit(sizegen.sizes.Sizeof(node)))), 0
default:
log.Printf("unhandled type: %T", node)
return nil, 0

Просмотреть файл

@ -17,6 +17,8 @@ limitations under the License.
package query
import hack "vitess.io/vitess/go/hack"
func (cached *BindVariable) CachedSize(alloc bool) int64 {
if cached == nil {
return int64(0)
@ -26,12 +28,12 @@ func (cached *BindVariable) CachedSize(alloc bool) int64 {
size += int64(96)
}
// field unknownFields []byte
size += int64(cap(cached.unknownFields))
size += hack.RuntimeAllocSize(int64(cap(cached.unknownFields)))
// field Value []byte
size += int64(cap(cached.Value))
size += hack.RuntimeAllocSize(int64(cap(cached.Value)))
// field Values []*vitess.io/vitess/go/vt/proto/query.Value
{
size += int64(cap(cached.Values)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Values)) * int64(8))
for _, elem := range cached.Values {
size += elem.CachedSize(true)
}
@ -47,19 +49,19 @@ func (cached *Field) CachedSize(alloc bool) int64 {
size += int64(160)
}
// field unknownFields []byte
size += int64(cap(cached.unknownFields))
size += hack.RuntimeAllocSize(int64(cap(cached.unknownFields)))
// field Name string
size += int64(len(cached.Name))
size += hack.RuntimeAllocSize(int64(len(cached.Name)))
// field Table string
size += int64(len(cached.Table))
size += hack.RuntimeAllocSize(int64(len(cached.Table)))
// field OrgTable string
size += int64(len(cached.OrgTable))
size += hack.RuntimeAllocSize(int64(len(cached.OrgTable)))
// field Database string
size += int64(len(cached.Database))
size += hack.RuntimeAllocSize(int64(len(cached.Database)))
// field OrgName string
size += int64(len(cached.OrgName))
size += hack.RuntimeAllocSize(int64(len(cached.OrgName)))
// field ColumnType string
size += int64(len(cached.ColumnType))
size += hack.RuntimeAllocSize(int64(len(cached.ColumnType)))
return size
}
func (cached *QueryWarning) CachedSize(alloc bool) int64 {
@ -71,9 +73,9 @@ func (cached *QueryWarning) CachedSize(alloc bool) int64 {
size += int64(64)
}
// field unknownFields []byte
size += int64(cap(cached.unknownFields))
size += hack.RuntimeAllocSize(int64(cap(cached.unknownFields)))
// field Message string
size += int64(len(cached.Message))
size += hack.RuntimeAllocSize(int64(len(cached.Message)))
return size
}
func (cached *Target) CachedSize(alloc bool) int64 {
@ -85,13 +87,13 @@ func (cached *Target) CachedSize(alloc bool) int64 {
size += int64(96)
}
// field unknownFields []byte
size += int64(cap(cached.unknownFields))
size += hack.RuntimeAllocSize(int64(cap(cached.unknownFields)))
// field Keyspace string
size += int64(len(cached.Keyspace))
size += hack.RuntimeAllocSize(int64(len(cached.Keyspace)))
// field Shard string
size += int64(len(cached.Shard))
size += hack.RuntimeAllocSize(int64(len(cached.Shard)))
// field Cell string
size += int64(len(cached.Cell))
size += hack.RuntimeAllocSize(int64(len(cached.Cell)))
return size
}
func (cached *Value) CachedSize(alloc bool) int64 {
@ -100,11 +102,11 @@ func (cached *Value) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(72)
size += int64(80)
}
// field unknownFields []byte
size += int64(cap(cached.unknownFields))
size += hack.RuntimeAllocSize(int64(cap(cached.unknownFields)))
// field Value []byte
size += int64(cap(cached.Value))
size += hack.RuntimeAllocSize(int64(cap(cached.Value)))
return size
}

Просмотреть файл

@ -17,19 +17,21 @@ limitations under the License.
package topodata
import hack "vitess.io/vitess/go/hack"
func (cached *KeyRange) CachedSize(alloc bool) int64 {
if cached == nil {
return int64(0)
}
size := int64(0)
if alloc {
size += int64(88)
size += int64(96)
}
// field unknownFields []byte
size += int64(cap(cached.unknownFields))
size += hack.RuntimeAllocSize(int64(cap(cached.unknownFields)))
// field Start []byte
size += int64(cap(cached.Start))
size += hack.RuntimeAllocSize(int64(cap(cached.Start)))
// field End []byte
size += int64(cap(cached.End))
size += hack.RuntimeAllocSize(int64(cap(cached.End)))
return size
}

Просмотреть файл

@ -17,6 +17,8 @@ limitations under the License.
package schema
import hack "vitess.io/vitess/go/hack"
func (cached *DDLStrategySetting) CachedSize(alloc bool) int64 {
if cached == nil {
return int64(0)
@ -26,8 +28,8 @@ func (cached *DDLStrategySetting) CachedSize(alloc bool) int64 {
size += int64(32)
}
// field Strategy vitess.io/vitess/go/vt/schema.DDLStrategy
size += int64(len(cached.Strategy))
size += hack.RuntimeAllocSize(int64(len(cached.Strategy)))
// field Options string
size += int64(len(cached.Options))
size += hack.RuntimeAllocSize(int64(len(cached.Options)))
return size
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -17,6 +17,8 @@ limitations under the License.
package tableacl
import hack "vitess.io/vitess/go/hack"
type cachedObject interface {
CachedSize(alloc bool) int64
}
@ -34,6 +36,6 @@ func (cached *ACLResult) CachedSize(alloc bool) int64 {
size += cc.CachedSize(true)
}
// field GroupName string
size += int64(len(cached.GroupName))
size += hack.RuntimeAllocSize(int64(len(cached.GroupName)))
return size
}

Просмотреть файл

@ -21,6 +21,8 @@ import (
"math"
"reflect"
"unsafe"
hack "vitess.io/vitess/go/hack"
)
type cachedObject interface {
@ -33,10 +35,10 @@ func (cached *AggregateParams) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(72)
size += int64(80)
}
// field Alias string
size += int64(len(cached.Alias))
size += hack.RuntimeAllocSize(int64(len(cached.Alias)))
// field Expr vitess.io/vitess/go/vt/sqlparser.Expr
if cc, ok := cached.Expr.(cachedObject); ok {
size += cc.CachedSize(true)
@ -67,7 +69,7 @@ func (cached *Concatenate) CachedSize(alloc bool) int64 {
}
// field Sources []vitess.io/vitess/go/vt/vtgate/engine.Primitive
{
size += int64(cap(cached.Sources)) * int64(16)
size += hack.RuntimeAllocSize(int64(cap(cached.Sources)) * int64(16))
for _, elem := range cached.Sources {
if cc, ok := elem.(cachedObject); ok {
size += cc.CachedSize(true)
@ -85,7 +87,7 @@ func (cached *DBDDL) CachedSize(alloc bool) int64 {
size += int64(32)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
return size
}
func (cached *DDL) CachedSize(alloc bool) int64 {
@ -94,12 +96,12 @@ func (cached *DDL) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(59)
size += int64(64)
}
// field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace
size += cached.Keyspace.CachedSize(true)
// field SQL string
size += int64(len(cached.SQL))
size += hack.RuntimeAllocSize(int64(len(cached.SQL)))
// field DDL vitess.io/vitess/go/vt/sqlparser.DDLStatement
if cc, ok := cached.DDL.(cachedObject); ok {
size += cc.CachedSize(true)
@ -125,14 +127,14 @@ func (cached *DML) CachedSize(alloc bool) int64 {
size += cc.CachedSize(true)
}
// field Query string
size += int64(len(cached.Query))
size += hack.RuntimeAllocSize(int64(len(cached.Query)))
// field Vindex vitess.io/vitess/go/vt/vtgate/vindexes.SingleColumn
if cc, ok := cached.Vindex.(cachedObject); ok {
size += cc.CachedSize(true)
}
// field Values []vitess.io/vitess/go/sqltypes.PlanValue
{
size += int64(cap(cached.Values)) * int64(88)
size += hack.RuntimeAllocSize(int64(cap(cached.Values)) * int64(88))
for _, elem := range cached.Values {
size += elem.CachedSize(false)
}
@ -144,7 +146,7 @@ func (cached *DML) CachedSize(alloc bool) int64 {
// field Table *vitess.io/vitess/go/vt/vtgate/vindexes.Table
size += cached.Table.CachedSize(true)
// field OwnedVindexQuery string
size += int64(len(cached.OwnedVindexQuery))
size += hack.RuntimeAllocSize(int64(len(cached.OwnedVindexQuery)))
return size
}
func (cached *Delete) CachedSize(alloc bool) int64 {
@ -184,7 +186,7 @@ func (cached *Generate) CachedSize(alloc bool) int64 {
// field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace
size += cached.Keyspace.CachedSize(true)
// field Query string
size += int64(len(cached.Query))
size += hack.RuntimeAllocSize(int64(len(cached.Query)))
// field Values vitess.io/vitess/go/sqltypes.PlanValue
size += cached.Values.CachedSize(false)
return size
@ -214,10 +216,10 @@ func (cached *Insert) CachedSize(alloc bool) int64 {
// field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace
size += cached.Keyspace.CachedSize(true)
// field Query string
size += int64(len(cached.Query))
size += hack.RuntimeAllocSize(int64(len(cached.Query)))
// field VindexValues []vitess.io/vitess/go/sqltypes.PlanValue
{
size += int64(cap(cached.VindexValues)) * int64(88)
size += hack.RuntimeAllocSize(int64(cap(cached.VindexValues)) * int64(88))
for _, elem := range cached.VindexValues {
size += elem.CachedSize(false)
}
@ -227,16 +229,16 @@ func (cached *Insert) CachedSize(alloc bool) int64 {
// field Generate *vitess.io/vitess/go/vt/vtgate/engine.Generate
size += cached.Generate.CachedSize(true)
// field Prefix string
size += int64(len(cached.Prefix))
size += hack.RuntimeAllocSize(int64(len(cached.Prefix)))
// field Mid []string
{
size += int64(cap(cached.Mid)) * int64(16)
size += hack.RuntimeAllocSize(int64(cap(cached.Mid)) * int64(16))
for _, elem := range cached.Mid {
size += int64(len(elem))
size += hack.RuntimeAllocSize(int64(len(elem)))
}
}
// field Suffix string
size += int64(len(cached.Suffix))
size += hack.RuntimeAllocSize(int64(len(cached.Suffix)))
return size
}
@ -247,7 +249,7 @@ func (cached *Join) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(72)
size += int64(80)
}
// field Left vitess.io/vitess/go/vt/vtgate/engine.Primitive
if cc, ok := cached.Left.(cachedObject); ok {
@ -259,7 +261,7 @@ func (cached *Join) CachedSize(alloc bool) int64 {
}
// field Cols []int
{
size += int64(cap(cached.Cols)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Cols)) * int64(8))
}
// field Vars map[string]int
if cached.Vars != nil {
@ -267,12 +269,12 @@ func (cached *Join) CachedSize(alloc bool) int64 {
hmap := reflect.ValueOf(cached.Vars)
numBuckets := int(math.Pow(2, float64((*(*uint8)(unsafe.Pointer(hmap.Pointer() + uintptr(9)))))))
numOldBuckets := (*(*uint16)(unsafe.Pointer(hmap.Pointer() + uintptr(10))))
size += int64(numOldBuckets * 208)
size += hack.RuntimeAllocSize(int64(numOldBuckets * 208))
if len(cached.Vars) > 0 || numBuckets > 1 {
size += int64(numBuckets * 208)
size += hack.RuntimeAllocSize(int64(numBuckets * 208))
}
for k := range cached.Vars {
size += int64(len(k))
size += hack.RuntimeAllocSize(int64(len(k)))
}
}
return size
@ -301,7 +303,7 @@ func (cached *Lock) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(40)
size += int64(48)
}
// field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace
size += cached.Keyspace.CachedSize(true)
@ -310,7 +312,7 @@ func (cached *Lock) CachedSize(alloc bool) int64 {
size += cc.CachedSize(true)
}
// field Query string
size += int64(len(cached.Query))
size += hack.RuntimeAllocSize(int64(len(cached.Query)))
return size
}
func (cached *MStream) CachedSize(alloc bool) int64 {
@ -319,7 +321,7 @@ func (cached *MStream) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(40)
size += int64(48)
}
// field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace
size += cached.Keyspace.CachedSize(true)
@ -328,7 +330,7 @@ func (cached *MStream) CachedSize(alloc bool) int64 {
size += cc.CachedSize(true)
}
// field TableName string
size += int64(len(cached.TableName))
size += hack.RuntimeAllocSize(int64(len(cached.TableName)))
return size
}
func (cached *MemorySort) CachedSize(alloc bool) int64 {
@ -337,13 +339,13 @@ func (cached *MemorySort) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(136)
size += int64(144)
}
// field UpperLimit vitess.io/vitess/go/sqltypes.PlanValue
size += cached.UpperLimit.CachedSize(false)
// field OrderBy []vitess.io/vitess/go/vt/vtgate/engine.OrderByParams
{
size += int64(cap(cached.OrderBy)) * int64(32)
size += hack.RuntimeAllocSize(int64(cap(cached.OrderBy)) * int64(32))
}
// field Input vitess.io/vitess/go/vt/vtgate/engine.Primitive
if cc, ok := cached.Input.(cachedObject); ok {
@ -357,11 +359,11 @@ func (cached *MergeSort) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(49)
size += int64(64)
}
// field Primitives []vitess.io/vitess/go/vt/vtgate/engine.StreamExecutor
{
size += int64(cap(cached.Primitives)) * int64(16)
size += hack.RuntimeAllocSize(int64(cap(cached.Primitives)) * int64(16))
for _, elem := range cached.Primitives {
if cc, ok := elem.(cachedObject); ok {
size += cc.CachedSize(true)
@ -370,7 +372,7 @@ func (cached *MergeSort) CachedSize(alloc bool) int64 {
}
// field OrderBy []vitess.io/vitess/go/vt/vtgate/engine.OrderByParams
{
size += int64(cap(cached.OrderBy)) * int64(32)
size += hack.RuntimeAllocSize(int64(cap(cached.OrderBy)) * int64(32))
}
return size
}
@ -389,7 +391,7 @@ func (cached *OnlineDDL) CachedSize(alloc bool) int64 {
size += cc.CachedSize(true)
}
// field SQL string
size += int64(len(cached.SQL))
size += hack.RuntimeAllocSize(int64(len(cached.SQL)))
// field DDLStrategySetting *vitess.io/vitess/go/vt/schema.DDLStrategySetting
size += cached.DDLStrategySetting.CachedSize(true)
// field TargetDestination vitess.io/vitess/go/vt/key.Destination
@ -408,14 +410,14 @@ func (cached *OrderedAggregate) CachedSize(alloc bool) int64 {
}
// field Aggregates []*vitess.io/vitess/go/vt/vtgate/engine.AggregateParams
{
size += int64(cap(cached.Aggregates)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Aggregates)) * int64(8))
for _, elem := range cached.Aggregates {
size += elem.CachedSize(true)
}
}
// field GroupByKeys []*vitess.io/vitess/go/vt/vtgate/engine.GroupByParams
{
size += int64(cap(cached.GroupByKeys)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.GroupByKeys)) * int64(8))
for _, elem := range cached.GroupByKeys {
size += elem.CachedSize(true)
}
@ -432,10 +434,10 @@ func (cached *Plan) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(120)
size += int64(128)
}
// field Original string
size += int64(len(cached.Original))
size += hack.RuntimeAllocSize(int64(len(cached.Original)))
// field Instructions vitess.io/vitess/go/vt/vtgate/engine.Primitive
if cc, ok := cached.Instructions.(cachedObject); ok {
size += cc.CachedSize(true)
@ -444,7 +446,7 @@ func (cached *Plan) CachedSize(alloc bool) int64 {
size += cached.BindVarNeeds.CachedSize(true)
// field Warnings []*vitess.io/vitess/go/vt/proto/query.QueryWarning
{
size += int64(cap(cached.Warnings)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Warnings)) * int64(8))
for _, elem := range cached.Warnings {
size += elem.CachedSize(true)
}
@ -461,14 +463,14 @@ func (cached *Projection) CachedSize(alloc bool) int64 {
}
// field Cols []string
{
size += int64(cap(cached.Cols)) * int64(16)
size += hack.RuntimeAllocSize(int64(cap(cached.Cols)) * int64(16))
for _, elem := range cached.Cols {
size += int64(len(elem))
size += hack.RuntimeAllocSize(int64(len(elem)))
}
}
// field Exprs []vitess.io/vitess/go/vt/vtgate/evalengine.Expr
{
size += int64(cap(cached.Exprs)) * int64(16)
size += hack.RuntimeAllocSize(int64(cap(cached.Exprs)) * int64(16))
for _, elem := range cached.Exprs {
if cc, ok := elem.(cachedObject); ok {
size += cc.CachedSize(true)
@ -487,12 +489,12 @@ func (cached *PulloutSubquery) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(72)
size += int64(80)
}
// field SubqueryResult string
size += int64(len(cached.SubqueryResult))
size += hack.RuntimeAllocSize(int64(len(cached.SubqueryResult)))
// field HasValues string
size += int64(len(cached.HasValues))
size += hack.RuntimeAllocSize(int64(len(cached.HasValues)))
// field Subquery vitess.io/vitess/go/vt/vtgate/engine.Primitive
if cc, ok := cached.Subquery.(cachedObject); ok {
size += cc.CachedSize(true)
@ -513,14 +515,14 @@ func (cached *RenameFields) CachedSize(alloc bool) int64 {
}
// field Cols []string
{
size += int64(cap(cached.Cols)) * int64(16)
size += hack.RuntimeAllocSize(int64(cap(cached.Cols)) * int64(16))
for _, elem := range cached.Cols {
size += int64(len(elem))
size += hack.RuntimeAllocSize(int64(len(elem)))
}
}
// field Indices []int
{
size += int64(cap(cached.Indices)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Indices)) * int64(8))
}
// field Input vitess.io/vitess/go/vt/vtgate/engine.Primitive
if cc, ok := cached.Input.(cachedObject); ok {
@ -555,7 +557,7 @@ func (cached *RevertMigration) CachedSize(alloc bool) int64 {
// field Stmt *vitess.io/vitess/go/vt/sqlparser.RevertMigration
size += cached.Stmt.CachedSize(true)
// field Query string
size += int64(len(cached.Query))
size += hack.RuntimeAllocSize(int64(len(cached.Query)))
// field TargetDestination vitess.io/vitess/go/vt/key.Destination
if cc, ok := cached.TargetDestination.(cachedObject); ok {
size += cc.CachedSize(true)
@ -579,29 +581,29 @@ func (cached *Route) CachedSize(alloc bool) int64 {
size += cc.CachedSize(true)
}
// field Query string
size += int64(len(cached.Query))
size += hack.RuntimeAllocSize(int64(len(cached.Query)))
// field TableName string
size += int64(len(cached.TableName))
size += hack.RuntimeAllocSize(int64(len(cached.TableName)))
// field FieldQuery string
size += int64(len(cached.FieldQuery))
size += hack.RuntimeAllocSize(int64(len(cached.FieldQuery)))
// field Vindex vitess.io/vitess/go/vt/vtgate/vindexes.SingleColumn
if cc, ok := cached.Vindex.(cachedObject); ok {
size += cc.CachedSize(true)
}
// field Values []vitess.io/vitess/go/sqltypes.PlanValue
{
size += int64(cap(cached.Values)) * int64(88)
size += hack.RuntimeAllocSize(int64(cap(cached.Values)) * int64(88))
for _, elem := range cached.Values {
size += elem.CachedSize(false)
}
}
// field OrderBy []vitess.io/vitess/go/vt/vtgate/engine.OrderByParams
{
size += int64(cap(cached.OrderBy)) * int64(32)
size += hack.RuntimeAllocSize(int64(cap(cached.OrderBy)) * int64(32))
}
// field SysTableTableSchema []vitess.io/vitess/go/vt/vtgate/evalengine.Expr
{
size += int64(cap(cached.SysTableTableSchema)) * int64(16)
size += hack.RuntimeAllocSize(int64(cap(cached.SysTableTableSchema)) * int64(16))
for _, elem := range cached.SysTableTableSchema {
if cc, ok := elem.(cachedObject); ok {
size += cc.CachedSize(true)
@ -614,12 +616,12 @@ func (cached *Route) CachedSize(alloc bool) int64 {
hmap := reflect.ValueOf(cached.SysTableTableName)
numBuckets := int(math.Pow(2, float64((*(*uint8)(unsafe.Pointer(hmap.Pointer() + uintptr(9)))))))
numOldBuckets := (*(*uint16)(unsafe.Pointer(hmap.Pointer() + uintptr(10))))
size += int64(numOldBuckets * 272)
size += hack.RuntimeAllocSize(int64(numOldBuckets * 272))
if len(cached.SysTableTableName) > 0 || numBuckets > 1 {
size += int64(numBuckets * 272)
size += hack.RuntimeAllocSize(int64(numBuckets * 272))
}
for k, v := range cached.SysTableTableName {
size += int64(len(k))
size += hack.RuntimeAllocSize(int64(len(k)))
if cc, ok := v.(cachedObject); ok {
size += cc.CachedSize(true)
}
@ -637,10 +639,10 @@ func (cached *Rows) CachedSize(alloc bool) int64 {
}
// field rows [][]vitess.io/vitess/go/sqltypes.Value
{
size += int64(cap(cached.rows)) * int64(24)
size += hack.RuntimeAllocSize(int64(cap(cached.rows)) * int64(24))
for _, elem := range cached.rows {
{
size += int64(cap(elem)) * int64(32)
size += hack.RuntimeAllocSize(int64(cap(elem)) * int64(32))
for _, elem := range elem {
size += elem.CachedSize(false)
}
@ -649,7 +651,7 @@ func (cached *Rows) CachedSize(alloc bool) int64 {
}
// field fields []*vitess.io/vitess/go/vt/proto/query.Field
{
size += int64(cap(cached.fields)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.fields)) * int64(8))
for _, elem := range cached.fields {
size += elem.CachedSize(true)
}
@ -680,7 +682,7 @@ func (cached *Send) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(44)
size += int64(48)
}
// field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace
size += cached.Keyspace.CachedSize(true)
@ -689,7 +691,7 @@ func (cached *Send) CachedSize(alloc bool) int64 {
size += cc.CachedSize(true)
}
// field Query string
size += int64(len(cached.Query))
size += hack.RuntimeAllocSize(int64(len(cached.Query)))
return size
}
func (cached *SessionPrimitive) CachedSize(alloc bool) int64 {
@ -701,7 +703,7 @@ func (cached *SessionPrimitive) CachedSize(alloc bool) int64 {
size += int64(24)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
return size
}
func (cached *Set) CachedSize(alloc bool) int64 {
@ -710,11 +712,11 @@ func (cached *Set) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(40)
size += int64(48)
}
// field Ops []vitess.io/vitess/go/vt/vtgate/engine.SetOp
{
size += int64(cap(cached.Ops)) * int64(16)
size += hack.RuntimeAllocSize(int64(cap(cached.Ops)) * int64(16))
for _, elem := range cached.Ops {
if cc, ok := elem.(cachedObject); ok {
size += cc.CachedSize(true)
@ -733,11 +735,11 @@ func (cached *SimpleProjection) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(40)
size += int64(48)
}
// field Cols []int
{
size += int64(cap(cached.Cols)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Cols)) * int64(8))
}
// field Input vitess.io/vitess/go/vt/vtgate/engine.Primitive
if cc, ok := cached.Input.(cachedObject); ok {
@ -751,10 +753,10 @@ func (cached *SysVarCheckAndIgnore) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(56)
size += int64(64)
}
// field Name string
size += int64(len(cached.Name))
size += hack.RuntimeAllocSize(int64(len(cached.Name)))
// field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace
size += cached.Keyspace.CachedSize(true)
// field TargetDestination vitess.io/vitess/go/vt/key.Destination
@ -762,7 +764,7 @@ func (cached *SysVarCheckAndIgnore) CachedSize(alloc bool) int64 {
size += cc.CachedSize(true)
}
// field Expr string
size += int64(len(cached.Expr))
size += hack.RuntimeAllocSize(int64(len(cached.Expr)))
return size
}
func (cached *SysVarIgnore) CachedSize(alloc bool) int64 {
@ -774,9 +776,9 @@ func (cached *SysVarIgnore) CachedSize(alloc bool) int64 {
size += int64(32)
}
// field Name string
size += int64(len(cached.Name))
size += hack.RuntimeAllocSize(int64(len(cached.Name)))
// field Expr string
size += int64(len(cached.Expr))
size += hack.RuntimeAllocSize(int64(len(cached.Expr)))
return size
}
func (cached *SysVarReservedConn) CachedSize(alloc bool) int64 {
@ -785,10 +787,10 @@ func (cached *SysVarReservedConn) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(56)
size += int64(64)
}
// field Name string
size += int64(len(cached.Name))
size += hack.RuntimeAllocSize(int64(len(cached.Name)))
// field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace
size += cached.Keyspace.CachedSize(true)
// field TargetDestination vitess.io/vitess/go/vt/key.Destination
@ -796,7 +798,7 @@ func (cached *SysVarReservedConn) CachedSize(alloc bool) int64 {
size += cc.CachedSize(true)
}
// field Expr string
size += int64(len(cached.Expr))
size += hack.RuntimeAllocSize(int64(len(cached.Expr)))
return size
}
func (cached *SysVarSetAware) CachedSize(alloc bool) int64 {
@ -808,7 +810,7 @@ func (cached *SysVarSetAware) CachedSize(alloc bool) int64 {
size += int64(32)
}
// field Name string
size += int64(len(cached.Name))
size += hack.RuntimeAllocSize(int64(len(cached.Name)))
// field Expr vitess.io/vitess/go/vt/vtgate/evalengine.Expr
if cc, ok := cached.Expr.(cachedObject); ok {
size += cc.CachedSize(true)
@ -823,7 +825,7 @@ func (cached *Update) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(152)
size += int64(160)
}
// field DML vitess.io/vitess/go/vt/vtgate/engine.DML
size += cached.DML.CachedSize(false)
@ -833,12 +835,12 @@ func (cached *Update) CachedSize(alloc bool) int64 {
hmap := reflect.ValueOf(cached.ChangedVindexValues)
numBuckets := int(math.Pow(2, float64((*(*uint8)(unsafe.Pointer(hmap.Pointer() + uintptr(9)))))))
numOldBuckets := (*(*uint16)(unsafe.Pointer(hmap.Pointer() + uintptr(10))))
size += int64(numOldBuckets * 208)
size += hack.RuntimeAllocSize(int64(numOldBuckets * 208))
if len(cached.ChangedVindexValues) > 0 || numBuckets > 1 {
size += int64(numBuckets * 208)
size += hack.RuntimeAllocSize(int64(numBuckets * 208))
}
for k, v := range cached.ChangedVindexValues {
size += int64(len(k))
size += hack.RuntimeAllocSize(int64(len(k)))
size += v.CachedSize(true)
}
}
@ -853,7 +855,7 @@ func (cached *UpdateTarget) CachedSize(alloc bool) int64 {
size += int64(16)
}
// field Target string
size += int64(len(cached.Target))
size += hack.RuntimeAllocSize(int64(len(cached.Target)))
return size
}
func (cached *UserDefinedVariable) CachedSize(alloc bool) int64 {
@ -865,7 +867,7 @@ func (cached *UserDefinedVariable) CachedSize(alloc bool) int64 {
size += int64(32)
}
// field Name string
size += int64(len(cached.Name))
size += hack.RuntimeAllocSize(int64(len(cached.Name)))
// field Expr vitess.io/vitess/go/vt/vtgate/evalengine.Expr
if cc, ok := cached.Expr.(cachedObject); ok {
size += cc.CachedSize(true)
@ -887,9 +889,9 @@ func (cached *VStream) CachedSize(alloc bool) int64 {
size += cc.CachedSize(true)
}
// field TableName string
size += int64(len(cached.TableName))
size += hack.RuntimeAllocSize(int64(len(cached.TableName)))
// field Position string
size += int64(len(cached.Position))
size += hack.RuntimeAllocSize(int64(len(cached.Position)))
return size
}
func (cached *VindexFunc) CachedSize(alloc bool) int64 {
@ -902,14 +904,14 @@ func (cached *VindexFunc) CachedSize(alloc bool) int64 {
}
// field Fields []*vitess.io/vitess/go/vt/proto/query.Field
{
size += int64(cap(cached.Fields)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Fields)) * int64(8))
for _, elem := range cached.Fields {
size += elem.CachedSize(true)
}
}
// field Cols []int
{
size += int64(cap(cached.Cols)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Cols)) * int64(8))
}
// field Vindex vitess.io/vitess/go/vt/vtgate/vindexes.SingleColumn
if cc, ok := cached.Vindex.(cachedObject); ok {
@ -935,12 +937,12 @@ func (cached *VindexValues) CachedSize(alloc bool) int64 {
hmap := reflect.ValueOf(cached.PvMap)
numBuckets := int(math.Pow(2, float64((*(*uint8)(unsafe.Pointer(hmap.Pointer() + uintptr(9)))))))
numOldBuckets := (*(*uint16)(unsafe.Pointer(hmap.Pointer() + uintptr(10))))
size += int64(numOldBuckets * 848)
size += hack.RuntimeAllocSize(int64(numOldBuckets * 848))
if len(cached.PvMap) > 0 || numBuckets > 1 {
size += int64(numBuckets * 848)
size += hack.RuntimeAllocSize(int64(numBuckets * 848))
}
for k, v := range cached.PvMap {
size += int64(len(k))
size += hack.RuntimeAllocSize(int64(len(k)))
size += v.CachedSize(false)
}
}
@ -957,7 +959,7 @@ func (cached *shardRoute) CachedSize(alloc bool) int64 {
size += int64(32)
}
// field query string
size += int64(len(cached.query))
size += hack.RuntimeAllocSize(int64(len(cached.query)))
// field rs *vitess.io/vitess/go/vt/srvtopo.ResolvedShard
size += cached.rs.CachedSize(true)
// field bv map[string]*vitess.io/vitess/go/vt/proto/query.BindVariable
@ -966,12 +968,12 @@ func (cached *shardRoute) CachedSize(alloc bool) int64 {
hmap := reflect.ValueOf(cached.bv)
numBuckets := int(math.Pow(2, float64((*(*uint8)(unsafe.Pointer(hmap.Pointer() + uintptr(9)))))))
numOldBuckets := (*(*uint16)(unsafe.Pointer(hmap.Pointer() + uintptr(10))))
size += int64(numOldBuckets * 208)
size += hack.RuntimeAllocSize(int64(numOldBuckets * 208))
if len(cached.bv) > 0 || numBuckets > 1 {
size += int64(numBuckets * 208)
size += hack.RuntimeAllocSize(int64(numBuckets * 208))
}
for k, v := range cached.bv {
size += int64(len(k))
size += hack.RuntimeAllocSize(int64(len(k)))
size += v.CachedSize(true)
}
}

Просмотреть файл

@ -17,6 +17,8 @@ limitations under the License.
package evalengine
import hack "vitess.io/vitess/go/hack"
type cachedObject interface {
CachedSize(alloc bool) int64
}
@ -52,7 +54,7 @@ func (cached *BindVariable) CachedSize(alloc bool) int64 {
size += int64(16)
}
// field Key string
size += int64(len(cached.Key))
size += hack.RuntimeAllocSize(int64(len(cached.Key)))
return size
}
func (cached *Column) CachedSize(alloc bool) int64 {
@ -71,10 +73,10 @@ func (cached *EvalResult) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(56)
size += int64(64)
}
// field bytes []byte
size += int64(cap(cached.bytes))
size += hack.RuntimeAllocSize(int64(cap(cached.bytes)))
return size
}
func (cached *Literal) CachedSize(alloc bool) int64 {
@ -83,7 +85,7 @@ func (cached *Literal) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(56)
size += int64(64)
}
// field Val vitess.io/vitess/go/vt/vtgate/evalengine.EvalResult
size += cached.Val.CachedSize(false)

Просмотреть файл

@ -21,6 +21,8 @@ import (
"math"
"reflect"
"unsafe"
hack "vitess.io/vitess/go/hack"
)
type cachedObject interface {
@ -50,7 +52,7 @@ func (cached *Binary) CachedSize(alloc bool) int64 {
size += int64(16)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
return size
}
func (cached *BinaryMD5) CachedSize(alloc bool) int64 {
@ -62,7 +64,7 @@ func (cached *BinaryMD5) CachedSize(alloc bool) int64 {
size += int64(16)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
return size
}
func (cached *CFC) CachedSize(alloc bool) int64 {
@ -74,10 +76,10 @@ func (cached *CFC) CachedSize(alloc bool) int64 {
size += int64(64)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
// field offsets []int
{
size += int64(cap(cached.offsets)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.offsets)) * int64(8))
}
// field prefixVindex vitess.io/vitess/go/vt/vtgate/vindexes.SingleColumn
if cc, ok := cached.prefixVindex.(cachedObject); ok {
@ -91,7 +93,7 @@ func (cached *Column) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(44)
size += int64(48)
}
// field Name vitess.io/vitess/go/vt/sqlparser.ColIdent
size += cached.Name.CachedSize(false)
@ -107,15 +109,15 @@ func (cached *ColumnVindex) CachedSize(alloc bool) int64 {
}
// field Columns []vitess.io/vitess/go/vt/sqlparser.ColIdent
{
size += int64(cap(cached.Columns)) * int64(40)
size += hack.RuntimeAllocSize(int64(cap(cached.Columns)) * int64(40))
for _, elem := range cached.Columns {
size += elem.CachedSize(false)
}
}
// field Type string
size += int64(len(cached.Type))
size += hack.RuntimeAllocSize(int64(len(cached.Type)))
// field Name string
size += int64(len(cached.Name))
size += hack.RuntimeAllocSize(int64(len(cached.Name)))
// field Vindex vitess.io/vitess/go/vt/vtgate/vindexes.Vindex
if cc, ok := cached.Vindex.(cachedObject); ok {
size += cc.CachedSize(true)
@ -155,7 +157,7 @@ func (cached *Hash) CachedSize(alloc bool) int64 {
size += int64(16)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
return size
}
func (cached *Keyspace) CachedSize(alloc bool) int64 {
@ -164,10 +166,10 @@ func (cached *Keyspace) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(17)
size += int64(24)
}
// field Name string
size += int64(len(cached.Name))
size += hack.RuntimeAllocSize(int64(len(cached.Name)))
return size
}
func (cached *LookupHash) CachedSize(alloc bool) int64 {
@ -176,10 +178,10 @@ func (cached *LookupHash) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(136)
size += int64(144)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
// field lkp vitess.io/vitess/go/vt/vtgate/vindexes.lookupInternal
size += cached.lkp.CachedSize(false)
return size
@ -190,10 +192,10 @@ func (cached *LookupHashUnique) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(136)
size += int64(144)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
// field lkp vitess.io/vitess/go/vt/vtgate/vindexes.lookupInternal
size += cached.lkp.CachedSize(false)
return size
@ -204,10 +206,10 @@ func (cached *LookupNonUnique) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(136)
size += int64(144)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
// field lkp vitess.io/vitess/go/vt/vtgate/vindexes.lookupInternal
size += cached.lkp.CachedSize(false)
return size
@ -218,10 +220,10 @@ func (cached *LookupUnicodeLooseMD5Hash) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(136)
size += int64(144)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
// field lkp vitess.io/vitess/go/vt/vtgate/vindexes.lookupInternal
size += cached.lkp.CachedSize(false)
return size
@ -232,10 +234,10 @@ func (cached *LookupUnicodeLooseMD5HashUnique) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(136)
size += int64(144)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
// field lkp vitess.io/vitess/go/vt/vtgate/vindexes.lookupInternal
size += cached.lkp.CachedSize(false)
return size
@ -246,10 +248,10 @@ func (cached *LookupUnique) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(136)
size += int64(144)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
// field lkp vitess.io/vitess/go/vt/vtgate/vindexes.lookupInternal
size += cached.lkp.CachedSize(false)
return size
@ -263,7 +265,7 @@ func (cached *Null) CachedSize(alloc bool) int64 {
size += int64(16)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
return size
}
func (cached *Numeric) CachedSize(alloc bool) int64 {
@ -275,7 +277,7 @@ func (cached *Numeric) CachedSize(alloc bool) int64 {
size += int64(16)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
return size
}
@ -289,16 +291,16 @@ func (cached *NumericStaticMap) CachedSize(alloc bool) int64 {
size += int64(24)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
// field lookup vitess.io/vitess/go/vt/vtgate/vindexes.NumericLookupTable
if cached.lookup != nil {
size += int64(48)
hmap := reflect.ValueOf(cached.lookup)
numBuckets := int(math.Pow(2, float64((*(*uint8)(unsafe.Pointer(hmap.Pointer() + uintptr(9)))))))
numOldBuckets := (*(*uint16)(unsafe.Pointer(hmap.Pointer() + uintptr(10))))
size += int64(numOldBuckets * 144)
size += hack.RuntimeAllocSize(int64(numOldBuckets * 144))
if len(cached.lookup) > 0 || numBuckets > 1 {
size += int64(numBuckets * 144)
size += hack.RuntimeAllocSize(int64(numBuckets * 144))
}
}
return size
@ -312,7 +314,7 @@ func (cached *RegionExperimental) CachedSize(alloc bool) int64 {
size += int64(24)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
return size
}
@ -326,19 +328,19 @@ func (cached *RegionJSON) CachedSize(alloc bool) int64 {
size += int64(32)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
// field regionMap vitess.io/vitess/go/vt/vtgate/vindexes.RegionMap
if cached.regionMap != nil {
size += int64(48)
hmap := reflect.ValueOf(cached.regionMap)
numBuckets := int(math.Pow(2, float64((*(*uint8)(unsafe.Pointer(hmap.Pointer() + uintptr(9)))))))
numOldBuckets := (*(*uint16)(unsafe.Pointer(hmap.Pointer() + uintptr(10))))
size += int64(numOldBuckets * 208)
size += hack.RuntimeAllocSize(int64(numOldBuckets * 208))
if len(cached.regionMap) > 0 || numBuckets > 1 {
size += int64(numBuckets * 208)
size += hack.RuntimeAllocSize(int64(numBuckets * 208))
}
for k := range cached.regionMap {
size += int64(len(k))
size += hack.RuntimeAllocSize(int64(len(k)))
}
}
return size
@ -352,7 +354,7 @@ func (cached *ReverseBits) CachedSize(alloc bool) int64 {
size += int64(16)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
return size
}
func (cached *Table) CachedSize(alloc bool) int64 {
@ -361,31 +363,31 @@ func (cached *Table) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(169)
size += int64(176)
}
// field Type string
size += int64(len(cached.Type))
size += hack.RuntimeAllocSize(int64(len(cached.Type)))
// field Name vitess.io/vitess/go/vt/sqlparser.TableIdent
size += cached.Name.CachedSize(false)
// field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace
size += cached.Keyspace.CachedSize(true)
// field ColumnVindexes []*vitess.io/vitess/go/vt/vtgate/vindexes.ColumnVindex
{
size += int64(cap(cached.ColumnVindexes)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.ColumnVindexes)) * int64(8))
for _, elem := range cached.ColumnVindexes {
size += elem.CachedSize(true)
}
}
// field Ordered []*vitess.io/vitess/go/vt/vtgate/vindexes.ColumnVindex
{
size += int64(cap(cached.Ordered)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Ordered)) * int64(8))
for _, elem := range cached.Ordered {
size += elem.CachedSize(true)
}
}
// field Owned []*vitess.io/vitess/go/vt/vtgate/vindexes.ColumnVindex
{
size += int64(cap(cached.Owned)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Owned)) * int64(8))
for _, elem := range cached.Owned {
size += elem.CachedSize(true)
}
@ -394,13 +396,13 @@ func (cached *Table) CachedSize(alloc bool) int64 {
size += cached.AutoIncrement.CachedSize(true)
// field Columns []vitess.io/vitess/go/vt/vtgate/vindexes.Column
{
size += int64(cap(cached.Columns)) * int64(44)
size += hack.RuntimeAllocSize(int64(cap(cached.Columns)) * int64(44))
for _, elem := range cached.Columns {
size += elem.CachedSize(false)
}
}
// field Pinned []byte
size += int64(cap(cached.Pinned))
size += hack.RuntimeAllocSize(int64(cap(cached.Pinned)))
return size
}
func (cached *UnicodeLooseMD5) CachedSize(alloc bool) int64 {
@ -412,7 +414,7 @@ func (cached *UnicodeLooseMD5) CachedSize(alloc bool) int64 {
size += int64(16)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
return size
}
func (cached *UnicodeLooseXXHash) CachedSize(alloc bool) int64 {
@ -424,7 +426,7 @@ func (cached *UnicodeLooseXXHash) CachedSize(alloc bool) int64 {
size += int64(16)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
return size
}
func (cached *XXHash) CachedSize(alloc bool) int64 {
@ -436,7 +438,7 @@ func (cached *XXHash) CachedSize(alloc bool) int64 {
size += int64(16)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
return size
}
func (cached *clCommon) CachedSize(alloc bool) int64 {
@ -448,28 +450,28 @@ func (cached *clCommon) CachedSize(alloc bool) int64 {
size += int64(256)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
// field lkp vitess.io/vitess/go/vt/vtgate/vindexes.lookupInternal
size += cached.lkp.CachedSize(false)
// field keyspace string
size += int64(len(cached.keyspace))
size += hack.RuntimeAllocSize(int64(len(cached.keyspace)))
// field ownerTable string
size += int64(len(cached.ownerTable))
size += hack.RuntimeAllocSize(int64(len(cached.ownerTable)))
// field ownerColumns []string
{
size += int64(cap(cached.ownerColumns)) * int64(16)
size += hack.RuntimeAllocSize(int64(cap(cached.ownerColumns)) * int64(16))
for _, elem := range cached.ownerColumns {
size += int64(len(elem))
size += hack.RuntimeAllocSize(int64(len(elem)))
}
}
// field lockLookupQuery string
size += int64(len(cached.lockLookupQuery))
size += hack.RuntimeAllocSize(int64(len(cached.lockLookupQuery)))
// field lockOwnerQuery string
size += int64(len(cached.lockOwnerQuery))
size += hack.RuntimeAllocSize(int64(len(cached.lockOwnerQuery)))
// field insertLookupQuery string
size += int64(len(cached.insertLookupQuery))
size += hack.RuntimeAllocSize(int64(len(cached.insertLookupQuery)))
// field updateLookupQuery string
size += int64(len(cached.updateLookupQuery))
size += hack.RuntimeAllocSize(int64(len(cached.updateLookupQuery)))
return size
}
func (cached *lookupInternal) CachedSize(alloc bool) int64 {
@ -481,22 +483,22 @@ func (cached *lookupInternal) CachedSize(alloc bool) int64 {
size += int64(112)
}
// field Table string
size += int64(len(cached.Table))
size += hack.RuntimeAllocSize(int64(len(cached.Table)))
// field FromColumns []string
{
size += int64(cap(cached.FromColumns)) * int64(16)
size += hack.RuntimeAllocSize(int64(cap(cached.FromColumns)) * int64(16))
for _, elem := range cached.FromColumns {
size += int64(len(elem))
size += hack.RuntimeAllocSize(int64(len(elem)))
}
}
// field To string
size += int64(len(cached.To))
size += hack.RuntimeAllocSize(int64(len(cached.To)))
// field sel string
size += int64(len(cached.sel))
size += hack.RuntimeAllocSize(int64(len(cached.sel)))
// field ver string
size += int64(len(cached.ver))
size += hack.RuntimeAllocSize(int64(len(cached.ver)))
// field del string
size += int64(len(cached.del))
size += hack.RuntimeAllocSize(int64(len(cached.del)))
return size
}
func (cached *prefixCFC) CachedSize(alloc bool) int64 {

Просмотреть файл

@ -17,6 +17,8 @@ limitations under the License.
package tabletserver
import hack "vitess.io/vitess/go/hack"
func (cached *TabletPlan) CachedSize(alloc bool) int64 {
if cached == nil {
return int64(0)
@ -28,10 +30,10 @@ func (cached *TabletPlan) CachedSize(alloc bool) int64 {
// field Plan *vitess.io/vitess/go/vt/vttablet/tabletserver/planbuilder.Plan
size += cached.Plan.CachedSize(true)
// field Original string
size += int64(len(cached.Original))
size += hack.RuntimeAllocSize(int64(len(cached.Original)))
// field Fields []*vitess.io/vitess/go/vt/proto/query.Field
{
size += int64(cap(cached.Fields)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Fields)) * int64(8))
for _, elem := range cached.Fields {
size += elem.CachedSize(true)
}
@ -40,7 +42,7 @@ func (cached *TabletPlan) CachedSize(alloc bool) int64 {
size += cached.Rules.CachedSize(true)
// field Authorized []*vitess.io/vitess/go/vt/tableacl.ACLResult
{
size += int64(cap(cached.Authorized)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Authorized)) * int64(8))
for _, elem := range cached.Authorized {
size += elem.CachedSize(true)
}

Просмотреть файл

@ -17,6 +17,8 @@ limitations under the License.
package planbuilder
import hack "vitess.io/vitess/go/hack"
type cachedObject interface {
CachedSize(alloc bool) int64
}
@ -30,7 +32,7 @@ func (cached *Permission) CachedSize(alloc bool) int64 {
size += int64(24)
}
// field TableName string
size += int64(len(cached.TableName))
size += hack.RuntimeAllocSize(int64(len(cached.TableName)))
return size
}
func (cached *Plan) CachedSize(alloc bool) int64 {
@ -39,13 +41,13 @@ func (cached *Plan) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(168)
size += int64(176)
}
// field Table *vitess.io/vitess/go/vt/vttablet/tabletserver/schema.Table
size += cached.Table.CachedSize(true)
// field Permissions []vitess.io/vitess/go/vt/vttablet/tabletserver/planbuilder.Permission
{
size += int64(cap(cached.Permissions)) * int64(24)
size += hack.RuntimeAllocSize(int64(cap(cached.Permissions)) * int64(24))
for _, elem := range cached.Permissions {
size += elem.CachedSize(false)
}

Просмотреть файл

@ -17,6 +17,8 @@ limitations under the License.
package rules
import hack "vitess.io/vitess/go/hack"
type cachedObject interface {
CachedSize(alloc bool) int64
}
@ -30,7 +32,7 @@ func (cached *BindVarCond) CachedSize(alloc bool) int64 {
size += int64(48)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
// field value vitess.io/vitess/go/vt/vttablet/tabletserver/rules.bvcValue
if cc, ok := cached.value.(cachedObject); ok {
size += cc.CachedSize(true)
@ -43,12 +45,12 @@ func (cached *Rule) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(232)
size += int64(240)
}
// field Description string
size += int64(len(cached.Description))
size += hack.RuntimeAllocSize(int64(len(cached.Description)))
// field Name string
size += int64(len(cached.Name))
size += hack.RuntimeAllocSize(int64(len(cached.Name)))
// field requestIP vitess.io/vitess/go/vt/vttablet/tabletserver/rules.namedRegexp
size += cached.requestIP.CachedSize(false)
// field user vitess.io/vitess/go/vt/vttablet/tabletserver/rules.namedRegexp
@ -61,18 +63,18 @@ func (cached *Rule) CachedSize(alloc bool) int64 {
size += cached.trailingComment.CachedSize(false)
// field plans []vitess.io/vitess/go/vt/vttablet/tabletserver/planbuilder.PlanType
{
size += int64(cap(cached.plans)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.plans)) * int64(8))
}
// field tableNames []string
{
size += int64(cap(cached.tableNames)) * int64(16)
size += hack.RuntimeAllocSize(int64(cap(cached.tableNames)) * int64(16))
for _, elem := range cached.tableNames {
size += int64(len(elem))
size += hack.RuntimeAllocSize(int64(len(elem)))
}
}
// field bindVarConds []vitess.io/vitess/go/vt/vttablet/tabletserver/rules.BindVarCond
{
size += int64(cap(cached.bindVarConds)) * int64(48)
size += hack.RuntimeAllocSize(int64(cap(cached.bindVarConds)) * int64(48))
for _, elem := range cached.bindVarConds {
size += elem.CachedSize(false)
}
@ -89,7 +91,7 @@ func (cached *Rules) CachedSize(alloc bool) int64 {
}
// field rules []*vitess.io/vitess/go/vt/vttablet/tabletserver/rules.Rule
{
size += int64(cap(cached.rules)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.rules)) * int64(8))
for _, elem := range cached.rules {
size += elem.CachedSize(true)
}
@ -106,7 +108,7 @@ func (cached *bvcre) CachedSize(alloc bool) int64 {
}
// field re *regexp.Regexp
if cached.re != nil {
size += int64(153)
size += hack.RuntimeAllocSize(int64(153))
}
return size
}
@ -119,10 +121,10 @@ func (cached *namedRegexp) CachedSize(alloc bool) int64 {
size += int64(24)
}
// field name string
size += int64(len(cached.name))
size += hack.RuntimeAllocSize(int64(len(cached.name)))
// field Regexp *regexp.Regexp
if cached.Regexp != nil {
size += int64(153)
size += hack.RuntimeAllocSize(int64(153))
}
return size
}

Просмотреть файл

@ -17,6 +17,8 @@ limitations under the License.
package schema
import hack "vitess.io/vitess/go/hack"
func (cached *MessageInfo) CachedSize(alloc bool) int64 {
if cached == nil {
return int64(0)
@ -27,7 +29,7 @@ func (cached *MessageInfo) CachedSize(alloc bool) int64 {
}
// field Fields []*vitess.io/vitess/go/vt/proto/query.Field
{
size += int64(cap(cached.Fields)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Fields)) * int64(8))
for _, elem := range cached.Fields {
size += elem.CachedSize(true)
}
@ -50,20 +52,20 @@ func (cached *Table) CachedSize(alloc bool) int64 {
}
size := int64(0)
if alloc {
size += int64(104)
size += int64(112)
}
// field Name vitess.io/vitess/go/vt/sqlparser.TableIdent
size += cached.Name.CachedSize(false)
// field Fields []*vitess.io/vitess/go/vt/proto/query.Field
{
size += int64(cap(cached.Fields)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.Fields)) * int64(8))
for _, elem := range cached.Fields {
size += elem.CachedSize(true)
}
}
// field PKColumns []int
{
size += int64(cap(cached.PKColumns)) * int64(8)
size += hack.RuntimeAllocSize(int64(cap(cached.PKColumns)) * int64(8))
}
// field SequenceInfo *vitess.io/vitess/go/vt/vttablet/tabletserver/schema.SequenceInfo
size += cached.SequenceInfo.CachedSize(true)