Professional Documents
Culture Documents
Caching and Virtual Memory
Caching and Virtual Memory
Caching and Virtual Memory
yes
value stored
at address
Cache
Concept
(Write)
Cache
WriteBuffer yes
store value
in cache
Write
through:
changes
sent
store value
immediately
to
next
level
of
storage
at address
if write through
Write
back:
changes
stored
in
cache
un;l
cache
block
is
replaced
Memory
Hierarchy
i7
has
8MB
as
shared
3rd
level
cache;
2nd
level
cache
is
per-‐core
Hardware
Design
Principle
raise exception
i7
has
8MB
as
shared
3rd
level
cache;
2nd
level
cache
is
per-‐core
Transla;on
on
a
Modern
Processor
Translation Box
can
change
their
working
set
Cache Hit Rate
Phase
• Context
change
Context
switches
switch
also
change
working
set
0
Time
Zipf
Distribu;on
• Caching
behavior
of
many
systems
are
not
well
characterized
by
the
working
set
model
• An
alterna;ve
is
the
Zipf
distribu;on
– Popularity
~
1/k^c,
for
kth
most
popular
item,
1
<
c
<
2
Zipf
Distribu;on
Popularity
Rank
Zipf
Examples
• Web
pages
• Movies
• Library
books
• Words
in
text
• Salaries
• City
popula;on
• …
Common
thread:
popularity
is
self-‐reinforcing
Zipf
and
Caching
1
Cache Hit Rate
0
.001% .01% .1% 1% 10% all
Cache Size (log scale)
Cache
Lookup:
Fully
Associa;ve
address value
address =?
=?
=?
=?
yes
return value
Cache
Lookup:
Direct
Mapped
address value
hash(address)
=? match at hash(address)?
yes
return value
Cache
Lookup:
Set
Associa;ve
hash(address)
0x0053 0x120d
yes yes
• FIFO?
– Replace
the
entry
that
has
been
in
the
cache
the
longest
;me
– What
could
go
wrong?
FIFO
in
Ac;on