From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Peter Darley <pdarley(at)kinesis-cem(dot)com> |
Cc: | Ron Snyder <snyder(at)roguewave(dot)com>, Pgsql-General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Process balancing on smp db server/apache web server |
Date: | 2002-06-02 18:49:43 |
Message-ID: | 200206021849.g52Inho12463@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Peter Darley wrote:
> Ron,
> I thought I was talking about Linux, but may I'm mistaken on how smp works.
> I was told that a process is run on one and only one CPU, and that there was
> no mechanism to move the process to another CPU during execution. This
> would mean that once a process was started on a CPU it would stay on that
> CPU, even if it grew to a point that it would make since to switch it over
> to another.
> It looks like I was hoodwinked tho, as some research has lead me to the SMP
> FAQ item 7:
>
> 7. Does Linux SMP support processor affinity?
> Standard kernel
> No and Yes. There is no way to force a process onto specific CPU's but the
> linux scheduler has a processor bias for each process, which tends to keep
> processes tied to a specific CPU.
>
> This seems to be saying that what I was told was wrong, so, I apologize for
> wasting the lists time.
Let me explain processor affinity. CPU's have instruction and data
caches on the chip, as well as virtual page mapping caches (TLB). This
makes keeping a process on the same CPU desirable because returning to
the same CPU means the CPU cache may have information that will allow
that process to run faster. However, there is no requirement that a
process remain on the same CPU, and it will often be moved to take
advantage of an idle CPU.
On a 2-cpu SMP system, try this. Start three loops in separate terminal
sessions:
echo $$;while : ;do :; done
Then, use 'ps' with the proper flags to see the CPU's for each process.
On my BSD/OS system, I use:
ps -axl|egrep '29276|29404|29451'
with the numbers representing the process id's displayed in my three
terminal sessions. What I see is that two are running on one CPU, and
one on another, but you should see that sometimes two are running on
CPU-0 and then two are running on CPU-1, as that the processes migrate
for load balancing purposes.
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2002-06-02 20:28:26 | MVCC and MS-SQL comparison |
Previous Message | Curt Sampson | 2002-06-02 07:21:22 | Re: Row Limit on tables |