The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Archive for the ‘FastMM’ Category

Have NoMessageBoxes depend on a global boolean · Issue #58 · pleriche/FastMM4 · GitHub

Posted by jpluimers on 2018/08/16

Reminder to self: [WayBackHave NoMessageBoxes depend on a global boolean · Issue #58 · pleriche/FastMM4 · GitHub

–jeroen

Posted in Delphi, Development, FastMM, Software Development | Leave a Comment »

A success story – kudos to ScaleMM, +André Mussche… – Ondrej Kelle – Google+

Posted by jpluimers on 2018/08/15

Though no maintenance for over 2 years, it ScaleMM seems among the fastest of Delphi memory managers: [WayBack] GitHub – andremussche/scalemm: Fast scaling memory manager for Delphi

Full story via [WayBackA success story – kudos to ScaleMM, +André Mussche… – Ondrej Kelle – Google+ at [WayBack] just tried Scaled MM – cut the time for 100k down from 51 minutes to 40 minutes. That’s with 18 (9+9) cores allocated to the app and 2 to everything else. Wow, allocating 8 + 8 and the time drops even more… – Russell Weetch

Two lessons on multi-threading here:

  • use a memory manager that copes well with threads
  • do not allocate more busy threads than available (hyper-threaded) cores

Some history (as ScaleMM, TopMM and FastMM seem to be related):

  • A bit of history here: at the time we had the mm contest. Not many people had access to 8 cores+, we had…. Andre and Ivo were both colleagues of mine at that point, although working for different companies. We needed (stock trading, Ivo and me) something to scale and Ivo wrote topmm, which still performs better on multi-cores than fastmm and has less assembler code. Andre improved on Ivo’s concepts and yes, it really outperforms fastmm on multi-cores today.
    It also out-performs most C family provided mm’s. Note I was not massively involved, but both Ivo and Andre were. And both did a proper job. So KUDOS to them.
    Note these (fastmm and topmm) were written with multi-core in mind. The practical results at the time were often under-estimated, because few people had access to the real hardware. Most of us running two cores at most. Nice to see that the concept those two programmers pursued still pays dividend in 2018!
  • Read: ScaleMM and TopMM and FastMM… Keyboard left me..
    (I wrote COMMM as a joke..!).
  • [WayBack] TopMemory v3.55. High Performance. Fully Scalable. Free. Memory Manager. for. Delphi – PDF
  • [WayBack] FPC Anagrams

There are also some IntelTBB memory manager references at https://plus.google.com/+RussellWeetch/posts/W4EQgLme5ud [WayBack]

–jeroen

Posted in Delphi, Development, FastMM, Software Development | Leave a Comment »

“Unknown function at TMethodImplementationIntercept”

Posted by jpluimers on 2018/06/01

Reminder to self: when you get Unknown function at TMethodImplementationIntercept in a Delphi stack trace from the Exception.StackTrace property or FastMM memory report:

  1. Ensure you generate a .MAP or .TDS file with full debug information
  2. Copy the .MAP or .TDS files to directory of your EXE.

Via:

The Exception.StackTrace was introduced in Delphi 2009 that extended these [WayBackException Members:

Some notes:

  • Fields where you can put hooks in; if there is no hook in place, they won’t be used:
    • [WayBackException.GetExceptionStackInfoProc Field GetExceptionStackInfoProc: function (P: PExceptionRecord): Pointer;
      • This function is called to return an opaque data structure that contains stack information for the given exception information record. This function will be called when the exception is about to be raised or if this is an external exception such as an Access Violation, called soon after the object is created.
    • [WayBackException.CleanUpStackInfoProc Field CleanUpStackInfoProc: procedure (Info: Pointer);
      • This function is called when the destructor is called to clean up any data associated with the given opaque data structure.
    • [WayBackException.GetStackInfoStringProc Field GetStackInfoStringProc: function (Info: Pointer): string;
      • This function is called to return a string representation of the opaque data structure returned by GetExceptionStackInfoProc

TMethodImplementationIntercept was introduced in the System.Rtti unit of Delphi XE6 [WayBack]:

–jeroen

Example code:


unit ExceptionHelperUnit;
interface
uses
System.SysUtils;
type
ExceptionHelper = class helper for Exception
public
function Describe: string;
class procedure RaiseNotImplementedException(const aClass: TClass; const aMethodName: string);
class function GetStackTrace: string;
end;
implementation
uses
System.RTLConsts,
System.SysConst;
type
EStackTraceException = class(Exception); // EProgrammerNotFound to make it really clear this is only to be used in very limited places ??
{ ExceptionHelper }
function ExceptionHelper.Describe: string;
var
lStackTrace: string;
begin
Result := inherited ToString();
if Self is EInOutError then
if Result = System.RTLConsts.SInvalidFileName then
Result := System.SysConst.SInvalidFileName;
if Assigned(StackInfo) then
lStackTrace := StackTrace
else
lStackTrace := 'empty';
Result := Format('Exception'#13#10'%s at $%p: %s'#13#10'with StackTrace'#13#10'%s', [ClassName, ExceptAddr, Result, lStackTrace]);
end;
class function ExceptionHelper.GetStackTrace: string;
begin
try
Result := 'Get StackTrace via Exception.';
raise EStackTraceException.Create(Result) at ReturnAddress;
except
on E: EStackTraceException do
Result := E.StackTrace;
end;
end;
class procedure ExceptionHelper.RaiseNotImplementedException(const aClass: TClass; const aMethodName: string);
begin
raise ENotImplemented.CreateFmt('Method %s.%s is not implemented.', [aClass.ClassName, aMethodName]);
end;
end.

Posted in Delphi, Development, FastMM, Software Development | Leave a Comment »

Delphi: There is a FastMM4 fork with AVX support and multi-threaded enhancements (faster locking) – how will it impact floating point heavy applications (as Delphi uses SSE instructions for floating point)

Posted by jpluimers on 2018/05/01

Interesting fork of FastMM4 for which I now think I understand why it is not merged into the regular FastMM4 repository: [WayBack] GitHub – maximmasiutin/FastMM4-AVX: FastMM4 fork with AVX support and multi-threaded enhancements (faster locking).

The fork does two things:

  • it has multi-threading enhancements (faster locking)
  • AVX support which seems tough for floating point heavy applications as Delphi generates SSE instructions for them

Reminder to self: how big is that impact and could the locking be separately merged into the base repository?

Eric Grange:
Looking at https://github.com/pleriche/FastMM4/issues/36 and given than the compile generates SSE2 code for floating point, I guess using AVX may be problematic when your code also does a lot of floating point using Delphi code (rather than AVX asm)

It could be that this repository is using only AVX-128, which might not have a penalty as per Advanced Vector Extensions – Wikipedia:

The AVX instructions support both 128-bit and 256-bit SIMD. The 128-bit versions can be useful to improve old code without needing to widen the vectorization, and avoid the penalty of going from SSE to AVX, they are also faster on some early AMD implementations of AVX. This mode is sometimes known as AVX-128.

Via: [WayBack] Do you use Embarcadero version of FastMM or the “official” bleeding edge version of FastMM from the gitHub repository? Any idea what are the difference… – Tommi Prami – Google+

–jeroen

Posted in Delphi, Development, FastMM, Software Development | 6 Comments »

Delphi Corner Weblog: New: Velthuis.AutoConsole unit – helps against the “optimised” Embarcadero FastMM fork.

Posted by jpluimers on 2017/05/17

Brilliant:

if it is a console program and it was started any other way (from the Windows Explorer, from the Delphi IDE with or without debugger, from another non-console program), then, before the console window can close, it will display:

Press any key...

Source: Delphi Corner Weblog: New: Velthuis.AutoConsole unit [WayBack]

via:

–jeroen

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, FastMM, Software Development | Leave a Comment »

New experimental FastMM version was committed to https://github.com/gabr42/…

Posted by jpluimers on 2016/03/22

The comments show some nice links to comparison overviews of hashing algorithms.

New experimental FastMM version was committed to https://github.com/gabr42/FastMM4/tree/Locking_Improvements.New in this version:- Slightly simplifie… – Primož Gabrijelčič – Google+

Source: New experimental FastMM version was committed to https://github.com/gabr42/Fa…

–jeroen

Posted in Delphi, Development, FastMM, Software Development | Leave a Comment »

FastMM4 moved from SF.net to GitHub – pleriche/FastMM4@245706d

Posted by jpluimers on 2016/02/23

Updated the homepage in the source and readme to reflect the move to GitHub.

Source: pleriche/FastMM4@245706d

In related news: Primož Gabrijelčič is contributing to it as well: his pull request got processed https://github.com/pleriche/FastMM4/pull/1 implemented FastReallocMem logger.

–jeroen

via: Edwin Yip Delphi Developers

 

Posted in Delphi, Development, FastMM, Software Development | Leave a Comment »

Delphi prebuild/prelink/postbuild events

Posted by jpluimers on 2014/11/20

Ever since the Delphi build engine got changed to MS Build in Delphi 2007, many people use Delphi build events. Their order is prebuild, prelink and postbuild (or maybe better spelled pre-build, pre-link and post-build).

Before Delphi 2007, you had to fiddler with project groups and dependencies to fake pre-build and post-build events. For an example see Pre and Post-Build Automation in Delphi.

One of the really good things about these events is that build events appear in the output tab of the messages window.

One of the really bad things is that there is hardly any documentation about the build events.

At least two important things are missing:

  1. How the lines of a build event are actually executed
  2. How parameter expansion works inside build events

Let’s explain these. Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Development, Event, FastMM, QC, Software Development | 5 Comments »

OS X FullDebugMode support added by Sebastian Zierer (Thanks!) in FastMM / Code / Commit [r67]

Posted by jpluimers on 2014/04/10

I just discovered that almost 2 weeks ago, the FastMM code repository added support for these defines in Mac OS X in Commit [r67].:

  • FullDebugMode
  • LogErrorsToFile
  • LogMemoryLeakDetailToFile

This is great news!

Note: this is not a full FastMM release, but since the original change by Sebastian Zierer has been done about half a year ago, the code is pretty stable.

Thanks mnasman for mentioning this on Delphi Redit, and Ralf Stocker for announcing this in the Non-Tech newsgroup.

–jeroen

via: FastMM / Code / Commit [r67].

Posted in Delphi, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Development, FastMM, Software Development | 2 Comments »

FastMM4 FullDebugMode quick tip: don’t forget to give your EXE access to the correct FullDebugMode.dll

Posted by jpluimers on 2014/03/06

If you run FastMM4 in FullDebugMode, then here are two tips that new (and sometimes existing users) often overlook:

  1. If you set the FullDebugMode directive in the IDE, build your project.
  2. Don’t forget to give your EXE access to FastMM_FullDebugMode.dll (x86), or FastMM_FullDebugMode64.dll (x64) which are stored in the FastMM4 download and in the precompiled directory of the source code.
    Either put that DLL in your path, or copy it to your EXE directory.
  3. Make sure your EXE can write in the directory of the EXE.

The first makes sure all units are compiled with FullDebugMode (Delphi does not always do that automagically).

The second makes sure your EXE can access the DLL that writes out your *MemoryManager_EventLog.txt file containing memory leaks and other issues FastMM4 detected.

–jeroen

Posted in Conference Topics, Conferences, Delphi, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Development, Event, FastMM, Software Development | 2 Comments »