修改console缓存大小
Prerequisites: Memory mapping and its types
先决条件: 内存映射及其类型
While designing a cache system of a PC, the size of cache lines is an important parameter.
在设计PC的缓存系统时,缓存行的大小是重要的参数。
In the caching system, the size of the cache line affects a lot of parameters.
在缓存系统中,缓存行的大小会影响很多参数。
The following results show the effect of changing the cache block or line size in a caching system.
以下结果显示了在缓存系统中更改缓存块或行大小的影响。
1) In what ways changing block size affect spatial locality?
1)改变块大小会以什么方式影响空间局部性?
Spatial Locality indicates, if any word is in the cache then next time it will be referenced in a short amount of time.
空间局部性表明,如果高速缓存中有任何单词,则下次将在很短的时间内引用它。
If the block size is large then the spatial locality will be better.
如果块大小较大,则空间位置会更好。
By keeping the cache size constant, we have two cases as follows,
通过保持高速缓存大小不变,我们有以下两种情况:
Case 1: Decreasing the Block Size
情况1:减小块大小
Smaller block size will contain a less number of nearby addresses in it. Thus, only a small number of nearby addresses will be brought into the cache.
较小的块大小将在其中包含较少数量的附近地址。 因此,只有少量附近的地址将被带入高速缓存。
Due to the small size of the block increases the chances of cache miss which reduces the exploitation of spatial locality.
由于块的小尺寸,增加了高速缓存未命中的机会,这减少了对空间局部性的利用。
Thus, smaller is the block size, inferior is the spatial locality.
因此,块大小较小,空间局部性较差。
Case 2: Increasing the Block Size
情况2:增加块大小
A large block size will contain a number of nearby addresses in it. Thus, a larger number of nearby addresses will be brought into the cache.
大的块大小将在其中包含许多附近的地址。 因此,大量附近的地址将被带入缓存。
This increases the chances of cache hit which increases the exploitation of spatial locality.
这增加了缓存命中的机会,从而增加了对空间局部性的利用。
If the block size is large hen experiences better spatial locality.
如果块大,则母鸡的空间定位更好。
2) In what ways changing block size affect On Cache Tag in Fully Associative Cache?
2)更改块大小会以什么方式影响完全关联缓存中的“缓存标签”?
Case 1: Decreasing the Block Size
情况1:减小块大小
If we are keeping the cache size constant and decreasing the block size then it will decrease the number of bits in block offset.
如果我们保持高速缓存大小不变并减小块大小,那么它将减少块偏移量的位数。
With the decrease in the number of bits in block offset, the number of bits in tag increases.
随着块偏移中位数的减少,标签中位数的增加。
Case 2: Increasing the Block Size
情况2:增加块大小
Keeping the cache size constant,
保持高速缓存大小不变,
Increasing the block size increases the number of bits in block offset.
增加块大小会增加块偏移量的位数。
With the increase in the number of bits in block offset, the number of bits in tag decreases.
随着块偏移中位数的增加,标签中位数的减少。
3) In what ways changing block size affect on Cache Tag in Set Associative Cache?
3)更改块大小会以哪些方式影响Set Associative Cache中的Cache Tag?
Case 1: Decreasing the Block Size
情况1:减小块大小
If we are keeping the cache size constant it will increase the number of lines in the cache and also the number of sets in the cache then the number of bits in set number increases.
如果我们保持高速缓存大小不变,则会增加高速缓存中的行数以及高速缓存中的集数,因此集数中的位数会增加。
When the block size decreases then the number of bits in block offset also decreases.
当块大小减小时,块偏移量中的位数也会减少。
So, the number of bits in the set number and number of bits in block offset will remain constant that is no change on the cache tag.
因此,设置数量中的位数和块偏移中的位数将保持不变,这在缓存标签上不会发生变化。
Case 2: Increasing the Block Size
情况2:增加块大小
If we are increasing the block size then it decreases the number of lines in the cache and increases the number of bits in block offset.
如果我们要增加块大小,那么它将减少高速缓存中的行数,并增加块偏移量的位数。
With the decrease in the number of cache lines, the number of sets in cache decreases and also the number of bits in set number decreases.
随着高速缓存行数量的减少,高速缓存中的集合数量减少,并且集合数量中的位数也减少。
So, the number of bits in the set number and number of bits in block offset will remain constant that is no effect on the cache tag.
因此,设置数量中的位数和块偏移中的位数将保持不变,这对缓存标签没有影响。
4) In what ways Changing block size affect On Cache Miss Penalty?
4)更改块大小会以何种方式影响“高速缓存未命中罚款”?
When a cache miss happens, the required block of the word has to be brought from the main memory.
当发生高速缓存未命中时,必须从主存储器中提取所需的字块。
Time taken to bring the block in the cache will be less if the block size is small. Hence, less miss penalty will incur.
如果块大小较小,则将块放入高速缓存所需的时间会更少。 因此,将产生较少的未命中罚款。
If the block size is large so the time taken to bring the block in the cache will be more. Hence, more miss penalty will incur.
如果块大小很大,那么将块带入缓存所需的时间会更多。 因此,将招致更多的未命中罚款。
5) In what ways changing block size affect on Cache Tag in Direct Mapped Cache?
5)更改块大小会以什么方式影响直接映射缓存中的缓存标签?
Case 1: Decreasing the Block Size
情况1:减小块大小
If we are keeping the cache size constant and decreasing the block size, this will increases the number of lines in the cache.
如果我们保持高速缓存大小不变并减小块大小,这将增加高速缓存中的行数。
With the decrease in block size, the number of bits in block offset decreases.
随着块大小的减小,块偏移的位数减少。
However, the number of bits in line number increases the cause of increasing the number of cache lines.
但是,行号中的位数增加了导致高速缓存行数增加的原因。
With the increasing number of cache lines, the number of bits in line number together with the number of bits in block offset will remain constant that is there is no effect on the cache tag.
随着高速缓存行数目的增加,行号中的位数和块偏移中的位数将保持不变,这对高速缓存标签没有影响。
Case 2: Increasing the Block Size
情况2:增加块大小
With increasing the block size the number of lines in cache decreases and the number of bits in block offset increases.
随着块大小的增加,高速缓存中的行数减少,并且块偏移量中的位数增加。
However, with the decreasing number of cache lines, the number of bits in line number decreases.
但是,随着高速缓存行的数量减少,行号中的位数减少。
So, the number of bits in line number and number of bits in block offset will remain constant. Hence, no effect on the cache tags.
因此,行号中的位数和块偏移中的位数将保持不变。 因此,对缓存标签没有影响。
6) In what ways Cache Tag affect on Cache Hit Time?
6)缓存标记以什么方式影响缓存命中时间?
The time required to find out whether the required block is in cache or not is cache hit time.
找出所需块是否在缓存中所需的时间是缓存命中时间。
It this comparing the tag of cache lines with the tag of the generated address.
它将缓存行的标签与生成的地址的标签进行比较。
Hence, Smaller is the cache tag, lesser will be the time taken to perform the comparisons so smaller cache tag ensures lower cache hit time and larger is the cache tag results in a higher cache hit time.
因此,缓存标签较小,执行比较所需的时间更少,因此较小的缓存标签可确保较低的缓存命中时间,而较大的缓存标签可导致较高的缓存命中时间。
References:
参考文献:
Set Associative Mapping | Set Associative Cache
设置关联映射| 设置关联缓存
Cache performance measurement and metric
缓存性能度量和指标
翻译自: https://www.includehelp.com/operating-systems/how-changing-the-line-size-of-cache-will-affect-other-parameters.aspx
修改console缓存大小