Recent

Author Topic: Lazarus IDE with Cmem  (Read 3403 times)

julkas

  • Guest
Re: Lazarus IDE with Cmem
« Reply #15 on: August 15, 2019, 12:56:08 pm »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Lazarus IDE with Cmem
« Reply #16 on: August 15, 2019, 01:09:54 pm »
That code runs on Linux, where it is somewhat more standard.

Cmem on Windows is ambiguous by default, since MSVC is the system C compiler, but FPC is mostly compatible with GCC (which again comes in many flavours like cygwin and mingw on Windows). And with many C compiler flavours come many C compiler runtimes.

julkas

  • Guest
Re: Lazarus IDE with Cmem
« Reply #17 on: August 15, 2019, 01:19:39 pm »
Quote
That code runs on Linux, where it is somewhat more standard.
That code runs not only on Linux
Code: Pascal  [Select][+][-]
  1. {$IFDEF UNIX}CThreads,{$ENDIF}
I have tested that code on Win32 Vista.

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: Lazarus IDE with Cmem
« Reply #18 on: August 15, 2019, 01:30:41 pm »
Yes, but the point is the actual memory aloc/de-alloc implementation of the C compiler you used.
E.g. with other such "tests" on Raspbian and Debian arm I get much differing results between cmem and the default memory manager with GNU C for armhf.
cmem runs out of memory sooner because of the page size. Other C compilers for ARM do have a noticable effect (the one from ARM itself is a good example).
It depends on application., likely even the type of C libraries you interface with if it has any positive impact at all.
Also note the FPC default settings are extremely conservative compared to C compilers, so you may want to explore the optimization options first:
Alignment, CPU settings, optimization -O settings and even the FPU, e.g. vector math for moves is not used in default fpc. But all these things may have been done in a C version for you and they are not done for you in FPC.
Also note the LLVM back-end can improve things. And furthermore, at least on Intel, there are third-party open source Delphi memory managers that outperform both cmem and the fpc default by several magnitudes in a mutithreading application. These memory managers are easily adapted to Freepascal. There are several real - solid - performance tests available for those memory managers in which cmem is also tested and comes second from last. Memory use can be explosive with cmem, whereas fragmentation is an issue with the FPC default, both when stressed.
The delphi ones I mentioned all have per thread allocators, btw. Cmem does not do that, at least not with the GCC compiler.

One thing to note: in the compiler shoot-out (even with an older fpc) the fpc default memory allocator performs best in memory use offset to others that favor speed at the cost of memory.
But then again: memory managers are pluggable in FPC.
« Last Edit: August 15, 2019, 01:53:29 pm by Thaddy »
Specialize a type, not a var.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Lazarus IDE with Cmem
« Reply #19 on: August 15, 2019, 02:45:53 pm »
Quote
That code runs on Linux, where it is somewhat more standard.
That code runs not only on Linux
Code: Pascal  [Select][+][-]
  1. {$IFDEF UNIX}CThreads,{$ENDIF}
I have tested that code on Win32 Vista.

That is part of a standard new program template. Not necessarily a sign it was prepared to run on windows.

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: Lazarus IDE with Cmem
« Reply #20 on: August 16, 2019, 09:40:24 pm »
And the answer to OP is: Yes I did tried your example and gave you the answer.
Specialize a type, not a var.

 

TinyPortal © 2005-2018