Skip to content

Commit

Permalink
Merge branch 'v2' into growable-read-buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
maypok86 committed Sep 15, 2024
2 parents 7133b0c + 0e7b832 commit 6553764
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
8 changes: 0 additions & 8 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ you must be able to justify that.
#### Stylistic guide (mandatory)

- [ ] My code complies with the [styles guide](https://github.com/uber-go/guide/blob/master/style.md).
- [ ] My commit history is clean (only contains changes relating to my
issue/pull request and no reverted-my-earlier-commit changes) and commit
messages start with identifiers of related issues in square brackets.

**Example:** `[#42] Short commit description`

If necessary both of these can be achieved even after the commits have been
made/pushed using [rebase and squash](https://git-scm.com/docs/git-rebase).

#### Before merging (mandatory)
- [ ] Check __target__ branch of PR is set correctly
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ jobs:
- name: lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
version: v1.61.0
args: --timeout=4m -v --out-${NO_FUTURE}format colored-line-number
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ run:
build-tags:
- integration
modules-download-mode: readonly
go: '1.17'
go: '1.19'
output:
formats:
- format: tab
Expand Down
6 changes: 6 additions & 0 deletions cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,12 @@ func TestCache_Ratio(t *testing.T) {
t.Logf("actual size: %d, capacity: %d", c.Size(), capacity)
t.Logf("actual: %.2f, optimal: %.2f", statsCounter.Snapshot().HitRatio(), o.Ratio())

time.Sleep(2 * time.Second)

if size := c.Size(); size != capacity {
t.Fatalf("not valid cache size. expected %d, but got %d", capacity, size)
}

mutex.Lock()
defer mutex.Unlock()
t.Logf("evicted: %d", m[CauseOverflow])
Expand Down
1 change: 0 additions & 1 deletion scripts/deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ bash -s -- -b "$(go env GOPATH)"/bin v1.61.0

go install github.com/daixiang0/gci@latest
GO111MODULE=on go install mvdan.cc/gofumpt@latest
go install github.com/golang/mock/mockgen@latest
8 changes: 4 additions & 4 deletions stats/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Counter struct {
misses *xsync.Adder
evictions *xsync.Adder
evictionWeight *xsync.Adder
rejectedSets *xsync.Adder
rejections *xsync.Adder
loadSuccesses *xsync.Adder
loadFailures *xsync.Adder
totalLoadTime *xsync.Adder
Expand All @@ -40,7 +40,7 @@ func NewCounter() *Counter {
misses: xsync.NewAdder(),
evictions: xsync.NewAdder(),
evictionWeight: xsync.NewAdder(),
rejectedSets: xsync.NewAdder(),
rejections: xsync.NewAdder(),
loadSuccesses: xsync.NewAdder(),
loadFailures: xsync.NewAdder(),
totalLoadTime: xsync.NewAdder(),
Expand All @@ -62,7 +62,7 @@ func (c *Counter) Snapshot() Stats {
misses: c.misses.Value(),
evictions: c.evictions.Value(),
evictionWeight: c.evictionWeight.Value(),
rejections: c.rejectedSets.Value(),
rejections: c.rejections.Value(),
loadSuccesses: c.loadSuccesses.Value(),
loadFailures: c.loadFailures.Value(),
//nolint:gosec // overflow is handled above
Expand Down Expand Up @@ -93,7 +93,7 @@ func (c *Counter) RecordEviction(weight uint32) {
// RecordRejections records rejections of entries. Cache rejects entries only if they have too much weight.
func (c *Counter) RecordRejections(count int) {
//nolint:gosec // there is no overflow
c.rejectedSets.Add(uint64(count))
c.rejections.Add(uint64(count))
}

// RecordLoadSuccess records the successful load of a new entry. This method should be called when a cache request
Expand Down

0 comments on commit 6553764

Please sign in to comment.