Skip to content

Commit b20b514

Browse files
Jaesoo Leefacebook-github-bot
authored andcommitted
fix bug in printing eviction success rate
Summary: This change fixes below bug printing wrong eviction success rate. Evict Attempts: 439,372 Success: -4198434145486952.50% RAM Evictions : 618,369 This happens because of the overflow in below code https://fburl.com/code/ln24ozv0 ``` out << folly::sformat( "Evict Attempts: {:,} Success: {:.2f}%", evictAttempts, invertPctFn(evictAttempts - numEvictions, evictAttempts) ``` Again, this could happen because evictAttempts and numEvictions are not taken atomically https://fburl.com/code/i587dhfh Reviewed By: therealgymmy Differential Revision: D46043428 fbshipit-source-id: 022a07e09c1093ca705e9e57596fa912497ba32d
1 parent ad0b378 commit b20b514

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

cachelib/cachebench/cache/CacheStats.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,9 @@ struct Stats {
118118
allocAttempts,
119119
invertPctFn(allocFailures, allocAttempts))
120120
<< std::endl;
121-
out << folly::sformat(
122-
"Evict Attempts: {:,} Success: {:.2f}%",
123-
evictAttempts,
124-
invertPctFn(evictAttempts - numEvictions, evictAttempts))
121+
out << folly::sformat("Evict Attempts: {:,} Success: {:.2f}%",
122+
evictAttempts,
123+
pctFn(numEvictions, evictAttempts))
125124
<< std::endl;
126125
out << folly::sformat("RAM Evictions : {:,}", numEvictions) << std::endl;
127126

0 commit comments

Comments
 (0)