1. Boris Gonzhalenko
  2. PowerBuilder
  3. Thursday, 1 June 2023 09:50 AM UTC

I've noticed that a huge power builder application shows very poor perfomance on multi-core processors, while it may work several times faster on one-core processor with the same input. While analysing this issue I discovered that an application tends to use just one core out of 4 or 6, and probably this creates a bottleneck.

I'd like to ask if there're some ways to change compile options of Power Builder application, to make it optimized for multi-core calculation? Or if there're some instructions I must include in the code, to mark the cycles that may be suitable for parallel execution?

Glenn Barber Accepted Answer Pending Moderation
  1. Tuesday, 2 July 2024 18:40 PM UTC
  2. PowerBuilder
  3. # 1

We saw this limitation in our app - and it turned out to be the windows handles limitation on the server.

Turning off windows handles in the pb.ini made a miraculous difference - we now run 32-64 separate parallel task at high speed utilizing nearly 100% of compuing resources.

Also make sure your server is configure for maximum compute performance - turn off fair share , etc.

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 2 June 2023 16:00 PM UTC
  2. PowerBuilder
  3. # 2

Hi Boris;

  You can also try creating a PB App EXE instance per processor using the SetProcessAffinityMask API.

   I created a system for Passport Canada using the above API with two PB App's. I used 16 instances of App1 that were each bound to one of the 16 cores on one server.The 2nd PB App2 was used as a coordinator App for the 16 App1 instances on each server. Each App1 took it's direction from App2. App2 monitored each App1's work queue, work status, error / restart and coordinated it's normal shutdown.

   I had three servers - thus 16 x 3 = 48 core instances of the PB App1 running. With three App2 coordinator instances. Each App2 communicated with each other - so each App2' knew the overall processing state of all three servers.

   Here are a few presentations that I gave on this architecture / design app;roach at various PB Conferences. This design allowed Passport to process (OCR, locate, redact, update Blob based images in an ASE DBMS at the rate on 1 million per hour!!!!

FYI...

https://sourceforge.net/projects/stdfndclass/files/Presentations/Multi-Threading

https://sourceforge.net/projects/stdfndclass/files/Presentations/OCR

Food for thought!  HTH

Regards ... Chris

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 1 June 2023 15:32 PM UTC
  2. PowerBuilder
  3. # 3

The SetProcessAffinityMask Windows API function can be used to assign your app to a specific CPU.

The second argument is a bit mask so set it like this:

mask = 2 ^cpu

Windows declaration:

BOOL SetProcessAffinityMask( [in] HANDLE hProcess, [in] DWORD_PTR dwProcessAffinityMask );

kernel32.dll

In PowerBuilder use Longptr for both arguments.

 

Comment
  1. Miguel Leeuwe
  2. Friday, 2 June 2023 07:47 AM UTC
Yes, totally agree with both of you, Benjamin and Andreas. I was just wondering what Roland was trying to point out of using this API to improve speed.
  1. Helpful
  1. Roland Smith
  2. Friday, 2 June 2023 11:58 AM UTC
I suppose if you knew which CPU processed a PB app fastest, you could use this function to force it to the CPU. I'm not sure you would see a noticeable improvement, the usual cause of slowness is I/O.
  1. Helpful 1
  1. Miguel Leeuwe
  2. Friday, 2 June 2023 16:02 PM UTC
Got it!
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 1 June 2023 11:45 AM UTC
  2. PowerBuilder
  3. # 4

Hi,

All good advice, but it still doesn't explain why power builder application shows very poor perfomance on multi-core processors, while it may work several times faster on one-core processor

Maybe it's because a single core of the multi-core processor is slower than the tested single core processor?

regards

Comment
  1. Andreas Mykonios
  2. Thursday, 1 June 2023 12:34 PM UTC
It is probable that i5 is running on the same speed. Also 4 cores is better that 2 cores - 4 threads. U in your I7 means that this one is a low power consumption (they use to do that on laptops to extend battery duration). As an example: i7-6500U runs at 2.5 GHz. i5-3570 runs at 3.4 GHz (base speed)... There is a significant difference of course between i7 and i5, but even in that case 3rd generation i5 is faster than 6th generation i7! And it's not related to PB.

There are cases where disk speed won't make a big difference (except when application starts, or if your computer uses lot of virtual memory).

Andreas.
  1. Helpful 1
  1. Chris Pollach @Appeon
  2. Thursday, 1 June 2023 15:07 PM UTC
Hi Miguel;

FWIW: I gave up on Intel over a decade ago. I think that their CPU's are over rated and over priced. I have switched over to AMD based machines.

My wife's current machine is an I7 and PB IDE and Apps do run much slower on that machine than mine.

I have recently upgraded my two machines to a Ryzen 5 and a Ryzen 7 CPU respectively and these are "super fast" all around.

I can boot the R7 from a cold start, login and launch the PB IDE and have it all ready to run PB Apps in 25-30 seconds!!!!!

Also, the R5 and R7 multi-core processors run PB Apps "lightening fast". I can do a complex App PS 2022 "build & deploy" in about 25-20 seconds (slower to IIS than Kestrel [10-15 seconds] in the R2 Beta). I am now a devote AMD fan (as can might tell - LOL).

Regards ... Chris
  1. Helpful 1
  1. Miguel Leeuwe
  2. Friday, 2 June 2023 04:05 AM UTC
I'm not a Mac fan at all, but it would make a lot of people very happy if PB could run on it. M2 processors are not so expensive and really fast.
  1. Helpful
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Thursday, 1 June 2023 10:29 AM UTC
  2. PowerBuilder
  3. # 5

Hi.

There is no an easy way to do that. It's possible to make your application use multithreading. Not all parts of your application could work in this mode. This mode is suited for background process that can be split somehow to work in different threads.

There is a great article by John Fauss about multithreading and PowerBuilder: Free My GUI! - Multi-Threading in PowerBuilder - Appeon Community. It explains all the basics about this topic, but you are supposed to understand some more advanced topics of pb. I would suggest to read it, and then maybe do some experiments.

Some important points - limitations:

  • Multithreading doesn't support visual controls - objects. Even messagebox cannot be used.
  • Global variable may be used, but in sharedobjects they are considered as local. This affects also sqlca e.t.c.

You may conclude that any repeated process running inside a transaction cannot be a candidate to be split in a multithread processing. But a process that repeats a specific task n times, and doesn't run in a transaction, it can be a candidate to be executed using sharedobjects.

So, in your case, you will have to:

  • Check if you have long running processes that could run in separate threads.
  • You will have somehow to decide how many threads to support. This may vary depending on processor and available memory.
  • You would have use a controller object (you have to design & built it) to manage your threads.
  • You also need an object that will "establish - maintain" communication between your applications and n threads working.

Finally, it's not easy to implement. Depending on your experience in PowerBuilder and the way your application was initially designed it might be less or more work.

Andreas.

Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 1 June 2023 10:21 AM UTC
  2. PowerBuilder
  3. # 6

PB applications are single threaded applications. So it uses only one core to run.

But you can use SharedObjects to make your application multithreaded. It's not easy to do this.

Here you can find an example: https://community.appeon.com/index.php/codeexchange/powerbuilder/307-a-multi-threaded-data-retrieval-example

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.