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

Bo Berglund bo.berglund at gmail.com
Thu Oct 28 13:27:15 CEST 2021


On Sun, 24 Oct 2021 08:18:31 +0000, Alexander Grotewohl via fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:

>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."

Yes it is *old* code written with Delphi starting from about 2004 and
"maintained" on Windows up until 2012 or thereabouts.

Issues were discovered on Windows7 but these were fixed and then Windows 10 made
it so much worse that I decided to try and port it over to Linux.

It is a Windows TService application ported to a command line program on Linux
so the base framework had to be modified a lot...
But the majority of the code is only modified wherever it deals with protection
dongles and read/write the Windows Registry.
Plus all file system accesses using \ separators and drive letters...
And of course the event driven model as a whole...

As long as it does not eat up more than 10% or so CPU I might have to swallow
it. And maybe schedule a regular restart of the server to clear whatever builds
up.


-- 
Bo Berglund
Developer in Sweden



More information about the fpc-pascal mailing list