This commit is contained in:
Andy Aragon 2026-02-04 04:54:57 +07:00 committed by GitHub
commit 2cb2f8b34c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 6 deletions

View file

@ -318,15 +318,21 @@ kvobj *lookupKey(redisDb *db, robj *key, int flags, dictEntryLink *link) {
}
}
if (!(flags & (LOOKUP_NOSTATS | LOOKUP_WRITE)))
server.stat_keyspace_hits++;
/* TODO: Use separate hits stats for WRITE */
if (!(flags & LOOKUP_NOSTATS)) {
if (flags & LOOKUP_WRITE)
server.stat_keyspace_write_hits++;
else
server.stat_keyspace_hits++;
}
} else {
if (!(flags & (LOOKUP_NONOTIFY | LOOKUP_WRITE)))
notifyKeyspaceEvent(NOTIFY_KEY_MISS, "keymiss", key, db->id);
if (!(flags & (LOOKUP_NOSTATS | LOOKUP_WRITE)))
server.stat_keyspace_misses++;
/* TODO: Use separate misses stats and notify event for WRITE */
if (!(flags & LOOKUP_NOSTATS)) {
if (flags & LOOKUP_WRITE)
server.stat_keyspace_write_misses++;
else
server.stat_keyspace_misses++;
}
}
return val;

View file

@ -2802,6 +2802,8 @@ void resetServerStats(void) {
server.stat_last_eviction_exceeded_time = 0;
server.stat_keyspace_misses = 0;
server.stat_keyspace_hits = 0;
server.stat_keyspace_write_hits = 0;
server.stat_keyspace_write_misses = 0;
server.stat_active_defrag_hits = 0;
server.stat_active_defrag_misses = 0;
server.stat_active_defrag_key_hits = 0;
@ -6519,6 +6521,8 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
"current_eviction_exceeded_time:%lld\r\n", current_eviction_exceeded_time / 1000,
"keyspace_hits:%lld\r\n", server.stat_keyspace_hits,
"keyspace_misses:%lld\r\n", server.stat_keyspace_misses,
"keyspace_write_hits:%lld\r\n", server.stat_keyspace_write_hits,
"keyspace_write_misses:%lld\r\n", server.stat_keyspace_write_misses,
"pubsub_channels:%llu\r\n", kvstoreSize(server.pubsub_channels),
"pubsub_patterns:%lu\r\n", dictSize(server.pubsub_patterns),
"pubsubshard_channels:%llu\r\n", kvstoreSize(server.pubsubshard_channels),

View file

@ -2046,6 +2046,8 @@ struct redisServer {
monotime stat_last_eviction_exceeded_time; /* Timestamp of current eviction start, unit us */
long long stat_keyspace_hits; /* Number of successful lookups of keys */
long long stat_keyspace_misses; /* Number of failed lookups of keys */
long long stat_keyspace_write_hits; /* Number of successful write lookups */
long long stat_keyspace_write_misses; /* Number of failed write lookups */
long long stat_active_defrag_hits; /* number of allocations moved */
long long stat_active_defrag_misses; /* number of allocations scanned but not moved */
long long stat_active_defrag_key_hits; /* number of keys with moved allocations */