-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
colblk: use regular slice in PrefixBytesIter
We currently store an `unsafe.Pointer` and separate length and capacities. In many cases in the hot path we have to create a slice using `unsafe.Slice`. However `unsafe.Slice` includes some checks that we don't need (see [here](https://github.com/golang/go/blob/f38d42f2c4c6ad0d7cbdad5e1417cac3be2a5dcb/src/runtime/unsafe.go#L53)). In this change we switch to storing a regular slice and converting to an `unsafe.Pointer` using `unsafe.SliceData` (which directly accesses the pointer field). This improves performance, even while gaining boundary checks when appending the suffix. ``` CockroachDataBlockIter/AlphaLen=4,Shared=8,PrefixLen=32,Logical=0,value=8/Next 11.4ns ± 2% 10.6ns ± 1% -7.32% (p=0.008 n=5+5) ```
- Loading branch information
1 parent
94561af
commit 8ec212a
Showing
4 changed files
with
57 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters