Skip to content

Commit

Permalink
cache: only sometimes perform metaCheck invariant checks
Browse files Browse the repository at this point in the history
In invariants builds, perform the invariant checks in metaCheck only 1% of the
time. In a Cockroach runtime-assertion roachtest performing an import, these
checks consumed 40% of CPU.
  • Loading branch information
jbowens committed Jan 22, 2025
1 parent 02e24de commit d151d6d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/cache/clockpro.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func (c *shard) metaDel(e *entry) (deletedValue *Value) {

// Check that the specified entry is not referenced by the cache.
func (c *shard) metaCheck(e *entry) {
if invariants.Enabled {
if invariants.Enabled && invariants.Sometimes(1) {
if _, ok := c.entries[e]; ok {
fmt.Fprintf(os.Stderr, "%p: %s unexpectedly found in entries map\n%s",
e, e.key, debug.Stack())
Expand Down

0 comments on commit d151d6d

Please sign in to comment.