You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
Mert Ovun
committed
groupcache: populate hotCache based on reported peer QPS
Previously, getFromPeer mirrored a remotely fetched value into the
hotCache on a fixed 10% of fetches, chosen at random. This was a
placeholder (noted in a TODO) and is a poor signal: it pollutes the
hotCache with one-off keys while taking ~10 round trips on average to
mirror a genuinely hot key, defeating the purpose of the hotCache.
Use the value's owner as the authority on hotness instead. The owner
tracks a per-key request rate using an exponentially weighted moving
average and reports it in the GetResponse.MinuteQps field (which the
wire format already carried but nobody populated). A non-owning peer
mirrors a key into its hotCache only once the owner reports a rate at
or above hotQPS.
The per-key rate state lives inside the mainCache entry, so it is
bounded by cache residency and cleaned up by ordinary eviction, with
no separate accounting to evict.
This replaces the test-only *rand.Rand hook (added in #175) with an
injectable clock, which TestPeers and the new stats tests use to drive
QPS deterministically.
0 commit comments