perf: implement bitpack encoding for LID and MID blocks#328
perf: implement bitpack encoding for LID and MID blocks#328
Conversation
3accfd6 to
53ef5eb
Compare
|
@seqbenchbot up main bulk |
🔴 Performance DegradationSome benchmarks have degraded compared to the previous run. Show table
|
|
@seqbenchbot down dc2d4d40 |
|
Nice, @cheb0 The benchmark with identificator Show summary
Have a great time! |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bf8f3d8 to
985f11f
Compare
🔴 Performance DegradationSome benchmarks have degraded compared to the previous run. Show table
|
985f11f to
4c802d2
Compare
🔴 Performance DegradationSome benchmarks have degraded compared to the previous run. Show table
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #328 +/- ##
==========================================
- Coverage 71.40% 71.28% -0.12%
==========================================
Files 219 220 +1
Lines 16454 16585 +131
==========================================
+ Hits 11749 11823 +74
- Misses 3834 3884 +50
- Partials 871 878 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🔴 Performance DegradationSome benchmarks have degraded compared to the previous run. Show table
|
|
|
||
| // CastAsUint64 allows working on []byte slice as []uint64. Uses unsafe casts for little endian, allocates | ||
| // a new buf and copies on big endian hosts. The caller must work as read only. | ||
| func CastAsUint64(buf []byte) []uint64 { |
There was a problem hiding this comment.
I guess it is worth putting a check that (n % sizeOfUint64) == 0. Just in case.
| } | ||
|
|
||
| if littleEndian { | ||
| return unsafe.Slice((*uint64)(unsafe.Pointer(unsafe.SliceData(buf))), n) |
There was a problem hiding this comment.
Are there any potential issues with alignment? AFAIK, there is no alignment guarantees that are provided by the Golang memory allocator.
For x86-64 it is not a problem (well, performance-wise it is), but for other architectures it is.
Maybe, we should add another check, something like:
assert(uintptr(unsafe.Pointer(&buf[0])) % unsafe.Alignof(uint64(0)) == 0)
There was a problem hiding this comment.
I deleted the entire file. I think it's too early for those optimizations. Maybe will do in a separate PR.
|
|
||
| func (b *Block) unpackBitpack(data []byte, buf *UnpackBuffer) error { | ||
| if data[0] == 1 { | ||
| b.IsLastLID = true |
There was a problem hiding this comment.
IIRC IsLastLID only affects packing and unpacking -- specifically, when we build slice of offsets for chunks of lids. This field in not accessed within search queries at all.
So maybe we can omit it? You store offsets as a part if LID block now so basically this field is useless.
There was a problem hiding this comment.
It's used by index analyzer cmd file. Probably deletion a separate PR would be fine, now it's just easier for me to avoid thinking about those fields.
There was a problem hiding this comment.
Deleted it from block format. We can rely on MinTID/MaxTID in index_analyzer, so we can delete this field altogether after index split is merged.
| } | ||
|
|
||
| // CopyUints32 copies srt to dst byte slice. If host is little-endian, then uses direct memory copy instead of loop. | ||
| func CopyUints32(src []uint32, dst []byte) []byte { |
There was a problem hiding this comment.
Have you measured impact of reinterpret cast for such functions?
🔴 Performance DegradationSome benchmarks have degraded compared to the previous run. Show table
|
🔴 Performance DegradationSome benchmarks have degraded compared to the previous run. Show table
|
🔴 Performance DegradationSome benchmarks have degraded compared to the previous run. Show table
|
3a567c4 to
f3827f1
Compare
🔴 Performance DegradationSome benchmarks have degraded compared to the previous run. Show table
|
Description
Replaces varint encoding with faster delta bitpacking. Both LID and MID blocks now use bitpack. Currently, intcomp library is used. The lib doesn't utilize SIMD, so we might update to something else in future.
Measurements
compression
bitpack compresses a lot better: for varints zstd compresses with ratio ~1.7-2.0 while it only compresses delta bitpacked data with ratio ~1.3. Therefore we potentially can disable zstd on benchmarks with a slight dataset size overhead.
dataset size
Overall, we reach approximately same dataset size. For some envs there is a small benefit of around -3% of total dataset.
Search latency (stg fractions repacked with bitpack)
Fixes #312