Computer
Performance
Performance
■ Performance is the key to understanding underlying motivation
for the hardware and its organization
■ Why is some hardware better than others for different programs?
■ What factors of system performance are hardware related?
(e.g., do we need a new machine, or a new operating system?)
■ How does the machine's instruction set affect performance?
The Role of Performance
Response Time
Throughput
Relative performance
Measuring Execution time
CPU time
CPU clocking ,instruction count and CPI
Computer Performance:
TIME, TIME, TIME!!!
■ Response Time (elapsed time, latency):Response time is how long
it takes to complete a task — from the start to the finish of a job.
■ how long does it take for my job to run?
Individual user
■ how long does it take to execute (start to concerns…
finish) my job?
■ how long must I wait for the database query?
■ Throughput:Throughput is the amount of work done per unit time
■ how many jobs can the machine run at once? Systems manager
concerns…
■ what is the average execution rate?
■ how much work is getting done?
Response time: The total time to complete a task, including disk accesses, memory accesses,
input/output (I/O) activities, operating system overhead—everything.
■ If we upgrade a machine with a new processor what do we increase?
■ If we add a new machine to the lab what do we increase?
■ Decreasing response time almost always improves throughput. Hence,
in case1, both response time and throughput are improved. In case 2,
no one task gets work done faster, so only throughput increases
Execution Time
■ Elapsed Time/Response time
■ counts everything (disk and memory accesses, waiting for I/O,
running other programs, etc.) from start to finish
■ a useful number, but often not good for comparison purposes
elapsed time = CPU time + wait time (I/O, other programs, etc.)
■ CPU time: CPU execution time Also called CPU time. The actual time
the CPU spends computing for a specific task.
■ doesn't count waiting for I/O or time spent running other programs
■ can be divided into user CPU time and system CPU time (OS calls)
CPU time = user CPU time + system CPU time
⇒ elapsed time = user CPU time + system CPU time + wait time
■ Our focus: user CPU time (CPU execution time or, simply,
execution time)
■ time spent executing the lines of code that are in our program
user CPU time: The CPU time
spent in a program itself.
system CPU time: The CPU
time spent in the operating system performing
tasks on behalf of the program.
clock cycle Also called tick,
clock tick, clock period, clock,
cycle. The time for one clock
period, usually of the processor
clock, which runs at a constant
rate.
clock period: The length of
each clock cycle.
Definition of Performance
■ For some program running on machine X:
PerformanceX = 1 / Execution timeX
This means that for two computers X and Y, if the performance
of X is greater than the performance of Y,
We have
PerformanceX > PerformanceY
1/ execution of time X > 1/ execution time of Y
Execution timeY > Execution timeX
X is n times faster than Y means:
PerformanceX / PerformanceY = n
Example of Relative
performance
■ If Afia’s Computer runs a program in 10 seconds and
Tahmid’s computer runs the same program in 15
seconds, whose computer is faster and by how much
faster?
Clock Cycles
■ Instead of reporting execution time in seconds, we often use
cycles. In modern computers hardware events progress cycle by
cycle: in other words, each event, e.g., multiplication, addition,
etc., is a sequence of cycles
■ Clock ticks indicate start and end of cycles:
cycle time
Clock Rate=1/Clock cycle time
tick
tick
■ cycle time = time between ticks = seconds per cycle
■ clock rate (frequency) = cycles per second (1 Hz. = 1
cycle/sec, 1 MHz. = 106 cycles/sec)
■ Example: A 200 Mhz. clock has a
cycle time
Performance Equation I
equivalently
■ So, to improve performance one can either:
■ reduce the number of cycles for a program, or
■ reduce the clock cycle time, or, equivalently,
■ increase the clock rate (The clock rate is the inverse of the clock
cycle time)
How many cycles are required
for a program?
■ Could assume that no. of cycles = no. of instructions
2nd instruction
3rd instruction
1st instruction
4th
5th
6th
...
time
■ This assumption is incorrect! Because:
■ Different instructions take different amounts of time (cycles)
■ Why…?
How many cycles are required
for a program?
time
■ Multiplication takes more time than addition
■ Floating point operations take longer than integer ones
■ Accessing memory takes more time than accessing registers
■ Important point: changing the cycle time often changes the
number of cycles required for various instructions because it
means changing the hardware design. More later…
Example
Our favorite program runs in 10 seconds on computer
A, which has a 4 GHz clock. We are trying to help a
computer designer build a computer, B, that will run
this program in 6 seconds. The designer has determined
that a substantial increase in the clock rate is possible,
but this increase will affect the rest of the CPU design,
causing computer B to require 1.2 times as many clock
cycles as computer A for this program.
■ What clock rate should we tell the designer to target?
Example Solution
Terminology
■ A given program will require:
■ some number of instructions (machine instructions)
■ some number of cycles
■ some number of seconds
■ We have a vocabulary that relates these quantities:
■ cycle time (seconds per cycle)
■ clock rate (No of clock cycles per second)
■ (average) CPI (cycles per instruction)
■ a floating point intensive application might have a higher average CPI
■ MIPS (millions of instructions per second)
■ this would be higher for a program using simple instructions
Performance Measure
■ Performance is determined by execution time
■ Do any of these other variables equal performance?
■ no of cycles to execute program?
■ no of instructions in program?
■ no of cycles per second?
■ average no of cycles per instruction?
■ average no of instructions per second?
■ Common pitfall : thinking one of the variables is indicative of
performance when it really isn’t
Performance Equation II
CPU execution time Instruction count × average CPI × Clock cycle time
=
for a program for a program
■ Derive the above equation from Performance Equation I
CPI Example I
■ Suppose we have two implementations of the same instruction
set architecture. Computer A has a clock cycle time of 250 ps
and a CPI of 2.0 for some program, and computer B has a clock
cycle time of 500 ps and a CPI of 1.2 for the same program.
Which computer is faster for this program, and by how much?
■ If two machines have the same ISA, which of our quantities (e.g., clock
rate, CPI, execution time, number of instructions, MIPS) will always
be identical?
CPI Example I Solution
CPI Example II
■ A compiler designer is trying to decide between two code
sequences for a particular machine.
■ Based on the hardware implementation, there are three
different classes of instructions: Class A, Class B, and Class C,
and they require 1, 2 and 3 cycles (respectively).
■ The first code sequence has 5 instructions:
2 of A, 1 of B, and 2 of C
The second sequence has 6 instructions:
4 of A, 1 of B, and 1 of C.
■ Which sequence will be faster? How much? What is the CPI for each
sequence?
CPI Example II Solution
CPI Example II Solution
MIPS Example
■ Two different compilers are being tested for a 4GHz. machine
with three different classes of instructions: Class A, Class B,
and Class C, which require 1, 2 and 3 cycles (respectively).
Both compilers are used to produce code for a large piece of
software.
■ Compiler 1 generates code with 5 billion Class A instructions, 1
billion Class B instructions, and 1 billion Class C instructions.
■ Compiler 2 generates code with 10 billion Class A instructions, 1
billion Class B instructions, and 1 billion Class C instructions.
■ Which sequence will be faster according to MIPS?
■ Which sequence will be faster according to execution time?
MIPS Example
MIPS Example
Summary
■ Performance is specific to a particular program
■ total execution time is a consistent summary of performance
■ For a given architecture performance increases come from:
■ increases in clock rate (without adverse CPI affects)
■ improvements in processor organization that lower CPI
■ compiler enhancements that lower CPI and/or instruction count
■ Pitfall: expecting improvement in one aspect of a machine’s
performance to affect the total performance