Re: Process balancing on smp db server/apache web server
От | Bruce Momjian |
---|---|
Тема | Re: Process balancing on smp db server/apache web server |
Дата | |
Msg-id | 200206021849.g52Inho12463@candle.pha.pa.us обсуждение исходный текст |
Ответ на | Re: Process balancing on smp db server/apache web server ("Peter Darley" <pdarley@kinesis-cem.com>) |
Список | 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@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
В списке pgsql-general по дате отправления: