From: Marc Battyani
Subject: Re: Timing for various operations on a PC
Date: 
Message-ID: <oN6dndbzqMyE5PHeRVnyjg@giganews.com>
<········@gmail.com> wrote
>     In Peter Norvig's essay, "Teach Yourself Programming in Ten Years",
> he says it is a good idea for anybody interested in CS to find out
> certain details like -- " Know how long it takes your computer to
> execute an instruction, fetch a word from memory (with and without a
> cache miss), read consecutive words from disk, and seek to a new
> location on disk." He gives a table(values from 2001) for his PC.
>     Can anyone tell me how to determine this accurately for a PC?
> Especially things like time taken to fetch something from L1 cache? Or
> is it something we have to look for the in the PC/processor manuals?
>       This group may not be the apropriate place for the question, but
> I have always found good answers here and I feel the topic maybe
> relevant to a programmer of any language.

It's important to understand that the memory latency is huge compared to the
processor speed. For instance here are the values for my notebook (2.0GHz
Pentium M with benchmark software from http://www.sciencemark.org/):

L1  Latency: 3 cycles / 1.50 ns / 32 byte stride
L2  Latency: 3 cycles / 1.50 ns / 4 byte stride
L2  Latency: 4 cycles / 2.01 ns / 16 byte stride
L2  Latency: 10 cycles / 5.02 ns / 64 byte stride
L2  Latency: 10 cycles / 5.02 ns / 256 byte stride
L2  Latency: 10 cycles / 5.02 ns / 512 byte stride
Mem Latency: 4 cycles / 2.01 ns / 4 byte stride
Mem Latency: 16 cycles / 7.52 ns / 16 byte stride
Mem Latency: 59 cycles / 30.10 ns / 64 byte stride
Mem Latency: 197 cycles / 96.31 ns / 256 byte stride
Mem Latency: 195 cycles / 100.83 ns / 512 byte stride

L1  BW: 24836.98 MB/s
L2  BW: 10156.85 MB/s
Mem BW: 2075.21 MB/s

As you see, you can easily have almost 200 processor cycles to fetch data
from memory.
You can read the software optimization manual for the Intel, IBM PPC and AMD
to have more info on how it works. For instance the AMD one is here:
http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/2511
2.PDF

You can also read how the DDR/DDR2 SDRAM works from the RAM manufacturers'
sites as it's rather complex now.

Marc