Dramatic speed effect of code-data proximity
- From: spamtrap@xxxxxxxxxx
- Date: 29 Aug 2006 07:06:33 -0700
Can somebody please explain this effect, observed using a Pentium 4 HT?
The following 32-bit code executes at a dramatically different speed
depending on whether or not the address 'var' is in the same 1 Kbyte
memory page as the code accessing it:
mov ecx,10000000H
test:
mov [var],eax
loop test
The measured timing was about 250 ms when the address 'var' was not in
the same 1 Kbyte page as the code (above or below) but about 36000 ms
(i.e. more than 100 times slower!) when the address 'var' was in the
same 1 Kbyte page as the code. I didn't believe this when I first saw
it but it seems to be easily reproducible.
I'm guessing that the data write invalidates the code cache, requiring
it to be reloaded from main memory each time around the loop. That
would explain the dramatic effect, but I'm not too sure why it should
be necessary.
Richard.
http://www.rtrussell.co.uk/
To reply by email change 'news' to my forename.
.
- Follow-Ups:
- Re: Dramatic speed effect of code-data proximity
- From: Mark_Larson
- Re: Dramatic speed effect of code-data proximity
- From: robertwessel2@xxxxxxxxx
- Re: Dramatic speed effect of code-data proximity
- Prev by Date: Could not switch back to Real-Address mode from Protected Mode. Help?
- Next by Date: Re: Dramatic speed effect of code-data proximity
- Previous by thread: Could not switch back to Real-Address mode from Protected Mode. Help?
- Next by thread: Re: Dramatic speed effect of code-data proximity
- Index(es):