Re: [fpc-pascal] Effective memory allocation

2014-11-04 Thread Bruno Krayenbuhl
Relooking at your timings and mine, it appears that you allocate 10x my count of register-size count of items and require 10x the FillChar which you need to initialize your filter array. My timing is about 80 ms and yours looks like 900 ms for 10x more register sized data, which look like the

Re: [fpc-pascal] Effective memory allocation

2014-11-03 Thread Bruno Krayenbuhl
My results : _Ptr:=GetMem(1)18 mus, 824 ns / GetMem _Ptr:=GetMem(1) + FillChar(_Ptr^,1,0)); 81 ms / GetMem + FillChar var ArInt:array of int32; . SetLength(ArInt, 1 shr 2); 81 ms / SetLength All timings are variable within [time, time+8%] on

Re: [fpc-pascal] Effective memory allocation

2014-11-03 Thread Sven Barth
Am 03.11.2014 08:32 schrieb Nico Erfurth n...@erfurth.eu: On 02.11.14 15:05, Xiangrong Fang wrote: Sorry, the results in previous mail was mis-labeled. ​ The result is: Using SetLength: Alloc: 9.40781697E-0001 Clear: 2.13420202E-0001 Using GetMemory:

Re: [fpc-pascal] Effective memory allocation

2014-11-03 Thread Adriaan van Os
Xiangrong Fang wrote: Hi All, I am programming a Bloom Filter and need a high-performance way to On what platform are you doing this ? Regards, Adriaan van Os ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

Re: [fpc-pascal] Effective memory allocation

2014-11-03 Thread Xiangrong Fang
2014-11-03 23:40 GMT+08:00 Adriaan van Os f...@microbizz.nl: Xiangrong Fang wrote: Hi All, I am programming a Bloom Filter and need a high-performance way to On what platform are you doing this ? ​I am programming on Linux, but it will be used on both Windows and Linux, Windows is the

Re: [fpc-pascal] Effective memory allocation

2014-11-03 Thread Nico Erfurth
Hi, Hi All, I am programming a Bloom Filter and need a high-performance way to On what platform are you doing this ? ​I am programming on Linux, but it will be used on both Windows and Linux, Windows is the primary target.​ Well, the first thing you should ask

Re: [fpc-pascal] Effective memory allocation

2014-11-03 Thread Xiangrong Fang
2014-11-04 6:35 GMT+08:00 Nico Erfurth n...@erfurth.eu: Well, the first thing you should ask yourself is Do I REALLY need such a large bloom filter. Everything larger than the last level cache will seriously harm your performance as you are going to trigger a lot of cache and TLB misses. In

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Xiangrong Fang
Sorry, the results in previous mail was mis-labeled. ​ The result is: Using SetLength: Alloc: 9.40781697E-0001 Clear: 2.13420202E-0001 Using GetMemory: Alloc: 2.8100E-0005 Clear: 7.74975504E-0001 ___

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Sven Barth
Am 02.11.2014 14:55 schrieb Xiangrong Fang xrf...@gmail.com: Hi All, I am programming a Bloom Filter and need a high-performance way to allocate and wipe large block of memory. I did the following test: program getmem; {$mode objfpc}{$H+} uses epiktimer; const SIZE = 1024 * 1024 *

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Constantine Yannakopoulos
On Sun, Nov 2, 2014 at 3:54 PM, Xiangrong Fang xrf...@gmail.com wrote: Also, I usually use pointer to pass block of memory to functions. How do I implement a function with the following signature: procedure MyProc(var Buf; Len: Integer): I mean, how to handle var Buf inside the procedure

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Xiangrong Fang
2014-11-03 2:50 GMT+08:00 Sven Barth pascaldra...@googlemail.com: If you use SetLength the dynamic array consists not only of the array data, but also of an information record in front of it. This will likely lead to the data not being aligned correctly (FillQWord works best with 8-Byte

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Sven Barth
On 03.11.2014 02:59, Xiangrong Fang wrote: 2014-11-03 2:50 GMT+08:00 Sven Barth pascaldra...@googlemail.com mailto:pascaldra...@googlemail.com: If you use SetLength the dynamic array consists not only of the array data, but also of an information record in front of it. This will

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Nikolay Nikolov
On 11/02/2014 03:54 PM, Xiangrong Fang wrote: Hi All, ... Also, I usually use pointer to pass block of memory to functions. How do I implement a function with the following signature: procedure MyProc(var Buf; Len: Integer): I mean, how to handle var Buf inside the procedure body? You

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Nico Erfurth
On 02.11.14 15:05, Xiangrong Fang wrote: Sorry, the results in previous mail was mis-labeled. ​ The result is: Using SetLength: Alloc: 9.40781697E-0001 Clear: 2.13420202E-0001 Using GetMemory: Alloc: 2.8100E-0005 Clear: 7.74975504E-0001

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Xiangrong Fang
2014-11-03 14:39 GMT+08:00 Sven Barth pascaldra...@googlemail.com: Would you mind to show the timings that you got for FillChar? :) ​Using FillChar is always about 5% (or less) faster than FillQWord when used with GetMemory, but will be around 20%-40% faster if the memory is allocated by