Skip to content

Commit

Permalink
tscache: save 4 bytes per encoded tscache value
Browse files Browse the repository at this point in the history
`unsafe.Sizeof(hlc.Timestamp{})` was including XXX_sizecache, which was bloating
the struct size even though it didn't have an effect on the encoded size of the
timestamps, which we control in `encodeValue`.

Even once we remove `XXX_sizecache` (#37706), it looks like `unsafe.Sizeof` will
still include padding which we don't want to capture in the `encodedTsSize` constant,
so this seems like the best approach. See https://play.golang.org/p/5swJSSbP6J4.

Release note: None
  • Loading branch information
nvanbenschoten committed Jun 17, 2019
1 parent c5256fe commit c1d05b3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/storage/tscache/interval_skl.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const (
)

const (
encodedTsSize = int(unsafe.Sizeof(hlc.Timestamp{}))
encodedTsSize = int(unsafe.Sizeof(int64(0)) + unsafe.Sizeof(int32(0)))
encodedTxnIDSize = int(unsafe.Sizeof(uuid.UUID{}))
encodedValSize = encodedTsSize + encodedTxnIDSize
defaultMinSklPages = 2
Expand Down

0 comments on commit c1d05b3

Please sign in to comment.