Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pebble/cmd/pebble/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ package main
import (
"fmt"
"log"
rand "math/rand/v2"
"sync"
"sync/atomic"
"time"

"github.com/cockroachdb/pebble"
"github.com/cockroachdb/pebble/internal/randvar"
"github.com/spf13/cobra"
"golang.org/x/exp/rand"
)

var queueConfig struct {
Expand Down Expand Up @@ -42,7 +42,7 @@ func queueTest() (test, *atomic.Int64) {
init: func(d DB, wg *sync.WaitGroup) {
var (
value []byte
rng = rand.New(rand.NewSource(1449168817))
rng = rand.New(rand.NewPCG(0, 1449168817))
queue = make([][]byte, queueConfig.size)
)
for i := 0; i < queueConfig.size; i++ {
Expand Down
8 changes: 4 additions & 4 deletions pebble/cmd/pebble/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (
"fmt"
"log"
"math"
rand "math/rand/v2"
"sync"
"sync/atomic"
"time"

"github.com/cockroachdb/pebble"
"github.com/cockroachdb/pebble/internal/randvar"
"github.com/spf13/cobra"
"golang.org/x/exp/rand"
)

var scanConfig struct {
Expand Down Expand Up @@ -65,7 +65,7 @@ func runScan(cmd *cobra.Command, args []string) {
const count = 100000
const batch = 1000

rng := rand.New(rand.NewSource(1449168817))
rng := rand.New(rand.NewPCG(0, 1449168817))
keys := make([][]byte, count)

for i := 0; i < count; {
Expand Down Expand Up @@ -94,7 +94,7 @@ func runScan(cmd *cobra.Command, args []string) {
go func(i int) {
defer wg.Done()

rng := rand.New(rand.NewSource(uint64(i)))
rng := rand.New(rand.NewPCG(0, uint64(i)))
startKeyBuf := append(make([]byte, 0, 64), []byte("key-")...)
endKeyBuf := append(make([]byte, 0, 64), []byte("key-")...)
minTS := encodeUint64Ascending(nil, math.MaxUint64)
Expand All @@ -103,7 +103,7 @@ func runScan(cmd *cobra.Command, args []string) {
wait(limiter)

rows := int(rowDist.Uint64(rng))
startIdx := rng.Int31n(int32(len(keys) - rows))
startIdx := rng.Int32N(int32(len(keys) - rows))
startKey := encodeUint32Ascending(startKeyBuf[:4], uint32(startIdx))
endKey := encodeUint32Ascending(endKeyBuf[:4], uint32(startIdx+int32(rows)))

Expand Down
4 changes: 2 additions & 2 deletions pebble/cmd/pebble/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ package main
import (
"fmt"
"log"
rand "math/rand/v2"
"sync"
"sync/atomic"
"time"

"github.com/cockroachdb/pebble"
"github.com/cockroachdb/pebble/internal/randvar"
"github.com/spf13/cobra"
"golang.org/x/exp/rand"
)

var syncConfig struct {
Expand Down Expand Up @@ -66,7 +66,7 @@ func runSync(cmd *cobra.Command, args []string) {
go func() {
defer wg.Done()

rand := rand.New(rand.NewSource(uint64(time.Now().UnixNano())))
rand := rand.New(rand.NewPCG(0, uint64(time.Now().UnixNano())))
var raw []byte
var buf []byte
var block []byte
Expand Down
3 changes: 0 additions & 3 deletions pebble/cmd/pebble/tombstone.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ func runTombstoneCmd(cmd *cobra.Command, args []string) error {

batchDist := ycsbConfig.batch
scanDist := ycsbConfig.scans
if err != nil {
return err
}

valueDist := ycsbConfig.values
y := newYcsb(weights, keyDist, batchDist, scanDist, valueDist)
Expand Down
5 changes: 1 addition & 4 deletions pebble/cmd/pebble/ycsb.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package main
import (
"fmt"
"log"
"math/rand/v2"
"strconv"
"strings"
"sync"
Expand All @@ -19,7 +20,6 @@ import (
"github.com/cockroachdb/pebble/internal/randvar"
"github.com/cockroachdb/pebble/internal/rate"
"github.com/spf13/cobra"
"golang.org/x/exp/rand"
)

const (
Expand Down Expand Up @@ -225,9 +225,6 @@ func runYcsb(cmd *cobra.Command, args []string) error {

batchDist := ycsbConfig.batch
scanDist := ycsbConfig.scans
if err != nil {
return err
}

valueDist := ycsbConfig.values
y := newYcsb(weights, keyDist, batchDist, scanDist, valueDist)
Expand Down
4 changes: 2 additions & 2 deletions pebble/commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/binary"
"fmt"
"io"
"math/rand/v2"
"sync"
"sync/atomic"
"testing"
Expand All @@ -19,7 +20,6 @@ import (
"github.com/cockroachdb/pebble/vfs"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/require"
"golang.org/x/exp/rand"
)

type testCommitEnv struct {
Expand Down Expand Up @@ -331,7 +331,7 @@ func BenchmarkCommitPipeline(b *testing.B) {
b.ResetTimer()

b.RunParallel(func(pb *testing.PB) {
rng := rand.New(rand.NewSource(uint64(time.Now().UnixNano())))
rng := rand.New(rand.NewPCG(0, uint64(time.Now().UnixNano())))
buf := make([]byte, keySize)

for pb.Next() {
Expand Down
16 changes: 8 additions & 8 deletions pebble/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"context"
"fmt"
"io"
"math/rand/v2"
"path/filepath"
"slices"
"strconv"
Expand All @@ -25,7 +26,6 @@ import (
"github.com/cockroachdb/pebble/sstable"
"github.com/cockroachdb/pebble/vfs"
"github.com/stretchr/testify/require"
"golang.org/x/exp/rand"
)

// try repeatedly calls f, sleeping between calls with exponential back-off,
Expand Down Expand Up @@ -311,12 +311,12 @@ func TestRandomWrites(t *testing.T) {
}
xxx := bytes.Repeat([]byte("x"), 512)

rng := rand.New(rand.NewSource(123))
rng := rand.New(rand.NewPCG(0, 123))
const N = 1000
for i := 0; i < N; i++ {
k := rng.Intn(len(keys))
if rng.Intn(20) != 0 {
wants[k] = rng.Intn(len(xxx) + 1)
k := rng.IntN(len(keys))
if rng.IntN(20) != 0 {
wants[k] = rng.IntN(len(xxx) + 1)
if err := d.Set(keys[k], xxx[:wants[k]], nil); err != nil {
t.Fatalf("i=%d: Set: %v", i, err)
}
Expand All @@ -327,7 +327,7 @@ func TestRandomWrites(t *testing.T) {
}
}

if i != N-1 || rng.Intn(50) != 0 {
if i != N-1 || rng.IntN(50) != 0 {
continue
}
for k := range keys {
Expand Down Expand Up @@ -930,7 +930,7 @@ func TestFlushEmpty(t *testing.T) {
}

func TestRollManifest(t *testing.T) {
toPreserve := rand.Int31n(5) + 1
toPreserve := rand.Int32N(5) + 1
opts := &Options{
MaxManifestFileSize: 1,
L0CompactionThreshold: 10,
Expand Down Expand Up @@ -1846,7 +1846,7 @@ func TestMemtableIngestInversion(t *testing.T) {
}

func BenchmarkDelete(b *testing.B) {
rng := rand.New(rand.NewSource(uint64(time.Now().UnixNano())))
rng := rand.New(rand.NewPCG(0, uint64(time.Now().UnixNano())))
const keyCount = 10000
var keys [keyCount][]byte
for i := 0; i < keyCount; i++ {
Expand Down
22 changes: 11 additions & 11 deletions pebble/external_iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"bytes"
"fmt"
"math"
"math/rand/v2"
"testing"
"time"

Expand All @@ -21,7 +22,6 @@ import (
"github.com/cockroachdb/pebble/sstable"
"github.com/cockroachdb/pebble/vfs"
"github.com/stretchr/testify/require"
"golang.org/x/exp/rand"
)

func TestExternalIterator(t *testing.T) {
Expand Down Expand Up @@ -151,13 +151,13 @@ func TestIterRandomizedMaybeFilteredKeys(t *testing.T) {
seed = uint64(time.Now().UnixNano())
t.Logf("seed: %d", seed)
}
rng := rand.New(rand.NewSource(seed))
numKeys := 100 + rng.Intn(5000)
rng := rand.New(rand.NewPCG(0, seed))
numKeys := 100 + rng.IntN(5000)
// The block property filter will exclude keys with suffixes [0, tsSeparator-1].
// We use the first "part" of the keyspace below to write keys >= tsSeparator,
// and the second part to write keys < tsSeparator. Successive parts (if any)
// will contain keys at random before or after the separator.
tsSeparator := 10 + rng.Int63n(5000)
tsSeparator := 10 + rng.Int64N(5000)
const keyLen = 5

// We split the keyspace into logical "parts" which are disjoint slices of the
Expand All @@ -166,8 +166,8 @@ func TestIterRandomizedMaybeFilteredKeys(t *testing.T) {
// predictable clustering of timestamps in sstable blocks, however it is not
// strictly necessary for this test.
alpha := testkeys.Alpha(keyLen)
numParts := rng.Intn(3) + 2
blockSize := 16 + rng.Intn(64)
numParts := rng.IntN(3) + 2
blockSize := 16 + rng.IntN(64)

c := cache.New(128 << 20)
defer c.Unref()
Expand Down Expand Up @@ -207,11 +207,11 @@ func TestIterRandomizedMaybeFilteredKeys(t *testing.T) {
for j := 0; j < maxKeysPerPart; j++ {
var ts int64
if i == 0 {
ts = rng.Int63n(5000) + tsSeparator
ts = rng.Int64N(5000) + tsSeparator
} else if i == 1 {
ts = rng.Int63n(tsSeparator)
ts = rng.Int64N(tsSeparator)
} else {
ts = rng.Int63n(tsSeparator + 5000)
ts = rng.Int64N(tsSeparator + 5000)
}
n := testkeys.WriteKeyAt(buf, alpha, keyIdx*alpha.Count()/int64(numKeys), ts)
keys = append(keys, append([]byte(nil), buf[:n]...))
Expand Down Expand Up @@ -251,7 +251,7 @@ func TestIterRandomizedMaybeFilteredKeys(t *testing.T) {
narrowBoundsMode := false

for i := 0; i < 10000; i++ {
if rng.Intn(8) == 0 {
if rng.IntN(8) == 0 {
// Toggle narrow bounds mode.
if narrowBoundsMode {
// Reset bounds.
Expand All @@ -260,7 +260,7 @@ func TestIterRandomizedMaybeFilteredKeys(t *testing.T) {
}
narrowBoundsMode = !narrowBoundsMode
}
keyIdx := rng.Intn(len(keys))
keyIdx := rng.IntN(len(keys))
seekKey := keys[keyIdx]
if narrowBoundsMode {
// Case 1: We just entered narrow bounds mode, and both bounds
Expand Down
61 changes: 31 additions & 30 deletions pebble/go.mod
Original file line number Diff line number Diff line change
@@ -1,49 +1,50 @@
module github.com/cockroachdb/pebble

replace github.com/cockroachdb/pebble => ../pebble

require (
github.com/DataDog/zstd v1.4.5
github.com/HdrHistogram/hdrhistogram-go v1.1.2
github.com/cespare/xxhash/v2 v2.2.0
github.com/HdrHistogram/hdrhistogram-go v1.2.0
github.com/cespare/xxhash/v2 v2.3.0
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f
github.com/cockroachdb/errors v1.11.1
github.com/cockroachdb/metamorphic v0.0.0-20231108215700-4ba948b56895
github.com/cockroachdb/redact v1.1.5
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06
github.com/cockroachdb/errors v1.12.0
github.com/cockroachdb/metamorphic v0.0.0-20231120015718-884f2746775a
github.com/cockroachdb/redact v1.1.6
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb
github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9
github.com/golang/snappy v0.0.4
github.com/guptarohit/asciigraph v0.5.5
github.com/klauspost/compress v1.15.15
github.com/golang/snappy v1.0.0
github.com/guptarohit/asciigraph v0.7.3
github.com/klauspost/compress v1.18.1
github.com/kr/pretty v0.3.1
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.0
github.com/prometheus/client_golang v1.12.0
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df
golang.org/x/perf v0.0.0-20230113213139-801c7ef9e5c5
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
golang.org/x/sys v0.11.0
github.com/prometheus/client_golang v1.23.2
github.com/prometheus/client_model v0.6.2
github.com/spf13/cobra v1.10.1
github.com/stretchr/testify v1.11.1
golang.org/x/perf v0.0.0-20251112180420-cfbd823f7301
golang.org/x/sync v0.18.0
golang.org/x/sys v0.38.0
)

require (
github.com/aclements/go-moremath v0.0.0-20210112150236-f10218a38794 // indirect
github.com/aclements/go-moremath v0.0.0-20241023150245-c8bbc672ef66 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
github.com/getsentry/sentry-go v0.38.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/prometheus/common v0.67.4 // indirect
github.com/prometheus/procfs v0.19.2 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/spf13/pflag v1.0.10 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
golang.org/x/text v0.31.0 // indirect
google.golang.org/protobuf v1.36.10 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

go 1.21
go 1.24.0
Loading