Beispiel #1
0
    def __init__(self, cache_size, min_obj_size, max_obj_size):

        # L1 caches objects that have been seen exactly once recently
        # L2 caches objects that have been seen at least twice recently
        # the top parts of L1 and L2 contain the objects that are currently cached
        # we only need the top and bottom parts of lists L1 and L2
        self._top1 = OrderedDict()
        self._bottom1 = OrderedDict()
        self._top2 = OrderedDict()
        self._bottom2 = OrderedDict()
        # cache_size in bytes
        self._max_size = cache_size
        # used_size = top1_size + top2_size
        self._used_size = 0
        self._top1_size = 0
        self._bottom1_size = 0
        self._bottom2_size = 0
        # average object size in bytes
        #self._avg_obj_size = (max_obj_size + min_obj_size) / 2
        # cache specific parameter: target size for top1 (as fraction of cache size)
        self._p = 0.
        # in ARC cache p is incremented (or decremented) by 1 and p in {0, 1, ..., c} where c = cache size in pages;
        # since here p in {0, ..., 1}, p must be incremented (or decremented) by 1/c, but instead of cache size in
        # pages we use cache size in avg_objects
        #self._step = self._avg_obj_size / cache_size
        # stats
        self.stats = CacheStats.CacheStats("ARC", cache_size)
        self.daily_stats = CacheStats.DailyCacheStats(cache_size)
Beispiel #2
0
    def __init__(self, cache_size, min_obj_size, max_obj_size):
        """
            cache_size in bytes.
        """
        self._max_size = cache_size
        self._used_size = 0

        # a dict that preserves the order of inserts
        self._cached_objects = OrderedDict()

        self.stats = CacheStats.CacheStats("Fifo", cache_size)
        self.daily_stats = CacheStats.DailyCacheStats(cache_size)
Beispiel #3
0
    def __init__(self, cache_size, min_obj_size, max_obj_size):

        """
            cache_size in bytes.
        """
        self._max_size = cache_size
        self._used_size = 0

        self._cached_objects = RandomChoiceDict()

        self.stats = CacheStats.CacheStats("Fifo", cache_size)
        self.daily_stats = CacheStats.DailyCacheStats(cache_size)
Beispiel #4
0
    def __init__(self, cache_size, min_obj_size, max_obj_size):

        self._max_size = cache_size
        self._used_size = 0
        # dictionary: obj_id -> object with last and next caching time
        self._cached_objects = {}
        # AVL tree: next_time -> object with last and next caching time
        self._tree = AVLTree()
        self._oldest_obj_id = None
        self._freshest_obj_id = None

        self.stats = CacheStats.CacheStats("Belady", cache_size)
        self.daily_stats = CacheStats.DailyCacheStats(cache_size)
Beispiel #5
0
    def __init__(self, cache_size, min_obj_size, max_obj_size):
        """
            cache_size in bytes.
        """
        self._max_size = cache_size
        self._used_size = 0

        # obj_id -> last_atime
        self._cached_objects = {}

        self._oldest_obj_id = None
        self._freshest_obj_id = None

        self.stats = CacheStats.CacheStats("LRU2ND", cache_size)
        self.daily_stats = CacheStats.DailyCacheStats(cache_size)
Beispiel #6
0
    def __init__(self, cache_size, min_obj_size, max_obj_size):

        """
            cache_size in bytes.
        """
        self._max_size = cache_size

        self.stats = CacheStats.CacheStats("LRU", cache_size)
        self.daily_stats = CacheStats.DailyCacheStats(cache_size)

        ts = int(time.time())

        get_size = int(0.333333 * cache_size)
        put_size = int(0.666666 * cache_size)
        self.get_lru = LRUCache(get_size, 0, 0)
        self.put_fifo = LRUCache(put_size, 0, 0)