Recent

Author Topic: Why CMem?  (Read 9640 times)

julkas

  • Guest
Why CMem?
« on: August 15, 2019, 01:45:27 pm »

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Why CMem?
« Reply #1 on: August 15, 2019, 01:49:50 pm »
Don't duplicate questions. Answered in the other thread.
Specialize a type, not a var.

julkas

  • Guest
Re: Why CMem?
« Reply #2 on: August 15, 2019, 01:53:01 pm »
Don't duplicate questions. Answered in the other thread.
Your answer is not clear for me.
Moderator - If my question is duplicated, please remove my post.

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Why CMem?
« Reply #3 on: August 15, 2019, 02:12:00 pm »
Specialize a type, not a var.

julkas

  • Guest
Re: Why CMem?
« Reply #4 on: August 15, 2019, 02:15:32 pm »
Yes @Thaddy. Same, but in other topic (post). I want clear answer.
And I think nobody can give me clear answer. Even FPC developers.
« Last Edit: August 15, 2019, 02:24:21 pm by julkas »

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Why CMem?
« Reply #5 on: August 15, 2019, 02:36:02 pm »
My guess? To make it a fairer comparison. Read the intro at "Free Pascal versus C++ g++ fastest programs"
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

julkas

  • Guest
Re: Why CMem?
« Reply #6 on: August 15, 2019, 02:44:00 pm »
My guess? To make it a fairer comparison. Read the intro at "Free Pascal versus C++ g++ fastest programs"
Quote
"measuring the quality of the generated code when both compilers are presented with what amounts to the same program."
Quote
These are only the fastest programs.

julkas

  • Guest
Re: Why CMem?
« Reply #7 on: August 15, 2019, 03:29:08 pm »
FastMM, ScaleMM, BrainMM, FPC memory manager. So - CMem?

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Why CMem?
« Reply #8 on: August 15, 2019, 03:35:06 pm »
I want clear answer.
That is a benchmark game, and since FPC has a choice with memory managers author probably tried them all and left the faster one.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

julkas

  • Guest
Re: Why CMem?
« Reply #9 on: August 15, 2019, 03:38:05 pm »
I want clear answer.
That is a benchmark game, and since FPC has a choice with memory managers author probably tried them all and left the faster one.
Why CMem is the faster one?
Yes, this is a game.
« Last Edit: August 15, 2019, 03:43:02 pm by julkas »

BrunoK

  • Sr. Member
  • ****
  • Posts: 452
  • Retired programmer
Re: Why CMem?
« Reply #10 on: August 15, 2019, 04:35:00 pm »
Because cmem seems faster in multithreaded applications (by much) whereas there is no noticable difference with heap.inc in single threaded apps. 
At least on windows.

julkas

  • Guest
Re: Why CMem?
« Reply #11 on: August 15, 2019, 05:39:13 pm »
Because cmem seems faster in multithreaded applications (by much) whereas there is no noticable difference with heap.inc in single threaded apps. 
At least on windows.
https://github.com/graemeg/freepascal/blob/master/rtl/inc/cmem.pp

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Why CMem?
« Reply #12 on: August 15, 2019, 07:45:36 pm »
Why do you refer to a fork instead of the real code available from freepascal.org? It is the exact same and usually more current.
Specialize a type, not a var.

Akira1364

  • Hero Member
  • *****
  • Posts: 561
Re: Why CMem?
« Reply #13 on: August 17, 2019, 05:46:37 am »
Why do you refer to a fork instead of the real code available from freepascal.org? It is the exact same and usually more current.

It's a direct mirror of the trunk FPC SVN, not a fork.

Why https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/binarytrees-fpascal-7.html uses CMem memory manager?

As the person who submitted that version of the benchmark: because CMem significantly improves the performance of multi-threaded applications in general (on Windows too, by the way). The execution time for that program without CMem is WAY longer than 3.06 seconds, to say the very least.
« Last Edit: August 17, 2019, 05:48:10 am by Akira1364 »

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Why CMem?
« Reply #14 on: August 17, 2019, 07:28:00 am »
When we measured the different memory managers during the Delphi memory manager challenge we had a different conclusion, at least compared to the newer per thread allocators like scalemm, smartmm and topmm and family. It may be that a FPC conversion is possible for those. The most important think conclusion was that the Delphi MM (FastMM) and cmem do not scale.
In some applications cmem indeed outperforms the fpc default a memory manager, but it depends on application as I explained.
The benchmark sourcecode (for 32 bit) can be optained from http://fastcode.sourceforge.net/. My old collegue Andre Musche has likely a 64 bit version of SmartMMv2 as well. I will ask him.
(Lock-free context switching) My other former collegue Ivo Tops wrote topmm.
I can prepare those (smartmmv2 and topmm) for fpc - windows32/64 (did that before, but code is not current: fpc 2.0.)
[to be completed with example]
« Last Edit: August 17, 2019, 10:08:02 am by Thaddy »
Specialize a type, not a var.

 

TinyPortal © 2005-2018