Skip to content

Commit

Permalink
stringmap: optimize memory layout
Browse files Browse the repository at this point in the history
name                                           old alloc/op   new alloc/op   delta
Int64/Store/skipmap-16                            96.0B ± 0%     96.0B ± 0%     ~     (all equal)
Int64/Load50Hits/skipmap-16                       0.00B          0.00B          ~     (all equal)
Int64/30Store70Load/skipmap-16                    28.3B ± 2%     28.3B ± 2%     ~     (p=1.000 n=20+20)
Int64/1Delete9Store90Load/skipmap-16              8.00B ± 0%     8.00B ± 0%     ~     (all equal)
Int64/1Range9Delete90Store900Load/skipmap-16      8.00B ± 0%     8.00B ± 0%     ~     (all equal)
String/Store/skipmap-16                            128B ± 0%      112B ± 0%  -12.50%  (p=0.000 n=20+20)
String/Load50Hits/skipmap-16                      15.0B ± 0%     15.0B ± 0%     ~     (all equal)
String/30Store70Load/skipmap-16                   49.0B ± 0%     44.0B ± 0%  -10.20%  (p=0.000 n=19+20)
String/1Delete9Store90Load/skipmap-16             25.0B ± 0%     24.0B ± 0%   -4.00%  (p=0.000 n=17+20)
String/1Range9Delete90Store900Load/skipmap-16     25.0B ± 0%     24.0B ± 0%   -4.00%  (p=0.000 n=16+20)
  • Loading branch information
zhangyunhao116 committed Nov 28, 2023
1 parent 4853390 commit 53380cd
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 54 deletions.
6 changes: 3 additions & 3 deletions gen_func.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_int.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_int32.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_int32desc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_int64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_int64desc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_intdesc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_ordered.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_ordereddesc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_stringdesc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_uint.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_uint32.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_uint32desc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_uint64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_uint64desc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gen_uintdesc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions skipmap.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ type {{.StructPrefix}}Map{{.StructSuffix}}{{.TypeParam}} struct {
}

type {{.StructPrefixLow}}node{{.StructSuffix}}{{.TypeParam}} struct {
key {{.KeyType}}
value unsafe.Pointer // *any
flags bitflag
key {{.KeyType}}
next optionalArray // [level]*{{.StructPrefixLow}}node{{.StructSuffix}}
mu sync.Mutex
level uint32
mu sync.Mutex
next optionalArray // [level]*{{.StructPrefixLow}}node{{.StructSuffix}}
}

func new{{.StructPrefix}}Node{{.StructSuffix}}{{.TypeParam}}(key {{.KeyType}}, value {{.ValueType}}, level int) *{{.StructPrefixLow}}node{{.StructSuffix}}{{.TypeArgument}} {
Expand Down

0 comments on commit 53380cd

Please sign in to comment.