[fpc-pascal] My Linux service application consumes 10% CPU when idling - why?
Michael Van Canneyt
michael at freepascal.org
Sun Oct 17 12:03:44 CEST 2021
On Sun, 17 Oct 2021, Bo Berglund via fpc-pascal wrote:
> On Sun, 17 Oct 2021 00:43:51 +0200, Bo Berglund via fpc-pascal
> <fpc-pascal at lists.freepascal.org> wrote:
>
>> timeout --signal=2 3s strace -f -c -p 488 -o tracelog2.log
>>
>> % time seconds usecs/call calls errors syscall
>> ------ ----------- ----------- --------- --------- ----------------
>> 46.47 0.348353 414 841 nanosleep
>> 27.67 0.207437 17286 12 _newselect
>> 16.17 0.121220 211 572 77 futex
>
> So 90.3 % of the time is spent in these 3 syscalls...
>
> Does this mean that:
> _newselect is running for 207 ms during the 3 second test time?
> (Which is 17 ms per call)
>
> And what is _newselect in the first place?
Select (or _newselect) checks if there is activity on a file descriptor.
If you're working with Indy, it uses this call to check for data on a
socket; It is called frequently.
> I assume nanosleep is some kind of Linux API call made by fpc when it invokes
> sleep() in my code.
Yes.
>
> And futex????
Futex is used for thread synchronisation.
Again, if you're using Indy and threads, it is called a lot.
Michael.
More information about the fpc-pascal
mailing list