Files
magpie/internal/usage/msgkey_test.go
T
yetone e3f1efdaac usage: a message id's pairing key is 16 bytes, not 24
msgKeysOf keeps each chunk's message ids as hashes, with the row, for
every chunk a pairing reads. The key was two 64-bit hashes and an
int32, padded to 24 bytes. It is now a 64-bit and a 32-bit hash with
the row, 16 bytes: two of a long history's ~300k ids alike in all 96
bits is ~1e-18 likely.

Run on mote at this head:
- go test ./internal/usage: ok (28.8s)
- GOOS=darwin/linux/windows go vet ./internal/usage: ok
- gofmt -l: clean
- Broken by hand: with the second hash back at 64 bits,
  TestMsgKeySize is red (24 bytes).
- Real-account copy (~/r2278/acct), idle heap at 180s, v0.1.3404's
  tree vs this: appendMsgKeys 6.49 MB -> 3.69 MB, inuse 103.0 MB ->
  97.8 MB, Footprint 154 MB.
2026-11-09 19:58:17 +08:00

15 lines
317 B
Go

package usage
import (
"testing"
"unsafe"
)
// TestMsgKeySize: a long history keeps ~300k of these per pairing, so a
// field that pads it past 16 bytes is a third more of them held.
func TestMsgKeySize(t *testing.T) {
if n := unsafe.Sizeof(msgKey{}); n != 16 {
t.Fatalf("msgKey is %d bytes, want 16", n)
}
}