[fpc-devel] Fwd: Re: An optimization suggestion for FPC

J. Gareth Moreton gareth at moreton-family.com
Sun Jun 28 13:34:21 CEST 2020


Hi Benito,

I'll see what I can do in that case.  I sense the optimisation may have 
to be done on a per-architecture basis because of it depending on how 
records are stored in memory.  I'll see what I can do though.  If it has 
to be a per-architecture optimisation, I'll only be able to do it for 
i386, x86_64 and whatever ARM processor is in my Raspberry Pi!

Gareth aka. Kit

On 28/06/2020 12:22, Benito van der Zander wrote:
> Hi J. Gareth,
>
> that is a really important optimization.
>
> Especially with new record management operators. I am going to wrap 
> almost all my variables in records, so they will be automatically 
> initialized.
>
> I have suggested it in the bug tracker, but it was closed, because 
> they say the bug tracker is not for suggestions: 
> https://bugs.freepascal.org/view.php?id=34915
>
> Bye,
> Benito
> On 28.06.20 12:31, J. Gareth Moreton wrote:
>>
>> So someone reached out to me directly again asking for an FPC 
>> optimisation.  Now I want to see if this is possible to optimise and 
>> won't break something or be annoying specific.
>>
>> Gareth aka. Kit
>>
>> -------- Forwarded Message --------
>> Subject: 	Re: An optimization suggestion for FPC
>> Date: 	Sun, 28 Jun 2020 11:30:09 +0100
>> From: 	J. Gareth Moreton <gareth at moreton-family.com>
>> To: 	Okoba <okobapatino at protonmail.com>
>>
>>
>>
>> Heh, I'm honoured you came to me directly.  I'll see if I can work 
>> anything out.  A lot of it is down to where the record is stored.  If 
>> it's on the stack, an optimisation shouldn't be difficult, but if 
>> it's on the heap somewhere, then it will be a bit more difficult.  Do 
>> you have your C++ example, and which C++ compiler did you use?
>>
>> Gareth aka. Kit
>>
>> On 28/06/2020 11:06, Okoba wrote:
>>> Hi,
>>> It seems you are interested in optimizing FPC and I have a trouble 
>>> with it and wanted to check it with you if I may.
>>> I like to have a way to pass the record variable and inc it without 
>>> losing speed. I wrote a sample and ran it with FPC trunk in Win64 
>>> and the times are commented. I should say the times for Delphi for 
>>> the same target is the same. And tried a C++ version and all the 
>>> times are almost the same and near 250.
>>> I tried many ways including absolute, pointer, custom asm functions, 
>>> custom functions with const and var params and the are almost always 
>>> slower than the first loop.
>>> So is there anyway to have a custom Inc function that get he record 
>>> variable and inc it without losing speed in compare to the system inc?
>>>
>>> Regards.
>>>
>>>
>>>
>>> program Project1;
>>>
>>> uses
>>>   SysUtils;
>>>
>>> type
>>>   TTest = record
>>>     P: int64;
>>>   end;
>>>
>>>   procedure Test;
>>>   var
>>>     V: TTest;
>>>     P: int64;
>>>     T: UInt64;
>>>     i, C: integer;
>>>   begin
>>>     C := 1000 * 1000 * 1000;
>>>
>>>     T := GetTickCount64;
>>>     P := 1;
>>>     for i := 1 to C do
>>>       Inc(P);
>>>     WriteLn(GetTickCount64 - T); //266
>>>
>>>     T := GetTickCount64;
>>>     V.P := 1;
>>>     for i := 1 to C do
>>>       Inc(V.P);
>>>     WriteLn(GetTickCount64 - T); //1400
>>>
>>>     T := GetTickCount64;
>>>     V.P := 1;
>>>     P := V.P;
>>>     for i := 1 to C do
>>>       Inc(P);
>>>     P := V.P;
>>>     WriteLn(GetTickCount64 - T);  //250
>>>   end;
>>>
>>> begin
>>>   Test;
>>>   ReadLn;
>>> end.
>>>
>>
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> 
>> 	Virus-free. www.avast.com 
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> 
>>
>>
>> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> _______________________________________________
>> fpc-devel maillist  -fpc-devel at lists.freepascal.org
>> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


-- 
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20200628/6e5d9889/attachment-0001.htm>


More information about the fpc-devel mailing list