Thread: Context switching and Xeon processors

Context switching and Xeon processors

From
"Brandon Metcalf"
Date:
We're running a dual Xeon machine with hyperthreading enabled and
PostgreSQL 8.0.3.  Below is the type of CPUs:

  processor       : 3
  vendor_id       : GenuineIntel
  cpu family      : 15
  model           : 4
  model name      : Intel(R) Xeon(TM) CPU 3.20GHz
  stepping        : 1
  cpu MHz         : 3200.274
  cache size      : 1024 KB
  ...

We've been tuning the kernel (2.4 SMP flavor) and have improved
performance quite a bit.  I'm now wondering if turning off HT will
improve performance even more.  Based on the vmstat output below, is
the context switching typical or too high?  And what is the latest on
the state of PostgreSQL running on Xeon processors with HT turned on?
I searched the archives, but couldn't discern anything definitive.

   r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy wa id
   1  0 135944  64612  17136 3756816    0    0     0   210  154   178  2  0  4 94
   1  0 135940  46600  17204 3754496    0    0     1  1231  442  3658  7  3 10 80
   1  3 135940  51228  17240 3754680    0    0     0  1268  255  2659  4  1 14 81
   1  0 135940  58512  17300 3754684    0    0     0  1818  335  1526  2  1 32 65
   1  1 135940  18104  17328 3806516    0    0 17670   476 1314  1962  2  2 41 56
   0  1 135940  17776  17232 3811620    0    0 23193   394 1600  2097  2  2 53 44
   0  1 135940  17944  17188 3809636    0    0 25459   349 1547  2013  2  2 50 46
   0  3 135940  18816  15184 3798312    0    0 24284  1328 1529  4730  6  5 53 36
   0  6 135940  23536   6060 3817088    0    0 27376  1332 1350  2628  2  3 56 39
   0  5 135940  18008   6036 3827132    0    0 18806  1539 1410  1416  1  2 61 36
   0  5 135940  18492   5708 3826660    0    0  3540 10354  736   955  2  2 76 20
   0  3 135940  18940   5788 3829864    0    0  2308  7506  707   519  2  1 81 15
   1  4 135940  18980   5820 3828836    0    0   138  3503  556   261  1  0 74 24
   0 10 135940  39332   5896 3777724    0    0   579  2805  621  4104  7  4 54 35
   0  4 135936  37816   5952 3791404    0    0   260  1887  384  1574  2  1 40 57
   0  5 135936  29552   5996 3802260    0    0   290  1642  434  1944  3  1 38 58


--
Brandon

Re: Context switching and Xeon processors

From
Tom Lane
Date:
"Brandon Metcalf" <bmetcalf@nortel.com> writes:
> We've been tuning the kernel (2.4 SMP flavor) and have improved
> performance quite a bit.  I'm now wondering if turning off HT will
> improve performance even more.  Based on the vmstat output below, is
> the context switching typical or too high?

Given that your CPU usage is hovering around 2%, it's highly unlikely
that you'll be able to measure any change at all by fiddling with HT.
What you need to be working on is disk I/O --- the "80% wait" number
is what should be getting your attention, not the CS number.

(FWIW, on the sort of hardware you're talking about, I wouldn't worry
about CS rates lower than maybe 10000/sec --- the hardware can sustain
well over 10x that.)

            regards, tom lane

Re: Context switching and Xeon processors

From
"Brandon Metcalf"
Date:
t == tgl@sss.pgh.pa.us writes:

 t> "Brandon Metcalf" <bmetcalf@nortel.com> writes:
 t> > We've been tuning the kernel (2.4 SMP flavor) and have improved
 t> > performance quite a bit.  I'm now wondering if turning off HT will
 t> > improve performance even more.  Based on the vmstat output below, is
 t> > the context switching typical or too high?

 t> Given that your CPU usage is hovering around 2%, it's highly unlikely
 t> that you'll be able to measure any change at all by fiddling with HT.
 t> What you need to be working on is disk I/O --- the "80% wait" number
 t> is what should be getting your attention, not the CS number.

 t> (FWIW, on the sort of hardware you're talking about, I wouldn't worry
 t> about CS rates lower than maybe 10000/sec --- the hardware can sustain
 t> well over 10x that.)


Yes, I agree the disk I/O is an issue and that's what we've been
addressing with the tuning we've been doing and have been able to
improve.  I think that we really need to go to a RAID 10 array to
address the I/O issue, but thought I would investigate the context
switching issue.

Thanks for the information.

--
Brandon

Re: Context switching and Xeon processors

From
"Steinar H. Gunderson"
Date:
On Tue, Dec 06, 2005 at 03:01:02PM -0600, Brandon Metcalf wrote:
> We're running a dual Xeon machine with hyperthreading enabled and
> PostgreSQL 8.0.3.

The two single most important things that will help you with high rates of
context switching:

  - Turn off hyperthreading.
  - Upgrade to 8.1.

/* Steinar */
--
Homepage: http://www.sesse.net/