masaori335 commented on code in PR #13785:
URL: https://github.com/apache/trafficserver/pull/13785#discussion_r4203719065
##########
src/iocore/cache/unit_tests/test_RamCacheCLFUS.cc:
##########
@@ -375,3 +375,20 @@ TEST_CASE("CLFUS compression backends compiled in",
"[cache][ramcache][compress]
#endif
CHECK(compression_cases().size() >= 3);
}
+
+// Guards against PR #11733-style regressions of the CLFUS value metric: the
value density
+// must be computed in floating point. Integer division truncates (hits + 1) /
(size + overhead)
+// to 0 for normal object sizes, zeroing the metric and silently collapsing
CLFUS to FIFO (no
+// promote-on-hit, no clock second chance, no value-based ghost re-admission).
+TEST_CASE("CLFUS value metric is a floating-point density",
"[cache][ramcache][clfus]")
+{
+ constexpr double v_one = RamCacheCLFUS::cache_value_hits_size(1u, 16384u);
// a typical 16 KiB object, seen once
+ constexpr double v_hot = RamCacheCLFUS::cache_value_hits_size(100u,
16384u); // same size, many more hits
+ constexpr double v_small = RamCacheCLFUS::cache_value_hits_size(10u, 1024u);
// smaller object, equal hits
+ constexpr double v_large = RamCacheCLFUS::cache_value_hits_size(10u, 16384u);
+
+ // A non-zero fraction: the integer-division regression makes this exactly
0.0.
+ STATIC_REQUIRE(v_one > 0.0);
Review Comment:
Fixed by
[da253b2](https://github.com/apache/trafficserver/pull/13785/commits/da253b2909512c6af0b851bda3b6a2140d82bb31).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]