Performance Analysis

Measuring per-element time for repeatedly reading an array while gradually growing its size shows time rising in steps at certain sizes. Why?

  1. AThe CPU frequency always drops as arrays grow
  2. BEach time the array exceeds L1, L2 and then L3 cache capacity, data must come from slower storage
  3. CThe results of additions change with array size
Show answer and explanation

Answer: B. Each time the array exceeds L1, L2 and then L3 cache capacity, data must come from slower storage

While small, the array fits in L1 cache and reads fast; once it exceeds L1 it comes from L2, beyond L2 from L3, and beyond L3 from main memory, with per-element time stepping up each time. With sequential reads, hardware prefetching can make the steps look smaller; reading in an irregular order shows them more clearly. This method roughly reveals cache capacities and their speeds. It also shows why keeping the data a program repeatedly uses (its working set) within cache has such a large effect on performance.

  • A. Frequency is not set by array size.
  • B. Correct. The memory hierarchy's capacities show up as steps.
  • C. Computation results do not change.

Related calculators

Books on Performance Analysis Ad

As an Amazon Associate I earn from qualifying purchases.

More Performance Analysis questions

  1. A function f that finishes in 20 ns per call is called millions of times. It is measured with an instrumentation profiler that inserts recording code at the entry and exit of functions. If the recording takes 60 ns in total per call and all of that time is counted as time in f, how many times its true time does the measured time of f become?
  2. Which is the basic formula for a program's CPU execution time?
  3. A program executing 1 billion instructions runs on a CPU with average CPI 2 and clock frequency 2 GHz. What is the execution time?
  4. A CPU design change raises clock frequency 1.5× but also raises CPI 1.2× (instruction count unchanged). How many times faster is execution?
  5. A new compiler optimization reduces executed instructions by 20% but increases average CPI by 10% (frequency unchanged). What is its effect?

Comparisons in this topic