* Re: Why is our Alpha box so slow?
1998-08-03 4:00 ` Christian Weisgerber
@ 1998-08-04 4:00 ` Linus Torvalds
1998-08-04 4:00 ` Robert Harley
` (2 more replies)
1998-08-04 4:00 ` Chris Pirih, proverbs at wolfenet dot com
` (3 subsequent siblings)
4 siblings, 3 replies; 22+ messages in thread
From: Linus Torvalds @ 1998-08-04 4:00 UTC (permalink / raw)
In article <6q55em$a58$1@mips.rhein-neckar.de>,
Christian Weisgerber <naddy@mips.rhein-neckar.de> wrote:
>
>The result on the Alpha box (Red Hat 5.1, 2.0.33, egcs-2.90.29, -O3) is
>bizarre:
>
> 1k: 149679693 *
> 2k: 149316456 * 8k 1st level cache
> 4k: 144773425 *
> 8k: 144881972 *
> 16k: 104659487 .
> 32k: 104677115 .
> 64k: 104652525 .
> 128k: 104110833 . huh!? we have 1M
> 256k: 56204479 of 2nd level cache
> 512k: 40814057
>1024k: 32698979
>2048k: 26571787 continuously getting slower!?
>4096k: 24232887
You may have 1MB of L2 cache, but it's direct-mapped and physical, and
Linux (for good reasons) doesn't try to colour it. So depending on how
your physical pages get spread out in memory you can't cache it all.
Anyway, it's not continuously getting slower, but the effect of the
cache is gradually getting less (you'd probably see it stagnating at
somewhere around 24000000 which would be your main memory index).
The colouring doesn't show up for the L1, because while the L1 is
direct-mapped too, so is your memory (8kB pages), so there are no
virtual->physical translation issues for the low 13 bits of the address,
and you don't see the same effect.
Now you know why newer CPU's tend to have multi-way associative caches.
Much better degradation.
Linus
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: Why is our Alpha box so slow?
1998-08-04 4:00 ` Linus Torvalds
@ 1998-08-04 4:00 ` Robert Harley
1998-08-06 4:00 ` Christian Weisgerber
1998-08-14 4:00 ` bmeyer
2 siblings, 0 replies; 22+ messages in thread
From: Robert Harley @ 1998-08-04 4:00 UTC (permalink / raw)
Christian Weisgerber <naddy@mips.rhein-neckar.de> wrote:
>
>The result on the Alpha box (Red Hat 5.1, 2.0.33, egcs-2.90.29, -O3) is
>bizarre:
>
> 1k: 149679693 *
> 2k: 149316456 * 8k 1st level cache
> 4k: 144773425 *
> 8k: 144881972 *
> 16k: 104659487 .
> 32k: 104677115 .
> 64k: 104652525 .
> 128k: 104110833 . huh!? we have 1M
> 256k: 56204479 of 2nd level cache
> 512k: 40814057
>1024k: 32698979
>2048k: 26571787 continuously getting slower!?
>4096k: 24232887
Here's what I got on two successive runs of your program on a PWS 500
(8K L1, 96K L2, 2M L3, 256M SDRAM) with kernel 2.0.35, egcs 1.0.3:
1k: 1062232512 1062755612
2k: 1061531391 1062338573
4k: 1039505016 1039862386
8k: 1047222456 1048294159
16k: 863710769 743501714 *
32k: 863224039 797739799 *
64k: 841381958 806677243 *
128k: 684417939 673839756
256k: 593329490 554701343
512k: 480981009 474114026
1024k: 394247431 401512977
2048k: 341795519 344795247
4096k: 302455587 306442743
8192k: 288015508 287996488
16384k: 286349351 285664343
32768k: 286640067 286410847
65536k: 287788687 287938399
131072k: 290794815 290588750
You can see definite plateaux for L1 and L2, then a graceful
degradation that flattens out at sizes much larger than L3.
The drop-off in your figures does seem to start too early for a 1M
cache. It looks more like 256K to me. Other than that the shape
looks right; the drop-off is severe because you have a model that's
well known to have really slow main memory!
torvalds@transmeta.com (Linus Torvalds) writes:
> You may have 1MB of L2 cache, but it's direct-mapped and physical, and
> Linux (for good reasons) doesn't try to colour it. So depending on how
> your physical pages get spread out in memory you can't cache it all.
I really wish that Linux did page colouring. For sizes between L1 and
L2, there are often variations like on the starred lines above.
I'm optimising some routines for arithmetic on big polynomials which
get broken down into pieces of this size, typically. Trying to
optimise in the face of random uncontrollable variations in timing is
difficult to say the least!
Bye,
Rob.
__ . . ' . . . ' *
/\ \ . . . . . + .
____/_ \ \____ .-. .-. __ . * . . + . . .
/______\ \ \ /\/ \/ \ .-. __/ \________________________________
\ _____\ \/ / / /\ \/ \__/ \__/ \
\/ / / \/ / / / \ /\ / \__/ \__ Robert.Harley@inria.fr \
/ / /\__/_/_/\ / `-' \ \__/ \__/ \______________________________/
/ / /\ \_______\_' `-' \__/ \__/ . . +
\/__\ \ \______/ \__/ . . + .+. .
\ \ / . . + . . . . .
\_\/
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: Why is our Alpha box so slow?
1998-08-04 4:00 ` Linus Torvalds
1998-08-04 4:00 ` Robert Harley
@ 1998-08-06 4:00 ` Christian Weisgerber
1998-08-14 4:00 ` bmeyer
2 siblings, 0 replies; 22+ messages in thread
From: Christian Weisgerber @ 1998-08-06 4:00 UTC (permalink / raw)
In article <6q6e4j$8c3$1@palladium.transmeta.com>, Linus Torvalds
<torvalds@transmeta.com> wrote:
> [.... direct-mapped cache... coloring... multi-way associative
> caches...]
Uh, this is kind of embarrassing, but can anybody offer any pointers to
some background information that would help me to understand what Linus
is talking about?
--
Christian "naddy" Weisgerber naddy@mips.rhein-neckar.de
100+ SF Book Reviews: <URL:http://home.pages.de/~naddy/reviews/>
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: Why is our Alpha box so slow?
1998-08-04 4:00 ` Linus Torvalds
1998-08-04 4:00 ` Robert Harley
1998-08-06 4:00 ` Christian Weisgerber
@ 1998-08-14 4:00 ` bmeyer
2 siblings, 0 replies; 22+ messages in thread
From: bmeyer @ 1998-08-14 4:00 UTC (permalink / raw)
torvalds@transmeta.com (Linus Torvalds) writes:
>You may have 1MB of L2 cache, but it's direct-mapped and physical, and
>Linux (for good reasons) doesn't try to colour it. So depending on how
>your physical pages get spread out in memory you can't cache it all.
Which brings up a question.... Is there some way to do request memory
that maps to certain parts in the caches? Or at least to find out the
relevant address bits of some memory after having allocated it?
And if so, is there any way (hopefully short of mlock()ing everything)
to make it stay there? Maybe even portably for the 21064/066/164?
I am asking because I am playing around with UAE, the Amiga emulator, and
it is somehow disconcerting to get massively different benchmark results
when starting the exact same piece of software twice. There are a few
data structures which are used extensively, and I suspect on the slow
runs, they are kicking each other out of the caches....
Bernie
--
============================================================================
"It's a magical world, Hobbes ol' buddy...
...let's go exploring"
Calvin's final words, on December 31st, 1995
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Why is our Alpha box so slow?
1998-08-03 4:00 ` Christian Weisgerber
1998-08-04 4:00 ` Linus Torvalds
@ 1998-08-04 4:00 ` Chris Pirih, proverbs at wolfenet dot com
1998-08-05 4:00 ` David A Willmore
1998-08-04 4:00 ` Christian Weisgerber
` (2 subsequent siblings)
4 siblings, 1 reply; 22+ messages in thread
From: Chris Pirih, proverbs at wolfenet dot com @ 1998-08-04 4:00 UTC (permalink / raw)
In article <6q55em$a58$1@mips.rhein-neckar.de>,
naddy@mips.rhein-neckar.de (Christian Weisgerber) wrote:
| The result on the Alpha box (Red Hat 5.1, 2.0.33, egcs-2.90.29, -O3) is
| bizarre:
|
| 1k: 149679693 *
| 2k: 149316456 * 8k 1st level cache
| 4k: 144773425 *
| 8k: 144881972 *
| 16k: 104659487 .
| 32k: 104677115 .
| 64k: 104652525 .
| 128k: 104110833 . huh!? we have 1M
| 256k: 56204479 of 2nd level cache
| 512k: 40814057
| 1024k: 32698979
| 2048k: 26571787 continuously getting slower!?
| 4096k: 24232887
My UDB gives similar strange results. It's supposed to have 256KB cache.
1k: 162429336
2k: 161239327
4k: 153634196
8k: 152466836 L1
16k: 115433109
32k: 115493359
64k: 115693927
128k: 54652508
256k: 33898287 L2
512k: 24448508
1024k: 21316260
2048k: 21236215
4096k: 21339344
As you can see by the 1024k-4096k numbers, main memory bandwidth SUCKS.
It is on par with my slowest 486 (DX2/66), and about half the speed of
my fastest 486 (AMD 160). I thought these things were supposed to have
64 bit memory busses! Anyway, that's probably why it seems so slow at
normal tasks.
Hmm... Actually, I just ran the benchmark on my 5x86, and it gives
the same shape curve as the Alphas:
1k: 159719763
2k: 159770978
4k: 159648998
8k: 159333539
16k: 153094855 L1
32k: 88254014
64k: 88369331
128k: 88251360
256k: 71518883
512k: 61695135 L2
1024k: 53851179
2048k: 51091243
4096k: 50810323
The 5x86 has 512K L2 cache. I suspect the difference is that the
Pentium has separate L1 caches for instructions and data, whereas
the Alphas and 5x86 have unified L1 cache. We're seeing some
contention between data and instruction bandwidth. I'll bet this
also has some effect on real-life performance.
---
chris
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: Why is our Alpha box so slow?
1998-08-04 4:00 ` Chris Pirih, proverbs at wolfenet dot com
@ 1998-08-05 4:00 ` David A Willmore
1998-08-12 4:00 ` Chris Pirih, proverbs at wolfenet dot com
0 siblings, 1 reply; 22+ messages in thread
From: David A Willmore @ 1998-08-05 4:00 UTC (permalink / raw)
_@_._ (Chris Pirih, proverbs at wolfenet dot com) writes:
>My UDB gives similar strange results. It's supposed to have 256KB cache.
> 1k: 162429336
> 2k: 161239327
> 4k: 153634196
> 8k: 152466836 L1
> 16k: 115433109
> 32k: 115493359
> 64k: 115693927
> 128k: 54652508
> 256k: 33898287 L2
> 512k: 24448508
>1024k: 21316260
>2048k: 21236215
>4096k: 21339344
>As you can see by the 1024k-4096k numbers, main memory bandwidth SUCKS.
>It is on par with my slowest 486 (DX2/66), and about half the speed of
>my fastest 486 (AMD 160). I thought these things were supposed to have
>64 bit memory busses! Anyway, that's probably why it seems so slow at
>normal tasks.
IIRC, the '66s have a smaller than Alpha usual memory bus as they have a lower
pin count package and they use some of those scarse pins for an on chip PCI
bus, right? Also, most all FP code hits memory hard, so you're going to see
a great degredation in performance running that style of code on a 66.
Another point to consider is that GCC is somewhat unusual for integer code.
Normally the two buckets are int/good cache behavior and fp/bad cache behavior.
Now, those are gross generalizations, but they are normally correct.
GCC hits the memory system harder than any other int app I know of. Given
that you have a RISC system (somewhat larger code size, much larger pointer
size), you'll have a bigger cache footprint than an x86 running similar code.
So, since the normal GCC 'happy cache size' of 512k should be a bit bigger
on an alpha, I would guess that your true problem is that your cache size
is either set incorrectly, or, as Linus said, you're just suffering from
poor page coloring.
I'd feel sorry for you, but my 386SX-16 gets that job. :) It's got 4 meg,
it runs Linux 2.1.114, and, yes, it likes it.
Cheers,
David
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Why is our Alpha box so slow?
1998-08-05 4:00 ` David A Willmore
@ 1998-08-12 4:00 ` Chris Pirih, proverbs at wolfenet dot com
0 siblings, 0 replies; 22+ messages in thread
From: Chris Pirih, proverbs at wolfenet dot com @ 1998-08-12 4:00 UTC (permalink / raw)
In article <willmore.902336065@whelk>,
willmore@whelk.cig.mot.com (David A Willmore) wrote:
| I'd feel sorry for you,
No need to feel sorry for me; the UDB is just for porting. I have
plenty of fast machines for running Quake. :)
| but my 386SX-16 gets that job. :) It's got 4 meg,
| it runs Linux 2.1.114, and, yes, it likes it.
I'll bet that was quite a machine in 1988!
---
chris
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Why is our Alpha box so slow?
1998-08-03 4:00 ` Christian Weisgerber
1998-08-04 4:00 ` Linus Torvalds
1998-08-04 4:00 ` Chris Pirih, proverbs at wolfenet dot com
@ 1998-08-04 4:00 ` Christian Weisgerber
1998-08-06 4:00 ` Alex Rhomberg
1998-08-06 4:00 ` B. James Phillippe
4 siblings, 0 replies; 22+ messages in thread
From: Christian Weisgerber @ 1998-08-04 4:00 UTC (permalink / raw)
In article <6q55em$a58$1@mips.rhein-neckar.de>, I wrote:
> I'm told the machine needs about 2..3h to compile a kernel.
This has turned out to be an exaggeration. I finally managed to build
2.0.34 with <URL:http://www.unix-ag.uni-siegen.de/~engel/.config>.
Running in the background, it took ~40min wall-clock time, about 30min
user+system CPU time.
Judging from some of the comments, this seems to be the expected speed
for this type of machine. :-/
--
Christian "naddy" Weisgerber naddy@mips.rhein-neckar.de
100+ SF Book Reviews: <URL:http://home.pages.de/~naddy/reviews/>
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: Why is our Alpha box so slow?
1998-08-03 4:00 ` Christian Weisgerber
` (2 preceding siblings ...)
1998-08-04 4:00 ` Christian Weisgerber
@ 1998-08-06 4:00 ` Alex Rhomberg
1998-08-06 4:00 ` Robert Harley
1998-08-06 4:00 ` Christian Weisgerber
1998-08-06 4:00 ` B. James Phillippe
4 siblings, 2 replies; 22+ messages in thread
From: Alex Rhomberg @ 1998-08-06 4:00 UTC (permalink / raw)
Christian Weisgerber wrote:
>
> Some further details:
>
> Today I checked the hardware. The CPU clock is jumpered correctly to
> 233MHz. There are eleven -1024-20 cache RAMs and the cache speed jumper
> is set to the 20ns position. Looks okay to me.
>
> The box boots with MILO. It was originally shipped with a console for NT
> but the flash ROM has since been overwritten with MILO.
>
> I'm told the machine needs about 2..3h to compile a kernel. I haven't
> yet managed to build one, so I haven't verified this value.
>
> I have written a very simple program in an attempt to evaluate the
> memory bandwidth of the machine. Yes, it's primitive, but I didn't have
> a proper benchmark at hand. (Any pointers?) Basically all it does is run
> through <size> bytes of memory in a *p++ +=1 loop for 15s and count
> iterations. You'd expect that if <size> fits into the cache, there'll be
> more iterations.
>
> On my Pentium-100, 256k PB cache (FreeBSD 2.2.7, gcc 2.7.2.1, -O3), I
> get the expected result:
>
> 1k: 185500888 *
> 2k: 185921817 * 8k 1st level cache
> 4k: 186118297 *
> 8k: 184412946 *
> 16k: 158454103 .
> 32k: 158543035 .
> 64k: 158442354 . 256k 2nd level cache
> 128k: 158063623 .
> 256k: 157281569 .
> 512k: 123673105
> 1024k: 123498417 main memory
> 2048k: 123463409
> 4096k: 123659481
>
> The result on the Alpha box (Red Hat 5.1, 2.0.33, egcs-2.90.29, -O3) is
> bizarre:
>
> 1k: 149679693 *
> 2k: 149316456 * 8k 1st level cache
> 4k: 144773425 *
> 8k: 144881972 *
> 16k: 104659487 .
> 32k: 104677115 .
> 64k: 104652525 .
> 128k: 104110833 . huh!? we have 1M
> 256k: 56204479 of 2nd level cache
> 512k: 40814057
> 1024k: 32698979
> 2048k: 26571787 continuously getting slower!?
> 4096k: 24232887
You might want to replace the printf at the end with this:
printf("%4d kWord (%5d kByte): %12ld (%4ld MByte/s)\n",
i/1024, i*sizeof(WORD)/1024,
count, count*sizeof(WORD)/RUNTIME/1000/1000);
The output of this makes the same numbers than before less bizarre :)
The performance declines when you hit the 128kWord (=1MByte) cache size.
This explanation is probably a little bit simpler than the one about
cache colouring, though when I like at my results, he still has some
points :)
For comparison the output of my PWS500:
1 kWord ( 8 kByte): 824218968 ( 439 MByte/s)
2 kWord ( 16 kByte): 824224447 ( 439 MByte/s)
4 kWord ( 32 kByte): 812589096 ( 433 MByte/s)
8 kWord ( 64 kByte): 816114182 ( 435 MByte/s) (96 kByte 2nd
Level)
16 kWord ( 128 kByte): 691893296 ( 369 MByte/s)
32 kWord ( 256 kByte): 691897996 ( 369 MByte/s)
64 kWord ( 512 kByte): 688360238 ( 367 MByte/s)
128 kWord ( 1024 kByte): 587383787 ( 313 MByte/s)
256 kWord ( 2048 kByte): 476236828 ( 253 MByte/s) (The end of 2M 3rd
level)
512 kWord ( 4096 kByte): 453027348 ( 241 MByte/s)
1024 kWord ( 8192 kByte): 395769889 ( 211 MByte/s)
2048 kWord (16384 kByte): 337396159 ( 179 MByte/s)
4096 kWord (32768 kByte): 285814847 ( 152 MByte/s)
Regards
Alex
--
_________________________________________________________________
/ \
| Alex Rhomberg Tel: +41 1 632 49 18 |
| Institut fuer Elektronik Fax: +41 1 632 12 10 |
| ETH Zuerich Zentrale: +41 1 632 11 11 |
| Gloriastrasse 35 |
| 8092 Zuerich email: rhomberg@ife.ee.ethz.ch |
\_________________________________________________________________/
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: Why is our Alpha box so slow?
1998-08-06 4:00 ` Alex Rhomberg
@ 1998-08-06 4:00 ` Robert Harley
1998-08-06 4:00 ` Christian Weisgerber
1 sibling, 0 replies; 22+ messages in thread
From: Robert Harley @ 1998-08-06 4:00 UTC (permalink / raw)
Alex Rhomberg <rhomberg@ife.ee.ethz.ch> writes:
> [...]
> You might want to replace the printf at the end with this:
>
> printf("%4d kWord (%5d kByte): %12ld (%4ld MByte/s)\n",
> i/1024, i*sizeof(WORD)/1024,
> count, count*sizeof(WORD)/RUNTIME/1000/1000);
No, read his code again.
Rob.
__ . . ' . . . ' *
/\ \ . . . . . + .
____/_ \ \____ .-. .-. __ . * . . + . . .
/______\ \ \ /\/ \/ \ .-. __/ \________________________________
\ _____\ \/ / / /\ \/ \__/ \__/ \
\/ / / \/ / / / \ /\ / \__/ \__ Robert.Harley@inria.fr \
/ / /\__/_/_/\ / `-' \ \__/ \__/ \______________________________/
/ / /\ \_______\_' `-' \__/ \__/ . . +
\/__\ \ \______/ \__/ . . + .+. .
\ \ / . . + . . . . .
\_\/
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: Why is our Alpha box so slow?
1998-08-06 4:00 ` Alex Rhomberg
1998-08-06 4:00 ` Robert Harley
@ 1998-08-06 4:00 ` Christian Weisgerber
1 sibling, 0 replies; 22+ messages in thread
From: Christian Weisgerber @ 1998-08-06 4:00 UTC (permalink / raw)
(BTW, while I certainly appreciate the various comments, all these
copies by E-mail are very bad netiquette.)
> You might want to replace the printf at the end with this:
>
> printf("%4d kWord (%5d kByte): %12ld (%4ld MByte/s)\n", [...]
>
> The output of this makes the same numbers than before less bizarre :)
And wrong.
Check the program, it's really kBytes not kWords.
> The performance declines when you hit the 128kWord (=1MByte) cache
> size.
Nope. 128kB.
--
Christian "naddy" Weisgerber naddy@mips.rhein-neckar.de
100+ SF Book Reviews: <URL:http://home.pages.de/~naddy/reviews/>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Why is our Alpha box so slow?
1998-08-03 4:00 ` Christian Weisgerber
` (3 preceding siblings ...)
1998-08-06 4:00 ` Alex Rhomberg
@ 1998-08-06 4:00 ` B. James Phillippe
4 siblings, 0 replies; 22+ messages in thread
From: B. James Phillippe @ 1998-08-06 4:00 UTC (permalink / raw)
To: Christian Weisgerber
On 3 Aug 1998, Christian Weisgerber wrote:
> Some further details:
...
> I have written a very simple program in an attempt to evaluate the
> memory bandwidth of the machine. Yes, it's primitive, but I didn't have
Hey, this is a pretty cool utility. :) Here are the (*best*) results for
my AS200 4/233 unit. Most dropped off substantially at 256k.
% /tmp/cache-test
1k: 382522357
2k: 382387705
4k: 381646188
8k: 380285518
16k: 374499835
32k: 267253969
64k: 260420847
128k: 153378371
256k: 148622663
512k: 103563281
1024k: 83295467
2048k: 75724739
4096k: 73843686
cheers,
-bp
--
B. James Phillippe <bryan@terran.org>
Linux Software Engineer, WGT Inc.
http://earth.terran.org/~bryan
^ permalink raw reply [flat|nested] 22+ messages in thread