Compare commits
4 Commits
v0.2.0
...
521b38c550
| Author | SHA1 | Date | |
|---|---|---|---|
|
521b38c550
|
|||
|
cbe4483326
|
|||
|
3bb663dc8b
|
|||
|
db2dfb466b
|
@@ -7,20 +7,20 @@ body:
|
||||
id: context
|
||||
attributes:
|
||||
label: Context
|
||||
placeholder: What circumstances led to the bug?
|
||||
description: What circumstances led to the bug?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected-behavior
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
placeholder: What did you expect would happen?
|
||||
description: What did you expect would happen?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: actual-behavior
|
||||
attributes:
|
||||
label: Actual Behavior
|
||||
placeholder: What happened, and why was it unexpected?
|
||||
description: What happened, and why was it unexpected?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
@@ -6,10 +6,18 @@ name: ✨ Feature Request
|
||||
about: Suggest an idea for this project
|
||||
title: "[FEATURE]: "
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this feature request! 🤗
|
||||
|
||||
Please make sure this feature request hasn't been already submitted by
|
||||
someone by looking through other open/closed issues. 😃
|
||||
- type: dropdown
|
||||
attributes:
|
||||
multiple: false
|
||||
label: Feature Type
|
||||
label: Type of Feature
|
||||
description: Select the type of feature request.
|
||||
options:
|
||||
- "✨ New Feature"
|
||||
- "📝 Documentation"
|
||||
@@ -23,7 +31,7 @@ body:
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
placeholder: |
|
||||
description: |
|
||||
Give us a brief description of the feature or enhancement you would
|
||||
like!
|
||||
validations:
|
||||
@@ -32,6 +40,6 @@ body:
|
||||
id: additional-information
|
||||
attributes:
|
||||
label: Additional Information
|
||||
placeholder: |
|
||||
description: |
|
||||
Give us some additional information on the feature request like proposed
|
||||
solutions, links, screenshots, etc.
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# yaml-language-server: $schema=https://www.schemastore.org/gitea-issue-config.json
|
||||
blank_issues_enabled: false
|
||||
blank_issues_enabled: true
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
name: "New Pull Request"
|
||||
about: "Standard PR template"
|
||||
title: ""
|
||||
ref: "main"
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
## Changes
|
||||
|
||||
### Design Decisions
|
||||
|
||||
## Checklist
|
||||
|
||||
- [ ] Tests pass
|
||||
- [ ] Docs updated
|
||||
@@ -9,12 +9,10 @@ jobs:
|
||||
check-pr-title:
|
||||
name: Check PR Title
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'pull_request'
|
||||
env:
|
||||
TITLE: ${{ gitea.event.pull_request.title }}
|
||||
steps:
|
||||
- run: |
|
||||
if ! echo "$TITLE" | grep -qE '^(WIP: )?(feat|fix|docs|chore|ci|test|refactor|perf|build|style|revert)(\(.+\))?(!)?: .+'; then
|
||||
TITLE="${{ gitea.event.pull_request.title }}"
|
||||
if ! echo "$TITLE" | grep -qE '^(feat|fix|docs|chore|ci|test|refactor|perf|build|style|revert)(\(.+\))?(!)?: .+'; then
|
||||
echo "::error::Pull Request title must follow conventional commits"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -3,6 +3,7 @@ package cuckoo_test
|
||||
import (
|
||||
"fmt"
|
||||
"maps"
|
||||
"math"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@@ -29,6 +30,7 @@ type fuzzStep struct {
|
||||
type fuzzScenario struct {
|
||||
seedA, seedB uint32
|
||||
capacity, growthFactor uint8
|
||||
load float64
|
||||
steps []fuzzStep
|
||||
}
|
||||
|
||||
@@ -46,6 +48,7 @@ func FuzzInsertLookup(f *testing.F) {
|
||||
seedA, seedB := scenario.seedA, scenario.seedB
|
||||
growthFactor := max(2, int(scenario.growthFactor))
|
||||
capacity := int(scenario.capacity)
|
||||
minimumLoad := math.Abs(math.Mod(scenario.load, 1.0))
|
||||
|
||||
// If they are the same number, the hashes will clash, always causing an
|
||||
// error.
|
||||
@@ -53,8 +56,14 @@ func FuzzInsertLookup(f *testing.F) {
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stderr, "seedA=%d seedB=%d capacity=%d growthFactor=%d\n",
|
||||
seedA, seedB, capacity, growthFactor)
|
||||
// If the load is too high, the hashs will not be able to allocate
|
||||
// properly.
|
||||
if minimumLoad > 0.20 {
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stderr, "seedA=%d seedB=%d capacity=%d growthFactor=%d minimumLoad=%f\n",
|
||||
seedA, seedB, capacity, growthFactor, minimumLoad)
|
||||
|
||||
actual := cuckoo.NewCustomTable[uint32, uint32](
|
||||
offsetHash(seedA),
|
||||
@@ -62,6 +71,7 @@ func FuzzInsertLookup(f *testing.F) {
|
||||
func(a, b uint32) bool { return a == b },
|
||||
cuckoo.Capacity(capacity),
|
||||
cuckoo.GrowthFactor(growthFactor),
|
||||
cuckoo.MinimumLoad(minimumLoad),
|
||||
)
|
||||
|
||||
expected := map[uint32]uint32{}
|
||||
|
||||
20
settings.go
20
settings.go
@@ -12,12 +12,11 @@ const DefaultCapacity uint64 = 16
|
||||
// hash table implementations use 2.
|
||||
const DefaultGrowthFactor uint64 = 2
|
||||
|
||||
// defaultMinimumLoad is the default lowest acceptable occupancy of a [Table].
|
||||
// The higher the minimum load, the more likely that a [Table.Put] will not
|
||||
// succeed. The value of 5% is taken from [libcuckoo].
|
||||
// DefaultMinimumLoad is the default lowest acceptable occupancy of a [Table].
|
||||
// The value of 5% is taken from [libcuckoo].
|
||||
//
|
||||
// [libcuckoo]: https://github.com/efficient/libcuckoo/blob/656714705a055df2b7a605eb3c71586d9da1e119/libcuckoo/cuckoohash_config.hh#L21
|
||||
const defaultMinimumLoad float64 = 0.05
|
||||
const DefaultMinimumLoad float64 = 0.05
|
||||
|
||||
type settings struct {
|
||||
growthFactor uint64
|
||||
@@ -39,6 +38,19 @@ func Capacity(value int) Option {
|
||||
return func(s *settings) { s.bucketSize = uint64(value) }
|
||||
}
|
||||
|
||||
// MinimumLoad modifies the [DefaultMinimumLoad] of the [Table]. The value must
|
||||
// be between 0.00 and 1.00.
|
||||
//
|
||||
// The higher the minimum load, the more likely that a [Table.Put] will not
|
||||
// succeed. Minimum loads above 20% are not tested.
|
||||
func MinimumLoad(value float64) Option {
|
||||
if value < 0.00 || value > 1.00 {
|
||||
panic(fmt.Sprintf("go-cuckoo: MinimumLoad must be between 0.00 and 1.00, got %f", value))
|
||||
}
|
||||
|
||||
return func(s *settings) { s.minLoadFactor = value }
|
||||
}
|
||||
|
||||
// GrowthFactor controls how much the capacity of the [Table] multiplies when
|
||||
// it must resize. The value must be greater than 1.
|
||||
func GrowthFactor(value int) Option {
|
||||
|
||||
2
table.go
2
table.go
@@ -198,7 +198,7 @@ func NewCustomTable[K, V any](hashA, hashB Hash[K], compare EqualFunc[K], option
|
||||
settings := &settings{
|
||||
growthFactor: DefaultGrowthFactor,
|
||||
bucketSize: DefaultCapacity,
|
||||
minLoadFactor: defaultMinimumLoad,
|
||||
minLoadFactor: DefaultMinimumLoad,
|
||||
}
|
||||
|
||||
for _, option := range options {
|
||||
|
||||
Reference in New Issue
Block a user