Thursday, April 20, 2006

Solaris and High Wait I/O CPU

A few days back a familiar little situation surfaced. Someone monitoring the OS was making claims that a particular machine was running at 100% cpu utilization during a period when a portion of the application was running slower than normal. The assertion being made was our system had a cpu shortage.

Given the fact that the application was running on a Solaris platform I looked at the vmstat history logs kept for just such an investigation. Per vmstat, for the time in question, there was plenty of idle cpu. Immediately, I thought this person must have been looking at the sar data on the machine in question. Sure enough, the sar data indicated a very low percentage of idle cpu. As you might have guessed, the percentage of time the system was waiting for I/O was rather large according to sar and, consequently, low idle time was being reported. I explained that it was typical for this system to run a high wait I/O percentage as reported by sar; after all, it is a database server with many processors. I also explained that low idle time as reported by sar does not necessarily mean a cpu bottleneck exists.

I remembered reading in Adrian Cockroft’s book, Sun Performance Tuning, that vmstat lumps wait I/O into idle time. So, naturally I was confident in my counter-assertion that our cpu utilization was just fine. I assuredly reached for my copy of the Sun Performance Tuning book to show where I had read this information years ago. I searched the index of the book and gave the book a cursory once-over to no avail. I started doubting whether I had reached for the wrong text! A bit frustrated I decide to perform a full book scan. Low and behold, I only got past two pages before my memory was vindicated. On page 3 it reads. “Whenever there are any blocked processes, all cpu idle time is treated as wait for I/O time! The vmstat command correctly includes wait for I/O in its idle value…” Viola!

The clock interrupt handler in the Solaris operating system runs every 10ms (or at least used to) to get cpu utilization information. It will search the state structure for each cpu and find that each cpu is in one of five states: user, system, idle, waiting for I/O or quiesced. Based on my understanding, the quiesced state is not really indicated by a value stored in a structure or variable associated with a cpu. It is simply the state when a cpu is not running user, system or idle threads and not waiting for I/O.

The point is, a high value for wait I/O generated from sar on a Solaris platform does not indicate a cpu bottleneck. Moreover, high wait I/O values do not necessarily indicate an I/O bottleneck. However, an I/O bottleneck could very easy manifest in high wait I/O percentages. You really need to look at your I/O service times to determine if the I/O subsystem is performing poorly.

For those wanting to know more on the algorithm used by Solaris to calculate idle and wait I/O cpu percentages read here. It is a bit dated, but describes how wait I/O is tallied in the Solaris operating system (at least in earlier versions). Interestingly enough this article cites Sun Performance Tuning, my trusty reference.

7 Comments:

Anonymous Anonymous said...

Great post! I am an Oracle DBA and have been spending the last few days battling with some UNIX admins that the wait I/O column in sar can be misleading sometimes (which they are averaging over 5 minutes) and what should be looked at is service time and average wait queue length in IOSTAT, which avg wait is nearly always 0 or less than 1. Showdown brewing.

7/06/2006 8:46 AM  
Blogger Eric S. Emrick said...

Well, I hope you have success in convincing your Unix administrators that not all is as it seems with sar and WIO. If they don't believe you point them to the document I have in the post. Or, buy them Adrian Cockrofts book using the company dime :)

Best of luck

7/06/2006 7:15 PM  
Anonymous Anonymous said...

Thank you!!!!!!!!!!

1/09/2007 8:52 PM  
Blogger ggruendgens said...

It appears that associating the concept of waiting on IO with CPU utilization is itself confusing. It is a process exection characteristic rather than a CPU utilization attribute.

Showing WIO next to USR, SYS and IDL would make sense to me only, if WIO would refer to the time the CPU is wating for IO itself. Since the kernel, I believe, "schedules out" processes waiting on IO, the CPU itself is waiting on IO only, I speculate, when waiting on data loading into registers (from CPU cache or from main memory) -- thus effectively measuring the utilization of memory buses.

3/23/2007 9:43 AM  
Blogger ggruendgens said...

But the following also make sense indeed (which I've found after some more googling):

"The rationale for separating out I/O wait time is that since an I/O operation may complete at any instant, and the process will be marked runable and begin consuming CPU cycles, the CPUs should not really be considered idle. The %wio metric most definitely does not tell you anything about how busy the disk subsystem is or whether the disks are overloaded. It can indicate whether or not the workload is I/O bound. Or, to look at it another way, %wio is good for tracking how much busier the CPUs would be if you could make the disk subsystem infinitely fast."

3/23/2007 9:48 AM  
Blogger Masood said...

This comment has been removed by the author.

1/18/2009 7:11 AM  
Blogger daspeac said...

I have heard about another way of corrupted adobe photoshop repair. Besides, you can visit my blogs at: http://daspeac.livejournal.com/ or http://daspeac.blogspot.com/ where I’m trying to share my experience with regard to data corruption issues

11/04/2010 2:45 PM  

Post a Comment

<< Home