Cache a diversity value with LRU eviction
(self, code_hash: int, diversity: float)
| 2153 | ) |
| 2154 | |
| 2155 | def _cache_diversity_value(self, code_hash: int, diversity: float) -> None: |
| 2156 | """Cache a diversity value with LRU eviction""" |
| 2157 | # Check if cache is full |
| 2158 | if len(self.diversity_cache) >= self.diversity_cache_size: |
| 2159 | # Remove oldest entry |
| 2160 | oldest_hash = min(self.diversity_cache.items(), key=lambda x: x[1]["timestamp"])[0] |
| 2161 | del self.diversity_cache[oldest_hash] |
| 2162 | |
| 2163 | # Add new entry |
| 2164 | self.diversity_cache[code_hash] = {"value": diversity, "timestamp": time.time()} |
| 2165 | |
| 2166 | def _invalidate_diversity_cache(self) -> None: |
| 2167 | """Invalidate the diversity cache when programs change significantly""" |
no outgoing calls
no test coverage detected