Re: [fpc-pascal] How to avoid Copy

2023-12-29 Thread Amir via fpc-pascal
On Dec 29, 2023 9:50 PM, Adriaan van Os  wrote:Amir--- via fpc-pascal wrote:

> Hi all,

> 

>  I have a List of record, where the record has a WideString field.

>   I have some code like the following:

> 

> function check(constref v: TMyRecord; data: TListOfMyRecord): Boolean;

> var

>   r: TMyRecord;

> 

> begin

>   Result := False;

>   for r in data do

> if r.State = v.State then

>   Exit(True);

> end;

> 

> I call this method a lot and the CPU profiling shows a lot of cpu time 

> spent on "fpc_copy_proc" (which I assume is doing the deep copy on 

> records) from "TCustomListEnumerator.GetCurrent".

> I considered other alternatives like using enumerators but they all need 

> a to return a record (and hence copying the widestring field).

> I can think of two solutions to get rid of the wasting(!) so much time 

> on "fpc_copy_proc":

> 1) Changing the TMyRecord to TMyClass. But then I need to Create and 

> Free a "lot" of objects.

> 2) Update TListOfMyRecord to TListOfPointerToMyRecord. This requires a 

> "lot" of memory allocation/fragmentation.

> 

> Is there a better solution?



Pass the data parameter by reference.This means I need to have a ListOfMyRecord and a ListOfConstRefMyRecord, right?



Regards,



Adriaan van Os


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to avoid Copy

2023-12-29 Thread Adriaan van Os via fpc-pascal

Amir--- via fpc-pascal wrote:

Hi all,

 I have a List of record, where the record has a WideString field.
  I have some code like the following:

function check(constref v: TMyRecord; data: TListOfMyRecord): Boolean;
var
  r: TMyRecord;

begin
  Result := False;
  for r in data do
if r.State = v.State then
  Exit(True);
end;

I call this method a lot and the CPU profiling shows a lot of cpu time 
spent on "fpc_copy_proc" (which I assume is doing the deep copy on 
records) from "TCustomListEnumerator.GetCurrent".
I considered other alternatives like using enumerators but they all need 
a to return a record (and hence copying the widestring field).
I can think of two solutions to get rid of the wasting(!) so much time 
on "fpc_copy_proc":
1) Changing the TMyRecord to TMyClass. But then I need to Create and 
Free a "lot" of objects.
2) Update TListOfMyRecord to TListOfPointerToMyRecord. This requires a 
"lot" of memory allocation/fragmentation.


Is there a better solution?


Pass the data parameter by reference.

Regards,

Adriaan van Os
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] How to avoid Copy

2023-12-29 Thread Amir--- via fpc-pascal

Hi all,

 I have a List of record, where the record has a WideString field.
  I have some code like the following:

function check(constref v: TMyRecord; data: TListOfMyRecord): Boolean;
var
  r: TMyRecord;

begin
  Result := False;
  for r in data do
    if r.State = v.State then
  Exit(True);
end;

I call this method a lot and the CPU profiling shows a lot of cpu time 
spent on "fpc_copy_proc" (which I assume is doing the deep copy on 
records) from "TCustomListEnumerator.GetCurrent".
I considered other alternatives like using enumerators but they all need 
a to return a record (and hence copying the widestring field).
I can think of two solutions to get rid of the wasting(!) so much time 
on "fpc_copy_proc":
1) Changing the TMyRecord to TMyClass. But then I need to Create and 
Free a "lot" of objects.
2) Update TListOfMyRecord to TListOfPointerToMyRecord. This requires a 
"lot" of memory allocation/fragmentation.


Is there a better solution?

Best,
Amir
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Daily snapshots?

2023-12-29 Thread Thomas Kurz via fpc-pascal
Thank you. That's what I've been looking for. Maybe the documentation at 
https://www.freepascal.org/docs-html/user/userse76.html could be updated 
regarding the new URL?

@Nico: Thanks for pointing me to Docker images, but I do not have Docker 
support on my Windows, unfortunately. I furthermore fear that it might be 
complicated to use a dockerized Lazarus.

Is there something special I have to consider when combining FPC-trunk with 
Lazarus 3.0? I'd like to replace the provided FPC 3.2.2 with the latest trunk 
snapshot. I guess I have to recompile all packages? Is there something else I 
need to do?

Thank you,
kind regards,
Thomas




- Original Message - 
From: Marco van de Voort via fpc-pascal 
To: fpc-pascal@lists.freepascal.org 
Sent: Friday, December 29, 2023, 12:37:54
Subject: [fpc-pascal] Daily snapshots?


Op 27/12/2023 om 12:38 schreef Thomas Kurz via fpc-pascal:

> as it seems to take longer for the next major release, I'd appreciate if 
> automated snapshots could be provided either daily or weekly.

> In the documentation, I found a link to 
> ftp://ftp.freepascal.org/pub/fpc/snapshot/trunk/ but I cannot login. I tried 
> with user=anynous and password=my-email-address.

> I don't mind the long time for the next release, but it'd help enormously to 
> have the option to download an up-to-date nightly build :)

The FTP site has been converted to http because many browsers deprecated 
the FTP protocol, try http://downloads.freepascal.org/fpc/snapshot/fixes/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Daily snapshots?

2023-12-29 Thread Marco van de Voort via fpc-pascal



Op 27/12/2023 om 12:38 schreef Thomas Kurz via fpc-pascal:


as it seems to take longer for the next major release, I'd appreciate if 
automated snapshots could be provided either daily or weekly.

In the documentation, I found a link to 
ftp://ftp.freepascal.org/pub/fpc/snapshot/trunk/ but I cannot login. I tried 
with user=anynous and password=my-email-address.

I don't mind the long time for the next release, but it'd help enormously to 
have the option to download an up-to-date nightly build :)


The FTP site has been converted to http because many browsers deprecated 
the FTP protocol, try http://downloads.freepascal.org/fpc/snapshot/fixes/


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Daily snapshots?

2023-12-29 Thread Nico Neumann via fpc-pascal

Hi Thomas,

in case your platform allows to use Container images [1], you might give 
the Container images of FPC [2] a try.
The beta image is for the next released version of FPC (fixes_3_2 
branch) while the trunk/nightly uses the main branch. Depending on the 
image version you only need to download between 180 and 313 megabytes 
(the slim images with <50 megabytes are only built for released 
versions) [3, 4] and it's fully separated from your system installation. 
You can also use the Dockerfile locally to build the image on your own 
host. The trunk/nightly image is build every 2nd day-the-week while the 
beta image is currently only build on the 15th of each month (since 
there were almost no changes in the past). If a higher frequency is 
required, its not a problem - just let me know and I'll be changing the 
schedule.


[1]: https://wiki.freepascal.org/Official_Docker_Images
[2]: https://gitlab.com/freepascal.org/fpc/docker
[3]: https://hub.docker.com/r/freepascal/fpc
[4]: https://gitlab.com/freepascal.org/fpc/docker/container_registry/2747086

Kind regards
Nico

On 12/27/23 12:38, Thomas Kurz via fpc-pascal wrote:

Hello,

as it seems to take longer for the next major release, I'd appreciate if 
automated snapshots could be provided either daily or weekly.

In the documentation, I found a link to 
ftp://ftp.freepascal.org/pub/fpc/snapshot/trunk/ but I cannot login. I tried 
with user=anynous and password=my-email-address.

I don't mind the long time for the next release, but it'd help enormously to 
have the option to download an up-to-date nightly build :)

Kind regards,
Thomas

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal