什么是缓存命中和缓存未命中?为什么上下文切换会导致缓存未命中? [英] What is a cache hit and a cache miss? Why context-switching would cause cache miss?

查看:1371
本文介绍了什么是缓存命中和缓存未命中?为什么上下文切换会导致缓存未命中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

性能和可扩展性)和名为上下文切换 -us-east-1.amazonaws.com/\">JCIP图书

From the 11th Chapter(Performance and Scalability) and the section named Context Switching of the JCIP book:


当新线程切换时,它需要的数据在本地处理器高速缓存中不太可能是
,因此上下文切换导致
高速缓存未命中的繁忙,因此线程运行得更慢一些,当它们是

When a new thread is switched in, the data it needs is unlikely to be in the local processor cache, so a context-switch causes a flurry of cache misses, and thus threads run a little more slowly when they are first scheduled.




  1. 有人可以以容易理解的方式解释高速缓存未命中的概念

  2. 为什么上下文切换会导致大量缓存缺失?


推荐答案


有人可以用容易理解的方式解释高速缓存未命中的概念, (缓存命中)?

Can someone explain in an easy to understand way the concept of cache miss and its probable opposite (cache hit)?

一般来说,缓存 并且未找到 - 缓存不包含正在查找的项目。缓存命中是当您在缓存中查找并且存储该项目并且能够满足查询时。

A cache miss, generally, is when something is looked up in the cache and is not found -- the cache did not contain the item being looked up. The cache hit is when you look something up in a cache and it was storing the item and is able to satisfy the query.


为什么上下文切换会导致大量缓存缺失?

Why context-switching would cause a lot of cache miss?

内存,它是在你的文章中引用的文本中引用,每个处理器都有一个内存缓存 - 主内存的高速副本。当新线程被上下文切换到处理器时,本地高速缓存存储器是空的或者它不对应于线程所需的数据。这意味着由该新线程进行的所有(或大多数)存储器查找导致高速缓存未命中,因为它需要的数据不是存储在本地存储器高速缓存中。硬件必须向主存储器发出多个请求以填充本地存储器高速缓存,这使得线程最初运行得更慢。

In terms of memory, which is being referenced in the quoted text in your post, each processor has a memory cache -- a high speed copy of main memory. When a new thread is context switched into a processor, the local cache memory is empty or it doesn't correspond to the data needed for the thread. This means that all (or most) memory lookups made by that new thread result in cache misses because the data that it needs is not stored in the local memory cache. The hardware has to then make a number of requests to main memory to fill up the local memory cache which causes the thread to initially run slower.

这篇关于什么是缓存命中和缓存未命中?为什么上下文切换会导致缓存未命中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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