zoukankan      html  css  js  c++  java
  • Cache Algorithms

    1. 平均内存引用时间

    Taverage memory reference time

    mmiss ratio = 1 - (hit ratio)

    Tmtime to make a main memory access when there is a miss (or, with multi-level cache, average memory reference time for the next-lower cache)

    Th =  the latency: the time to reference the cache when there is a hit

    Evarious secondary effects, such as queuing effects in multiprocessor systems

    平均内存引用时间 = 丢失率 * 丢失时加入时间 + 命中时引用时间(延迟) + 多种次要影响(比如多级处理器排队等待时间)

    参考 https://en.wikipedia.org/wiki/Cache_algorithms

    2. 替换算法

    关键词:research 、 traditional 、 大内存 、 遍历周期

    OPT (The theoretically optimal page replacement algorithm) 

    This algorithm cannot be implemented in a general purpose operating system because it is impossible to compute reliably how long it will be before a page is going to be used, except when all software that will run on a system is either known beforehand and is amenable to static analysis of its memory reference patterns, or only a class of applications allowing run-time analysis.

    无法实现

    NRU (Not recently used)

    It is an algorithm that favours keeping pages in memory that have been recently used.

    3. referenced, modified
    2. referenced, not modified
    1. not referenced, modified
    0. not referenced, not modified

    从最低级(0级)选择随机页删除

    FIFO (First-in, first-out)

    最简单的页替换算法,可用List和LinkedHashMap 实现

    LRU (The least recently used)

    LRU works on the idea that pages that have been most heavily used in the past few instructions are most likely to be used heavily in the next few instructions too.

    在前面几条指令中使用频繁的页面很可能在后面的几条指令中频繁使用。

    反过来说,已经很久没有使用的页面很可能在未来较长的一段时间内不会被用到。

    Random

    Random replacement algorithm replaces a random page in memory.

    NFU (Not frequently used)

    The not frequently used (NFU) page replacement algorithm requires a counter, and every page has one counter of its own which is initially set to 0. 

  • 相关阅读:
    leetcode-22 括号生成
    Mysql安装与使用(详细)
    java开发环境的搭建
    LeetCode 55. Jump Game
    LeetCode 31. Next Permutation
    2019.1.12国家开发银行(国开行)笔试【补录】+ 面试总结
    苹果电脑MAMP环境配置以及关于“星球大战”知识图谱的复现
    创新工场-Deecamp2019冬令营笔试A卷 AND 面试内容
    使用scp命令在mac本机和linux服务器之间传输数据
    python小技巧之多行缩进,获取程序运行时间,删除非空文件夹
  • 原文地址:https://www.cnblogs.com/zno2/p/4845586.html
Copyright © 2011-2022 走看看