<s>
In	O
computer	B-General_Concept
organisation	I-General_Concept
,	O
the	O
memory	B-General_Concept
hierarchy	I-General_Concept
separates	O
computer	B-General_Concept
storage	I-General_Concept
into	O
a	O
hierarchy	O
based	O
on	O
response	O
time	O
.	O
</s>
<s>
Memory	B-General_Concept
hierarchy	I-General_Concept
affects	O
performance	O
in	O
computer	O
architectural	O
design	O
,	O
algorithm	O
predictions	O
,	O
and	O
lower	O
level	O
programming	B-General_Concept
constructs	O
involving	O
locality	B-General_Concept
of	I-General_Concept
reference	I-General_Concept
.	O
</s>
<s>
Designing	O
for	O
high	O
performance	O
requires	O
considering	O
the	O
restrictions	O
of	O
the	O
memory	B-General_Concept
hierarchy	I-General_Concept
,	O
i.e.	O
</s>
<s>
Internal	O
Processor	B-General_Concept
registers	I-General_Concept
and	O
cache	B-General_Concept
.	O
</s>
<s>
Main	O
the	O
system	O
RAM	B-Architecture
and	O
controller	O
cards	O
.	O
</s>
<s>
This	O
is	O
a	O
general	O
memory	B-General_Concept
hierarchy	I-General_Concept
structuring	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
paging	O
algorithm	O
may	O
be	O
considered	O
as	O
a	O
level	O
for	O
virtual	B-Architecture
memory	I-Architecture
when	O
designing	O
a	O
computer	B-General_Concept
architecture	I-General_Concept
,	O
and	O
one	O
can	O
include	O
a	O
level	O
of	O
nearline	B-General_Concept
storage	I-General_Concept
between	O
online	O
and	O
offline	O
storage	O
.	O
</s>
<s>
Adding	O
complexity	O
slows	O
down	O
the	O
memory	B-General_Concept
hierarchy	I-General_Concept
.	O
</s>
<s>
One	O
of	O
the	O
main	O
ways	O
to	O
increase	O
system	O
performance	O
is	O
minimising	O
how	O
far	O
down	O
the	O
memory	B-General_Concept
hierarchy	I-General_Concept
one	O
has	O
to	O
go	O
to	O
manipulate	O
data	O
.	O
</s>
<s>
Neither	O
of	O
them	O
is	O
uniform	O
,	O
but	O
is	O
specific	O
to	O
a	O
particular	O
component	O
of	O
the	O
memory	B-General_Concept
hierarchy	I-General_Concept
.	O
</s>
<s>
Predicting	O
where	O
in	O
the	O
memory	B-General_Concept
hierarchy	I-General_Concept
the	O
data	O
resides	O
is	O
difficult	O
.	O
</s>
<s>
the	O
...	O
location	O
in	O
the	O
memory	B-General_Concept
hierarchy	I-General_Concept
dictates	O
the	O
time	O
required	O
for	O
the	O
prefetch	O
to	O
occur	O
.	O
</s>
<s>
The	O
number	O
of	O
levels	O
in	O
the	O
memory	B-General_Concept
hierarchy	I-General_Concept
and	O
the	O
performance	O
at	O
each	O
level	O
has	O
increased	O
over	O
time	O
.	O
</s>
<s>
For	O
example	O
,	O
the	O
memory	B-General_Concept
hierarchy	I-General_Concept
of	O
an	O
Intel	O
Haswell	O
Mobile	O
processor	O
circa	O
2013	O
is	O
:	O
</s>
<s>
Processor	B-General_Concept
registers	I-General_Concept
the	O
fastest	O
possible	O
access	O
(	O
usually	O
1	O
CPU	O
cycle	O
)	O
.	O
</s>
<s>
Level	O
1	O
(	O
L1	O
)	O
Data	B-General_Concept
cache	I-General_Concept
128	O
KiB	O
in	O
size	O
.	O
</s>
<s>
Level	O
2	O
(	O
L2	O
)	O
Instruction	B-Language
and	O
data	O
(	O
shared	O
)	O
1	O
MiB	O
in	O
size	O
.	O
</s>
<s>
Level	O
3	O
(	O
L3	O
)	O
Shared	B-General_Concept
cache	I-General_Concept
6	O
MiB	O
in	O
size	O
.	O
</s>
<s>
Level	O
4	O
(	O
L4	O
)	O
Shared	B-General_Concept
cache	I-General_Concept
128	O
MiB	O
in	O
size	O
.	O
</s>
<s>
Main	B-General_Concept
memory	I-General_Concept
(	O
Primary	O
storage	O
)	O
GiB	O
in	O
size	O
.	O
</s>
<s>
Disk	B-Device
storage	I-Device
(	O
Secondary	O
storage	O
)	O
Terabytes	O
in	O
size	O
.	O
</s>
<s>
Nearline	B-General_Concept
storage	I-General_Concept
(	O
Tertiary	O
storage	O
)	O
Up	O
to	O
exabytes	O
in	O
size	O
.	O
</s>
<s>
The	O
lower	O
levels	O
of	O
the	O
hierarchy	O
–	O
from	O
disks	B-Device
downwards	O
–	O
are	O
also	O
known	O
as	O
tiered	B-General_Concept
storage	I-General_Concept
.	O
</s>
<s>
The	O
formal	O
distinction	O
between	O
online	O
,	O
nearline	B-General_Concept
,	O
and	O
offline	O
storage	O
is	O
:	O
</s>
<s>
Nearline	B-General_Concept
storage	I-General_Concept
is	O
not	O
immediately	O
available	O
,	O
but	O
can	O
be	O
made	O
online	O
quickly	O
without	O
human	O
intervention	O
.	O
</s>
<s>
For	O
example	O
,	O
always-on	O
spinning	O
disks	B-Device
are	O
online	O
,	O
while	O
spinning	O
disks	B-Device
that	O
spin-down	O
,	O
such	O
as	O
massive	O
array	O
of	O
idle	O
disk	B-Device
(	O
MAID	O
)	O
,	O
are	O
nearline	B-General_Concept
.	O
</s>
<s>
Removable	O
media	O
such	O
as	O
tape	O
cartridges	O
that	O
can	O
be	O
automatically	O
loaded	O
,	O
as	O
in	O
a	O
tape	B-Device
library	I-Device
,	O
are	O
nearline	B-General_Concept
,	O
while	O
cartridges	O
that	O
must	O
be	O
manually	O
loaded	O
are	O
offline	O
.	O
</s>
<s>
Most	O
modern	O
CPUs	B-General_Concept
are	O
so	O
fast	O
that	O
for	O
most	O
program	O
workloads	O
,	O
the	O
bottleneck	O
is	O
the	O
locality	B-General_Concept
of	I-General_Concept
reference	I-General_Concept
of	O
memory	O
accesses	O
and	O
the	O
efficiency	O
of	O
the	O
caching	B-General_Concept
and	O
memory	O
transfer	O
between	O
different	O
levels	O
of	O
the	O
hierarchy	O
.	O
</s>
<s>
The	O
resulting	O
load	O
on	O
memory	O
use	O
is	O
known	O
as	O
pressure	O
(	O
respectively	O
register	O
pressure	O
,	O
cache	B-General_Concept
pressure	O
,	O
and	O
(	O
main	O
)	O
memory	O
pressure	O
)	O
.	O
</s>
<s>
Terms	O
for	O
data	O
being	O
missing	O
from	O
a	O
higher	O
level	O
and	O
needing	O
to	O
be	O
fetched	O
from	O
a	O
lower	O
level	O
are	O
,	O
respectively	O
:	O
register	O
spilling	O
(	O
due	O
to	O
register	O
pressure	O
:	O
register	O
to	O
cache	B-General_Concept
)	O
,	O
cache	B-General_Concept
miss	O
(	O
cache	B-General_Concept
to	O
main	B-General_Concept
memory	I-General_Concept
)	O
,	O
and	O
(	O
hard	O
)	O
page	B-General_Concept
fault	I-General_Concept
(	O
main	B-General_Concept
memory	I-General_Concept
to	O
disk	B-Device
)	O
.	O
</s>
<s>
Modern	O
programming	B-General_Concept
languages	O
mainly	O
assume	O
two	O
levels	O
of	O
memory	O
,	O
main	B-General_Concept
memory	I-General_Concept
and	O
disk	B-Device
storage	I-Device
,	O
though	O
in	O
assembly	B-Language
language	I-Language
and	O
inline	B-Language
assemblers	I-Language
in	O
languages	O
such	O
as	O
C	B-Language
,	O
registers	O
can	O
be	O
directly	O
accessed	O
.	O
</s>
<s>
Taking	O
optimal	O
advantage	O
of	O
the	O
memory	B-General_Concept
hierarchy	I-General_Concept
requires	O
the	O
cooperation	O
of	O
programmers	O
,	O
hardware	O
,	O
and	O
compilers	O
(	O
as	O
well	O
as	O
underlying	O
support	O
from	O
the	O
operating	O
system	O
)	O
:	O
</s>
<s>
Programmers	O
are	O
responsible	O
for	O
moving	O
data	O
between	O
disk	B-Device
and	O
memory	O
through	O
file	O
I/O	O
.	O
</s>
<s>
Optimizing	B-Application
compilers	I-Application
are	O
responsible	O
for	O
generating	O
code	O
that	O
,	O
when	O
executed	O
,	O
will	O
cause	O
the	O
hardware	O
to	O
use	O
caches	O
and	O
registers	O
efficiently	O
.	O
</s>
<s>
Then	O
the	O
memory	B-General_Concept
hierarchy	I-General_Concept
will	O
be	O
assessed	O
during	O
code	O
refactoring	O
.	O
</s>
