Showing posts with label CPU Tuning. Show all posts
Showing posts with label CPU Tuning. Show all posts

Monday, May 18, 2009

SAR (Context Switch)

To monitor the context switching activity

# sar -wP ALL 10 5

Context switching happens when a multi-process OS suspends running one process or thread and starts another. Context switching occurs during any of the following,
  • A time slice expires.
  • A process exits
  • A process puts itself to sleep or in a stopped state.
  • A real-time priority process becomes ready to run.

Thanks

SAR (Cpu) Individual

To monitor one CPU at a time.

# sar -P 2 10 5

The o/p displays the result for the 3rd CPU, 10 seconds apart, 5 times.

# sar -P 0,3 10 5

The o/p displays the result for the 1st and 4th CPU, 10 seconds apart, 5 times.

# sar -P ALL 10 5

The o/p displays the result for all the CPU, 10 seconds apart, 5 times.

Thanks

SAR (Cpu)

To monitor CPU usage

# sar -u 10 5

The o/p has the following columns.

%usr - Percent of CPU running in user mode (executing user code).
%sys - Percent of CPU running in system mode (executing OS code).
%wio - Percent of CPU running idle with a process waiting for block I/O.
%idle - Percent of CPU that is idle.

Inference
  • A low %idle indicates CPU intensive job.
  • A high %wio indicates a disk contention.
  • A high %sys (>20) indicates a bottleneck. May be due to swapping or paging.
  • A high %usr indicates applications not tuned properly or over utilization of CPU.

Thanks

Tuesday, May 5, 2009

ps (Cpu)

To display top 10 CPU consuming process

$ ps aux | head -1; ps aux | sort -rn +2 | head -10

To display process in order of CPU time

$ ps avx | head -1 ; ps avx | grep -v PID | sort -rn +3 | head -10

This is the total accumulated CPU time for the life of the process and not the clock time.

To display processes in order of being penalized

$ ps -eakl | head -1 ; ps -eakl | sort -rn +5 | head -10

Penalized process are awarded less CPU time. Use nice to increase the priority.

To display processes in order of priority

$ ps -eakl | sort -n +6 | head -10

The lower value in the PRI column has the high priority.

To display processes in order of nice value

$ ps -eakl | head -1; ps -eakl | sort -rn +7 | head -10

By running the above commands you will get the process ids of the top resource consuming sessions. Use the pids in the following SQL statements to get the session details.

SQL> Select * From v$session s, v$process p
Where s.paddr = p.addr
and p.spid in ('pid', ‘pid’);


Thanks

renice

The renice command is used to change the nice value of one or more processes that are running on a system. The renice command can also change the nice values of a specific process group.

Syntax

# renice [-n Increment] [-g -p -u] ID

Where ID – When p option is used it represents PID. When g option is used it represents process group ID. When u option is used it indicates user id.

To increase the priority of ps command, decrease the nice value

# renice –n -10 –p 52904

To decrease the priority of ps command, increase the nice value

# renice –n 10 –p 52904

Thanks

nice

The nice command enables to adjust the priority of a command.

Syntax

# nice [-increment] command [Arguments]

To increase the priority of ps command, decrease the nice value.

# nice --10 ps

To decrease the priority of ps command, increase the nice value.

# nice -10 ps

Note1: By default a foreground process has a nice value of 20.
Note2: By default a background process has a nice value of 24.
Note3: Non Root users can only degrade the priority of their own commands.

Thanks

mpstat (Solaris)

The mpstat command reports per processor statistics. Each row of the table represents the activity of one processor. Pay close attention to the smtx measurement. Smtx measures the no. of times the CPU failed to obtain a mutex (Mutual Exclusion Lock). Mutex stalls waste CPU time and degrade multiprocessor scaling.

# mpstat

If the smtx value is greater than 200, then the system is heading towards a CPU bottleneck.

Thanks

uptime

The uptime command produces a single line of output that shows the current time, how long the system has been running since it was booted up, how many user sessions are currently open and the load averages.

$ uptime

The load averages are the average numbers of processes (run queue) that were active during the past one, five and fifteen minutes.

Thanks

Followers

Powered By Blogger
 

RAC Database Administration. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com