Re: spin_delay() for ARM - Mailing list pgsql-hackers

From Amit Khandekar
Subject Re: spin_delay() for ARM
Date
Msg-id CAJ3gD9dJRrOj2yNs6dNkmGoLzWkmNAJnATeUwmStMS5U8GSsMw@mail.gmail.com
Whole thread Raw
In response to Re: spin_delay() for ARM  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers


On Sat, 11 Apr 2020 at 00:47, Andres Freund <andres@anarazel.de> wrote:
>
> Hi,
>
> On 2020-04-10 13:09:13 +0530, Amit Khandekar wrote:
> > On my Intel Xeon machine with 8 cores, I tried to test PAUSE also
> > using a sample C program (attached spin.c). Here, many child processes
> > (much more than CPUs) wait in a tight loop for a shared variable to
> > become 0, while the parent process continuously increments a sequence
> > number for a fixed amount of time, after which, it sets the shared
> > variable to 0. The child's tight loop calls PAUSE in each iteration.
> > What I hoped was that because of PAUSE in children, the parent process
> > would get more share of the CPU, due to which, in a given time, the
> > sequence number will reach a higher value. Also, I expected the CPU
> > cycles spent by child processes to drop down, thanks to PAUSE. None of
> > these happened. There was no change.
>
> > Possibly, this testcase is not right. Probably the process preemption
> > occurs only within the set of hyperthreads attached to a single core.
> > And in my testcase, the parent process is the only one who is ready to
> > run. Still, I have anyway attached the program (spin.c) for archival;
> > in case somebody with a YIELD-supporting ARM machine wants to use it
> > to test YIELD.
>
> PAUSE doesn't operate on the level of the CPU scheduler. So the OS won't
> just schedule another process - you won't see different CPU usage if you
> measure it purely as the time running.

Yeah, I thought that the OS scheduling would be an *indirect* consequence of the pause because of it's slowing down the CPU, but looks like that does not happen.


> You should be able to see a
> difference if you measure with a profiler that shows you data from the
> CPUs performance monitoring unit.
Hmm, I had tried with perf and could see the pause itself consuming 5% cpu. But I haven't yet played with per-process figures.



--
Thanks,
-Amit Khandekar
Huawei Technologies
--
Thanks,
-Amit Khandekar
Huawei Technologies

pgsql-hackers by date:

Previous
From: James Coleman
Date:
Subject: Re: execExprInterp() questions / How to improve scalar array op expr eval?
Next
From: Amit Khandekar
Date:
Subject: Re: spin_delay() for ARM