CallThreadProcSafe and performance monitoring tools

delphi package - automated exception handling
Post Reply
zbeleh
Posts: 15
Joined: Tue Jan 19, 2021 7:14 pm

CallThreadProcSafe and performance monitoring tools

Post by zbeleh »

Hello,
I am using performance monitoring tools to track bottlenecks in my application.

while doing so, the function CallThreadProcSafe from unit MadExcept is topping the list.
according to the attached screenshot, it is called once and is taking over 50% of the execution time.
aqtime.png
aqtime.png (71.24 KiB) Viewed 3933 times
This probably doesn't make sense, but I was just curious as to what this procedure does.

Memory leak detection (known to be slow) are not enabled in this execution, so the above is resulting from the exception handling aspect of MadExcept.

Any ideas which might help clear out the misunderstanding?
Thanks!
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: CallThreadProcSafe and performance monitoring tools

Post by madshi »

CallThreadProcSafe basically encapsulates your thread functions in order to be able to inject a try..except block into them. So CallThreadProcSafe basically looks like this:

Code: Select all

function CallThreadProcSafe(originalThreadProc) : integer;
begin
  try
    result := originalThreadProc;
  except
    HandleException()
  end;
end;
zbeleh
Posts: 15
Joined: Tue Jan 19, 2021 7:14 pm

Re: CallThreadProcSafe and performance monitoring tools

Post by zbeleh »

so from your description, I understand that there should be no extra cost added by this procedure, unless an exception is raised (which, if it wasn't for MadExcept, would have propagated the Exception further upwards anyway).

thanks again!
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: CallThreadProcSafe and performance monitoring tools

Post by madshi »

There is no meaningful cost added by this procedure. Generally, madExcept is not supposed to slow down anything, unless there's an exception.
Post Reply