v1.4.3
Fixed
-
Cache Associativity Bug (Critical)
findVictim()now prefers empty (invalid) blocks before consulting the replacement policy- Previously the cache used only 1 way per set regardless of associativity, causing hit ratio to decrease with increasing associativity
getTagAndSet()now uses standard tag decomposition (tag = blockNumber / numSets) instead of storing the full block number as the tag, fixing incorrect writeback addresses
-
PLRU Replacement Policy
- Replaced floating-point
std::log2()with integer bit-scan loop to prevent silent truncation (e.g.log2(8)returning2.999→2) - Added power-of-2 assertion in constructor since the tree structure requires it
- Added missing
#include <cassert>
- Replaced floating-point
-
Victim Cache
getAllValidAddresses()- Replaced
std::transform+std::remove(0)with a simple validity-checked loop - Previously, a legitimate cache block at address 0 would be silently dropped
- Replaced
-
Victim Cache
invalidateBlocksInRange()- Changed from
std::remove_if+erase(which physically removes elements) to in-place invalidation - The old approach corrupted
fifoQueueandaddressToIndexindices, causing incorrect evictions or crashes on subsequent operations
- Changed from
Changed
- Dead Code Removal: Removed unused
lruOrder,fifoOrder, andnextFifoIndexfields fromCacheSetincache_block.hand their initialization incache.cpp— all replacement logic usesReplacementPolicyBaseinstances - Namespace Cleanup: Moved
VictimBlockandVictimCacheintonamespace cachesim; removed deadCacheSimulatordemo class fromvictim_cache.h - Code Simplification: Removed stale "FIXED"/"SOLUTION" comments from
victim_cache.hper code-simplifier guidelines - Version updated to v1.4.3 in CLI, CMakeLists.txt, CITATION.cff, and documentation
Added
- Associativity Test: New
tests/unit/core/associativity_test.cppverifying that hit ratio is monotonically non-decreasing as associativity increases - Cache Analysis Tool: New
tools/cache_analysis.cppto visualize hit rate vs associativity and verify fix effectiveness
Documentation
- Updated
README.md"What's New" section for v1.4.3 - Updated
docs/developer/architecture.md— correctedCacheSetdescription and refreshed Future Extensions - Updated
docs/features/replacement-policies.md— added PLRU power-of-2 requirement note - Updated
docs/features/victim-cache.md— code examples now reflectcachesimnamespace
Technical Details
- All coherence protocols (MSI, MESI, MOESI) were audited and verified correct
- All 20 tests pass (unit, integration, performance)