冷缓存和热缓存概念是什么意思? [英] What does it mean by cold cache and warm cache concept?

查看:1447
本文介绍了冷缓存和热缓存概念是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了一篇文章,并使用了术语冷藏缓存缓存温暖。我搜索,但我没有找到有用的东西。 冷藏缓存缓存缓存概念是什么意思?

我也访问这个链接但是我还需要更多的东西。

解决方案< TL; DR与汽车的冷机和暖机有相似之处。冷藏 - 没有任何价值,不能给你任何加速,因为它是空的。缓存有一些值,可以给你加速。

缓存是一种结构,它保存一些值(inode,内存页,磁盘块等),以便更快速地查找。通过在快速搜索数据结构(哈希表,B +树)或更快的访问介质(RAM内存vs HDD,SSD vs HDD)中存储某种短引用, 。

为了能够做到这一点快速搜索,你需要你的缓存来保存值。让我们看看例子。



说,你有一个Linux系统与一些文件系统。要访问文件系统中的文件,您需要知道文件从磁盘启动的位置。这个信息存储在inode中。为了简单起见,我们说inode表存储在磁盘上的某个地方(所谓的超级块部分)。现在想象一下,你需要读取文件/ etc / fstab。要做到这一点,你需要从磁盘(10毫秒)读取inode表,然后解析它,并获得文件的起始块,然后读取文件本身(10毫秒)。总计〜20ms

这种操作太多了。所以你要在RAM中添加一个哈希表形式的缓存。 RAM的访问时间是10ns - 这个速度是1000(!)倍。


$ b $ $ p $ (inode number或filename):(起始磁盘块)
但是问题是,在开始时你的缓存是空的 - 这样的缓存被称为冷藏缓存 >。要利用缓存的好处,您需要填充一些值。这是怎么发生的?当你正在寻找一些文件,你看你的inode缓存。如果您在缓存( cache miss )中没有找到inode,那么您会说'Okay',并使用inode表读取,解析和读取文件本身来执行完整的读取循环。但解析部分后,您保存inode号码和解析缓存中的开始磁盘块。而且这种情况还在继续 - 您尝试读取另一个文件,查看缓存,发生缓存未命中(缓存很冷),从磁盘读取数据,在缓存中添加一行。

因此,冷藏缓存不会给你任何加速,因为你仍然从磁盘读取数据。在某些情况下,冷藏缓存会让系统变慢,因为您正在做额外的工作(在表格中查找额外的步骤)以预热缓存。

过了一段时间在你的缓存中会有一些值,有一段时间你尝试读取文件,你在缓存和BAM中查找!你已经找到了inode( cache hit )!现在你已经开始磁盘块,所以你跳过阅读超级块,并开始阅读文件本身!您已经保存了10ms!



缓存称为热缓存 - 缓存中包含一些可让您缓存命中的值。 b $ b

I read a paper and it used terms "cold cache" and "warm cache". I search but I didn't find something useful. What does it mean by "cold cache" and "warm cache" concept ?

I also visit this link But I need something more.

解决方案

TL;DR There is analogy with cold engine and warm engine of the car. Cold cache - doesn't have any values and can't give you any speedup because, well, it's empty. Warm cache have some values and can give you that speedup.

Cache is a structure that holds some values (inodes, memory pages, disk blocks, etc.) for faster lookup.

Cache works by storing some kind of short references in fast search data structure (hash table, B+ Tree) or faster access media (RAM memory vs HDD, SSD vs HDD).

To be able to do this fast search you need your cache to hold values. Let's look at example.

Say, you have a Linux system with some filesystem. To access files in filesystem you need to know where your file starts at disk. This information stored in inode. For simplicity we say that inode table is stored somewhere on disk (so called "superblock" part).

Now imagine, that you need to read file /etc/fstab. To do this you need to read inode table from disk (10 ms) then parse it and get start block of file and then read file itself(10ms). Total ~20ms

This is way too many operations. So you are adding a cache in form of hash table in RAM. RAM access is 10ns - that's 1000(!) times faster. Each row in that hash table holds 2 values.

(inode number or filename) : (starting disk block)

But the problem is that at the start your cache is empty - such cache is called cold cache. To exploit benefits of your cache you need to fill it with some values. How does it happen? When you're looking for some file you look in your inode cache. If you don't find inode in cache (cache miss) you're saying 'Okay' and do full read cycle with inode table reading, parsing it and reading file itself. But after parsing part you're saving inode number and parsed starting disk block in your cache. And that's going on and on - you try to read another file, you look in cache, you get cache miss (your cache is cold), you read from disk, you add row in cache.

So cold cache doesn't give you any speedup because you are still reading from disk. In some cases cold cache makes your system slower because you're doing extra work (extra step of looking up in table) to warm up your cache.

After some time you'll have some values in your cache, and by some time you try to read file, you lookup in cache and BAM! you have found inode (cache hit)! Now you have starting disk block, so you skip reading superblock and start reading file itself! You have just saved 10ms!

That cache it called warm cache - cache with some values that gives you cache hits.

这篇关于冷缓存和热缓存概念是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆