修改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緩存大小