#1 Re: Low level and performance » Delphi doesn't like multi-core CPUs (or the contrary) » 2013-02-05 19:31:22

Thanks for the feedback.

I hope I am on the right track with regard to gaining an overall improvement in performance.

Here is what I've done thus far ..

On our Delphi 7 buidl server

- Patched to D7 update 1
- Downloaded the precompiled System.dcu and SysInit.dcu, and placed over the existing ones
- Put ScaleMM2 as the preferred memory manager

I've done a build, and local tests, and everything appears to be just fine.

I've released this to a VM with 8 cores, and can see a significant performance gain.

When I take this same code to a much more powerful system (4 physical CPU, 8 core each --> total 32 cores), I see a decrease in performance (it got worse, by a very large margin).

I am running 32 TThreads.  These threads are pretty lightweight, but represent a  logical/isolated task (with a TDOAConnection on each).

What I seeing on our internal VM is a if CPU shows 80-90%, the kernel makes up about half of that.
What I seeing on our more powerful, non-VM system is if CPU shows 80-90%, the kernel makes up about 95+% of that.

On this 32 core system, it is actually significantly faster (almost 2-3x faster) with running 16 threads as it is running 32 threads.  I see no other contention on the DB or anything else.  It appears to be entirely within the delphi portion.

Our threads each have their own queue of work which are protectively pulling from and the main thread protectively adds to (protectively = TCriticalSection with a private member variable (FDummy: Array[0..95] Of Byte);

Am I right in thinking that kernel time = bad, and most likely related to locking as referenced here?

I appreciate the insights.

#2 Re: Low level and performance » Delphi doesn't like multi-core CPUs (or the contrary) » 2013-02-05 03:59:31

Most of this is pretty deep, and I don't pretend to get it all, but I think I have the main concepts to avoid.   Looking for clarification/confirmation.

For a Delphi 7 environment, Is this the correct summary of what to do to ensure we don't have issues with my binaries running on multiple processor/multiple core systems ...

- Apply the Enhanced Runtime Library (replace with apprpriate System.dcu & SysInit.dcu's)
- Replace memory manager with ScaleMM2 or equivalent, does FastMM4 have this issue as well?
- Replace TThread with my own class, that ties directly to the Win32 API for creating threads
- In threads, avoid String (or more specifically, use ShortString)

I am sure there's tons more, but from what I can gather, these are the main tasks.

I don't work too often in Delphi anymore, but have recently run into performance issues on a 32 core system that appears to be a ton of contention within the threading; and cant help but think its directly tied to the points you are making here.

Thanks in advance, for the help. 

PS - Any other points for Delphi 7 as it relates to this topic would be appreciated.

Board footer

Powered by FluxBB