Board index » delphi » Re: Voting for FastCode rules on memory reading

Re: Voting for FastCode rules on memory reading


2005-05-10 01:23:28 AM
delphi37
Quote
>Can i take that as a yes?
[...]

I replied here before I saw the "Fastcode MM Validation" thread. I
got wishy-washy and didn't want this as a validation, but agreed that
it would make a good quality check because it is how I'd want the
MM to behave.

So yes, you counted my vote properly. What's your opinion on the
quality check?
Are we speaking about the same subject?
This rule but can be important to string-related challenges, but AFAIK
doesn't have much effect on memory managers. These are not likely to
benefit from reading extra data.
Memory managers can safely ignore this rule, for if one byte in a
memory page can be read, all can be read. The MM can not change this.
 
 

Re: Voting for FastCode rules on memory reading

Quote
>If there isn't a really good reason to impose the rule, it should be
>changed.
Can i take that as a yes?
There will be no error when reading extra-bytes, there are no strict
reason to decline this rule, just some programmer's habits:
keep a program clean (in this case while executing).
Florent
 

Re: Voting for FastCode rules on memory reading

Avatar Zondertau writes:
Quote
Are we speaking about the same subject?
Whoops. My first post was correct (s{*word*99} the rule unless there's a
good reason), but I got the threads confused after that. Please
disregard.
--
Regards,
Bruce McGee
Glooscap Software
 

Re: Voting for FastCode rules on memory reading

Avatar Zondertau writes:
Quote
Hi to all,

I would like to suggest a change of FastCode rules for reading memory.
I would suggest that these two rules:

- It is allowed to read past the end of AnsiStrings and WideStrings
including the dword containing the zero-terminator.

- It is not allowed to read past the end of ShortStrings and PChar
strings.

Be replaced by this new rule:

- It is allowed to read anywhere from any memory page containing at
least one byte of a ShortString, PChar, AnsiString or WideString
string, including a #0 terminator.

I would like us to vote on this issue.
My vote is: Yes.
--
Regards
Torjei Kvinen
 

Re: Voting for FastCode rules on memory reading

Quote
My vote is: Yes.
Then we now have the folllowing vote count:
In favor of changing rule: Aleksandr, Avatar, Bruce, Pierre,
Thorsten, Torjei
In favor of keeping rule: Dennis, Florent
Unsure (not clear from post): Anders
Unsure (depends on speed tests): Eric
 

Re: Voting for FastCode rules on memory reading

On 9 May 2005 12:26:14 -0700, "Avatar Zondertau" <XXXX@XXXXX.COM>
writes:
Quote

Unsure (not clear from post): Anders
That's because it is not very clear in my head either :-)
My first reaction is: "No way, you shouldn't allow this! It definitely
has a 'bad smell'."
Next: "But if we allow reading the full DWORD containing the last byte,
why not the full page?"
So,
1) How sure can we be that it will 'always' be allowed to read a full
page - at least some (very much) older computers had permission bits for
every memory cell!
2) Can the CPU actually, physically, access anything smaller than a
DWORD? Or will the memory access be a full DWORD even when I ask for a
byte?
After this short discussion with myself, I will cast my vote:
No, I don't think the rule should be changed.
(But feel free to ignore my opinion, as it is not built on any solid
fact, it is just an opinion)
--
Anders Isaksson, Sweden
BlockCAD: web.telia.com/~u16122508/proglego.htm
Gallery: web.telia.com/~u16122508/gallery/index.htm
 

Re: Voting for FastCode rules on memory reading

Hi Anders
You and I have the same opinion and understanding and "feeling" about this
;-)
Regards
Dennis
 

Re: Voting for FastCode rules on memory reading

Quote
>Unsure (not clear from post): Anders

That's because it is not very clear in my head either :-)

My first reaction is: "No way, you shouldn't allow this! It definitely
has a 'bad smell'."

Next: "But if we allow reading the full DWORD containing the last byte,
why not the full page?"

So,

1) How sure can we be that it will 'always' be allowed to read a full
page - at least some (very much) older computers had permission bits for
every memory cell!
The IA32 developer's manual volume 3 specifies that access permissions
can be set per page and per segment. It also specifies that pages are 4
KB, 2 MB or 4 MB. These specifications must hold for IA32 CPUs.
Segments are specified by Windows to be used for creating a flat memory
space; this means they cannot be used by Windows for protection (at
least not DS, ES and SS). To change this would break all existing
Windows programs.
Quote
2) Can the CPU actually, physically, access anything smaller than a
DWORD? Or will the memory access be a full DWORD even when I ask for a
byte?
Depens on what you count; IIRC cache lines are 32 bytes.
Quote
After this short discussion with myself, I will cast my vote:

No, I don't think the rule should be changed.

(But feel free to ignore my opinion, as it is not built on any solid
fact, it is just an opinion)
I won't ignore it; the same probably goes for most of us:
In favor of changing rule: Aleksandr, Avatar, Bruce, Pierre,
Thorsten, Torjei
In favor of keeping rule: Anders, Dennis, Florent
Unsure (depends on speed tests): Eric
 

Re: Voting for FastCode rules on memory reading

Hi Avatar
Thanks for keeping on top of this voting round. It takes some pressure of my
head ;-)
Quote
Depens on what you count; IIRC cache lines are 32 bytes.
32 byte L1 in P6
64 byte L1 in P4
128 byte L2 in P4
In favor of changing rule:
6 - Aleksandr, Avatar, Bruce, Pierre, Thorsten, Torjei
In favor of keeping rule:
3 - Anders, Dennis, Florent
Quote
Unsure (depends on speed tests): Eric
Eric: Could you gives us an update?
Regards
Dennis
 

Re: Voting for FastCode rules on memory reading

Quote
>Unsure (depends on speed tests): Eric
Eric: Could you gives us an update?
Hasn't changed much :)
I don't think there is much to gain in practice, but that could mean
trouble in corner cases, so unless I am wrong and there is a whole lot of
performance to gain, I would rather keep the strict rule.
Eric
 

Re: Voting for FastCode rules on memory reading

Hi
Quote
- It is allowed to read anywhere from any memory page containing at
least one byte of a ShortString, PChar, AnsiString or WideString
string, including a #0 terminator.
It looks like the rule should be added to the official set of rules on our
homepage today.
Just one question.
Do you think that Borland would like functions in the RTL that are based on
this rule?
Regards
Dennis
 

Re: Voting for FastCode rules on memory reading

Quote
>- It is allowed to read anywhere from any memory page containing at
>least one byte of a ShortString, PChar, AnsiString or WideString
>string, including a #0 terminator.

It looks like the rule should be added to the official set of rules
on our homepage today.

Just one question.

Do you think that Borland would like functions in the RTL that are
based on this rule?
You'd have to ask Danny about that.
If he doesn't we could keep the old rule for the RTL replacement
category.
 

Re: Voting for FastCode rules on memory reading

Hi Avatar
Quote
You'd have to ask Danny about that.
Yes
Quote
If he doesn't we could keep the old rule for the RTL replacement
category.
Perhaps we should just do that?
Regards
Dennis
 

Re: Voting for FastCode rules on memory reading

Quote
>You'd have to ask Danny about that.

Yes

>If he doesn't we could keep the old rule for the RTL replacement
>category.

Perhaps we should just do that?
Yes, that might be the best solution. That will allow FastCode to fully
use the hardware, while not scaring away Borland. Afterall since the
RTL replacement category doesn't allow MMX the rule change wouldn't
affect RTL replacement anyway.
 

Re: Voting for FastCode rules on memory reading

Quote
Afterall since the RTL replacement category doesn't allow MMX the rule
change wouldn't affect RTL replacement anyway.
In practice yes, but in theory no.
The rule allows you to read anywhere on the page no matter which
instruction
you use?
Regards
Dennis