Use int8 for mvtype (memory reduction) (#1130)

* Use int8 for mvtype (memory reduction)

* Try to get around codespell false positives
This commit is contained in:
John Kerl 2022-11-26 00:34:25 -05:00 committed by GitHub
parent 95be06b752
commit c4f1d519ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 8 deletions

View file

@ -33,4 +33,4 @@ jobs:
with:
check_filenames: true
ignore_words_file: .codespellignore
skip: "*.csv,*.dkvp,*.txt,*.js,*.html,*.map,./tags,./test/cases,./docs/src/shapes-of-data.md.in,./docs/src/shapes-of-data.md"
skip: "*.csv,*.dkvp,*.txt,*.js,*.html,*.map,*.z,./tags,./test/cases,./docs/src/shapes-of-data.md.in,./docs/src/shapes-of-data.md,test/input/latin1.xtab"

19
cmd/sizes/main.go Normal file
View file

@ -0,0 +1,19 @@
// ================================================================
// Experiments for type-inference performance optimization
// ================================================================
// go build github.com/johnkerl/miller/cmd/sizes
package main
import (
"github.com/johnkerl/miller/internal/pkg/mlrval"
)
func main() {
var mvs [2]mlrval.Mlrval
mvs[0] = *mlrval.FromString("hello")
mvs[1] = *mlrval.FromString("world")
mvs[0].ShowSizes()
mvs[1].ShowSizes()
}

View file

@ -3,6 +3,7 @@ package mlrval
import (
"fmt"
"os"
"reflect"
"strconv"
)
@ -122,3 +123,19 @@ func (mv *Mlrval) StringifyValuesRecursively() {
mv.SetFromString(mv.String())
}
}
func (mv *Mlrval) ShowSizes() {
fmt.Printf("TOTAL %p %d\n", mv, reflect.TypeOf(*mv).Size())
fmt.Printf("mv.intval %p %d\n", &mv.intval, reflect.TypeOf(mv.intval).Size())
fmt.Printf("mv.floatval %p %d\n", &mv.floatval, reflect.TypeOf(mv.floatval).Size())
fmt.Printf("mv.printrep %p %d\n", &mv.printrep, reflect.TypeOf(mv.printrep).Size())
fmt.Printf("mv.printrepValid %p %d\n", &mv.printrepValid, reflect.TypeOf(mv.printrepValid).Size())
fmt.Printf("mv.boolval %p %d\n", &mv.boolval, reflect.TypeOf(mv.boolval).Size())
fmt.Printf("mv.mvtype %p %d\n", &mv.mvtype, reflect.TypeOf(mv.mvtype).Size())
fmt.Printf("mv.arrayval %p %d\n", &mv.arrayval, reflect.TypeOf(mv.arrayval).Size())
fmt.Printf("mv.mapval %p %d\n", &mv.mapval, reflect.TypeOf(mv.mapval).Size())
if mv.funcval != nil {
fmt.Printf("mv.funcval %p %d\n", &mv.funcval, reflect.TypeOf(mv.funcval).Size())
}
}

View file

@ -54,17 +54,16 @@
package mlrval
type Mlrval struct {
intval int64
floatval float64
printrep string
printrepValid bool
boolval bool
// Enumeration for string / int / float / boolean / etc.
// I would call this "type" not "mvtype" but "type" is a keyword in Go.
mvtype MVType
printrep string
printrepValid bool
intval int64
floatval float64
boolval bool
arrayval []*Mlrval
mapval *Mlrmap
// First-class-function literals from internal/pkg/dsl/cst.
@ -84,7 +83,7 @@ const ABSENT_PRINTREP = "(absent)"
// JavaScript, similarly, there are undefined and null, respectively --
// Miller's absent is more like JavaScript's undefined.)
type MVType int
type MVType int8
// Important: the values of these enums are used to index into disposition
// matrices. If they are changed, it will break the disposition matrices, or