dgraph-io / ristretto

A high performance memory-bound Go cache

Home Page:https://dgraph.io/blog/post/introducing-ristretto-high-perf-go-cache/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG]: <sync.Pool GC>

AyangHuang opened this issue · comments

What version of Ristretto are you using?

  • The pool in the ringBuffer structure in the ring.go source file will completely release the objects in the pool after two GCs. Causes modifications in the cached setbuf to be lost.

The next is sync.Pool source file.

// go/src/sync/pool.go

func init() {
	runtime_registerPoolCleanup(poolCleanup)
}

func poolCleanup() {
	// This function is called with the world stopped, at the beginning of a garbage collection.
	// It must not allocate and probably should not call any runtime functions.

	// Because the world is stopped, no pool user can be in a
	// pinned section (in effect, this has all Ps pinned).

	// Drop victim caches from all pools.
	for _, p := range oldPools {
		p.victim = nil
		p.victimSize = 0
	}

	// Move primary cache to victim cache.
	for _, p := range allPools {
		p.victim = p.local
		p.victimSize = p.localSize
		p.local = nil
		p.localSize = 0
	}

	// The pools with non-empty primary caches now have non-empty
	// victim caches and no pools have primary caches.
	oldPools, allPools = allPools, nil
}

What version of Go are you using?

none

Have you tried reproducing the issue with the latest release?

None

What is the hardware spec (RAM, CPU, OS)?

none

What steps will reproduce the bug?

none

Expected behavior and actual result.

none

Additional information

none