[fpc-pascal] My Linux service application consumes 10% CPU when idling - why?

Alexander Grotewohl alex at dcclost.com
Sun Oct 24 10:18:31 CEST 2021


In the end we have a black box with Indy that isn't going to be opened.. and from the sound of it, a dated method of manually checking for i/o (in this case likely with select() and a zero timeout..). Calling that and sleep() over and over millions of times..

I'm sorry to the OP if I'm assuming a lot but my guess is the code is a bit old and could use some refactoring to do away with the old Pascal "active loop."

--
Alexander Grotewohl
https://dcclost.com
________________________________
From: fpc-pascal <fpc-pascal-bounces at lists.freepascal.org> on behalf of Bernd K. via fpc-pascal <fpc-pascal at lists.freepascal.org>
Sent: Saturday, October 23, 2021 6:46:21 AM
To: fpc-pascal at lists.freepascal.org <fpc-pascal at lists.freepascal.org>
Cc: Bernd K. <prof7bit at gmail.com>
Subject: Re: [fpc-pascal] My Linux service application consumes 10% CPU when idling - why?

Am 07.10.21 um 19:41 schrieb Bo Berglund via fpc-pascal:

> The question is: how to find what is still using CPU?

Have a look at the tool sysprof. This is a statistical sampling profiler
that can show you a call tree with percentages of CPU consumption. Thee
are also other sampling profilers around (oprofile, perf/hotspot,
google-gperftools, etc..) that all work by the same principle, you could
try which one suits you best. They should all be able to tell you where
exactly it spends how much of its CPU time. You don't need to instrument
the code, just compile it with dwarf debug info contained in the
executable (not as external debug file), maybe also reduce the
optimization level if, and it should be able to show you the call tree
along with time consumption of each function.

Bernd


_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20211024/638c443f/attachment.htm>


More information about the fpc-pascal mailing list