-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(generators): address problem when size ot pk is too small
When pk is too small gemini had number of problems: 1. If it is one byte size, then generators are iterating over 0-255, while most of them in flights, load threads are getting stuck on waiting for valies, while generators can't provide new one 2. Murmur to get 100% partition coverage as result some partitions are not getting data while load threads still target them making treads stuck forever
- Loading branch information
Dmitry Kropachev
committed
Jul 17, 2023
1 parent
d351b0e
commit 420a85c
Showing
13 changed files
with
307 additions
and
44 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2019 ScyllaDB | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package realrandom | ||
|
||
import ( | ||
crand "crypto/rand" | ||
"encoding/binary" | ||
"math/bits" | ||
"time" | ||
|
||
"golang.org/x/exp/rand" | ||
) | ||
|
||
var Source rand.Source | ||
|
||
type crandSource struct{} | ||
|
||
func (c *crandSource) Uint64() uint64 { | ||
var out [8]byte | ||
_, _ = crand.Read(out[:]) | ||
return binary.LittleEndian.Uint64(out[:]) | ||
} | ||
|
||
func (c *crandSource) Seed(_ uint64) {} | ||
|
||
type TimeSource struct { | ||
source rand.Source | ||
} | ||
|
||
func NewTimeSource() *TimeSource { | ||
now := time.Now() | ||
return &TimeSource{ | ||
source: rand.NewSource(uint64(now.Nanosecond() * now.Second())), | ||
} | ||
} | ||
|
||
func (c *TimeSource) Uint64() uint64 { | ||
now := time.Now() | ||
val := c.source.Uint64() | ||
return bits.RotateLeft64(val^uint64(now.Nanosecond()*now.Second()), -int(val>>58)) | ||
} | ||
|
||
func (c *TimeSource) Seed(_ uint64) {} | ||
|
||
func init() { | ||
var b [8]byte | ||
_, err := crand.Read(b[:]) | ||
if err == nil { | ||
Source = &crandSource{} | ||
} else { | ||
Source = NewTimeSource() | ||
} | ||
} |
Oops, something went wrong.