Lecture – Performance Performance management on UNIX.

Slides:



Advertisements
Similar presentations
Unix Systems Performance Tuning Project of COSC 513 Name: Qinghui Mu Instructor: Prof. Anvari.
Advertisements

Chapter 5 Controlling Processes Xiaoli Jiao 6/8/99.
Using tcpdump. tcpdump is a powerful tool that allows us to sniff network packets and make some statistical analysis out of those dumps. tcpdump operates.
Zombie and orphan processes. Zombie process (from wikipedia) When a process ends, all of the memory and resources associated with it are deallocated.
Lesson 10-Controlling User Processes. Overview Managing and processing processes. Managing jobs. Exiting/quitting when jobs have been stopped.
Operating Systems Yasir Kiani. 20-Sep Agenda for Today Review of previous lecture Use of FIFOs in a program Example code Process management commands.
1 Operating Systems and Protection CS Goals of Today’s Lecture How multiple programs can run at once  Processes  Context switching  Process.
Controlling Processes & Periodic Processes WeeSan Lee
Linux+ Guide to Linux Certification, Second Edition
Using netstat for Performance Analysis
Structure of Processes
Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
Process Scheduling. Process The activation of a program. Can have multiple processes of a program Entities associated with a process –Instruction pointer,
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Process Description and Control A process is sometimes called a task, it is a program in execution.
5 UNIX Processes. Introduction  Processes  How to list them  How to terminate them  Process priorities  Scheduling jobs  Signals.
UNIX Processes. The UNIX Process A process is an instance of a program in execution. Created by another parent process as its child. One process can be.
UNIX System Administration Handbook Chapter 4. Controlling Processes 3 rd Edition Evi Nemeth et al. Li Song CMSC691X Summer 2002.
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
CIT 470: Advanced Network and System AdministrationSlide #1 CIT 470: Advanced Network and System Administration Performance Monitoring.
CIT 470: Advanced Network and System AdministrationSlide #1 CIT 470: Advanced Network and System Administration Performance Monitoring.
Fall 2011 Nassau Community College ITE153 – Operating Systems 1 Session 4 More Hands-on Commands.
Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University.
Linux+ Guide to Linux Certification, Third Edition
Guide to Linux Installation and Administration, 2e1 Chapter 10 Managing System Resources.
Process Control. Module 11 Process Control ♦ Introduction ► A process is a running occurrence of a program, including all variables and other conditions.
Operating Systems Process Management.
Va-scanCopyright 2002, Marchany Unit 7 – Solaris Process Control Randy Marchany VA Tech Computing Center.
Managing processes and services. 1. How Linux handles processes 2. Managing running processes 3. Scheduling processes.
Linux+ Guide to Linux Certification, Second Edition Chapter 10 Managing Linux Processes.
RH030 Linux Computing Essentials
The kernel considers each program running on your system to be a process A process lives as it executes, with a lifetime that may be short or long A process.
Guide To UNIX Using Linux Third Edition Chapter 8: Exploring the UNIX/Linux Utilities.
What Every Developer Should Know about the Kernel Dr. Michael L. Collard 1.
Scis.regis.edu ● CS 468: Advanced UNIX Class 4 Dr. Jesús Borrego Regis University 1.
Linux+ Guide to Linux Certification Chapter Eleven Managing Linux Processes.
Lab 3 + Using the Terminal 1. "Under Linux there are GUIs (graphical user interfaces). where you can point and click and drag, and hopefully get work.
CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT Processes.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
Chapter 3 – Processes (Pgs 101 – 141). Processes  Pretty much identical to a “job”  A task that a computer is performing  Consists of: 1. Text Section.
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 9 Working.
System Administration. Logging in as System Administrator System Admin login (aka superuser, aka root) –login id: root –Default PS1 prompt: # –Home directory:
CS 390 Unix Programming Environment
Zombie and orphan processes. Zombie process (from wikipedia) When a process ends, all of the memory and resources associated with it are deallocated so.
CSC414 “Introduction to UNIX/ Linux” Lecture 3
Agenda Managing Processes (Jobs) Command Grouping Running jobs in background (bg) Bringing jobs to foreground (fg), Background job status (jobs) Suspending.
Performance Analysis. Computer Center, CS, NCTU 2 Help! My system is slow!  slow.pdf.
Guide to Parallel Operating Systems with Windows 7 and Linux Chapter 10 Operating System Management.
Linux I/O Tuning Anshul Gupta. 2 - Performance Gathering Tools -I/O Elevators -File System -Swap and Caches Agenda.
Linux Command Tips.
Linux203Training Module System Mgmt.
Process Management Process Concept Why only the global variables?
Modeling Page Replacement Algorithms
Linux 202 Training Module Program and Process.
Processes A process is a running program.
Operating Systems Lecture 11.
Structure of Processes
CIT 470: Advanced Network and System Administration
CHAPTER 8 ( , ) John Carelli, Instructor Kutztown University
Modeling Page Replacement Algorithms
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Controlling Processes
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Process Description and Control in Unix
Process Description and Control in Unix
Performance Analysis.
Presentation transcript:

Lecture – Performance Performance management on UNIX

02/06/20162 Performance Analysis Performance analysis involves identifying various system bottlenecks This involves a number of steps We must ask a number of questions Is there a performance Problem? Is the problem CPU or I/O related?

02/06/20163 Performance Analysis CPU Related? What is the current load on the CPU? What is the average load on the CPU? I/O Related Is it normal disk I/O? Would more/faster disks help? Is it paging I/O? Would more physical memory help?

02/06/20164 Related to a Particular User or Program? Identify the user / program Identify what they are doing to cause the problem Revise their operating procedures Consider removing them from the system

02/06/20165 Determining CPU Usage Determining the CPU usage is the first thing we should do There are a number of tools to do this vmstat gives several pieces of useful information including CPU usage vmstat [interval] [count] Interval is the number of seconds between reports and count is the number of reports to generate

02/06/20166 vmstat 2 10 vmstat 2 10 procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id

7 vmstat The first line gives the average values since the system was booted and should be ignored To determine the CPU usage, we are interested in the last three columns, us, sy, id us: % of CPU dedicated to User tasks sy: % of CPU dedicated to System tasks. Including I/O performing general O/S functions etc. id: % of CPU idle procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id

02/06/20168 Analysing vmstat output (CPU) Just because CPU time is high or idle time is low does not indicate a system problem It may simply indicate that a number of batch jobs are scheduled to run at the same time and might benefit from being rearranged In order to establish if there is a genuine problem it is necessary to monitor the system over an extended period If average CPU% remain high, there is a problem

02/06/20169 Analysing vmstat output (Process States) There are three states in which a process may be at any point in time Runtime, uninterrupted sleep, swapped out Process Statistics: r: Number of processes waiting for runtime b: Number of processes in uninterrupted sleep w: Number of processes swapped out, but otherwise able to run A high r suggests there is a bottle neck. procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id

02/06/ Analysing vmstat output (Memory) Memory Statistics swapd: Amount of virtual memory used (KB) free: Amount of idle memory (KB) buff: Ammount of memory used in buffers cache:amount of memory left in cache procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id

02/06/ Analysing vmstat output (Swap) Swap Statistics si: Amount of memory swapped in from disk (KB/s) so: Amount of memory swapped out to disk (KB/s) Swap statistics are arguably the most important statistic to monitor, and of these, the so field This field indicates the pages that have been swapped out, even if done before vmstat was started procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id

02/06/ Analysing vmstat output (I/O) I/O Statistics bi: Blocks received from a block device (blocks/sec) bo: Blocks sent to a block device (blocks/sec) If there are a large number of block transfers, the problem with your system may lie here (i.e. device access is high) A single reading, however is not indicative of the system as a whole, simply a snapshot All Linux blocks are 1KB except for CDRom blocks (2KB) procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id

02/06/ Analysing vmstat output (System) System Statistics in: The number of interrupts per second, including the system clock cs: The number of context switches per second procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id

02/06/ Analysing vmstat output (CPU usage) System Statistics us: % of CPU dedicated to user tasks sy: % of CPU dedicated to system tasks id: % of CPU idle procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id

02/06/ top top is another tool for identifying problems with a LINUX system Displays the top CPU processes Displays a listing of the most CPU intensive tasks on the system Can provide an interactive interface for manipulating the processes Default is to update every 5 seconds top operates by examining files in the /proc pseudo file system This pseudo file system is used as an interface to kernel data structures man proc

02/06/ rbradley]$ top 17:14:41 up 47 days, 2:27, 8 users, load average: 0.06, 0.03, processes: 59 sleeping, 2 running, 0 zombie, 0 stopped CPU states: 0.0% user 0.2% system 0.0% nice 0.0% iowait 99.8% idle Mem: k av, k used, k free, 0k shrd, 44976k buff 57692k actv, 11208k in_d, 1024k in_c Swap: k av, 9096k used, k free 34656k cached PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND 1 root S :15 0 init 2 root SW :00 0 keventd 3 root SW :01 0 kapmd 4 root SWN :00 0 ksoftirqd_CPU0 9 root SW :00 0 bdflush 226 root SW :00 0 kjournald 586 root S :08 0 syslogd 590 root S :03 0 klogd 666 root S :09 0 sshd 719 root S :00 0 gpm 728 root S :05 0 crond 785 xfs S :00 0 xfs 803 daemon S :00 0 atd 812 root S :00 0 mingetty 813 root S :00 0 mingetty top

17 Analysing top output Up: The time the system has been up and the three load averages Average number of processes ready to run in the last 1,5 and 15 minutes Same as the output of uptime Processes: The total number of processes running at the time of the last update Broken down into running, sleeping, stopped and zombied (A zombie process is a finished process where the parent has not read it exit state – which causes the process to be cleaned up) 17:14:41 up 47 days, 2:27, 8 users, load average: 0.06, 0.03, processes: 59 sleeping, 2 running, 0 zombie, 0 stopped CPU states: 0.0% user 0.2% system 0.0% nice 0.0% iowait 99.8% idle Mem: k av, k used, k free, 0k shrd, 44976k buff 57692k actv, 11208k in_d, 1024k in_c Swap: k av, 9096k used, k free 34656k cached

02/06/ Analysing top output CPU States: The percentage of CPU time in user mode, system mode, niced tasks (negative nice tasks) and idle Time spent in niced tasks will also be counted system and user time, so the total will be more than 100% Mem: Statistics on memory usage, including total available memory, free memory, used memory, shared memory, memory used for buffers 17:14:41 up 47 days, 2:27, 8 users, load average: 0.06, 0.03, processes: 59 sleeping, 2 running, 0 zombie, 0 stopped CPU states: 0.0% user 0.2% system 0.0% nice 0.0% iowait 99.8% idle Mem: k av, k used, k free, 0k shrd, 44976k buff 57692k actv, 11208k in_d, 1024k in_c Swap: k av, 9096k used, k free 34656k cached

02/06/ Analysing top output Swap: Statistics on swap space including total swap space and used swap space This and the Mem section together are the same as the output of free* PID: The process ID of each task USER: The username pf the task’s owner PRI: The priority of the task NI: The nice value of the task. Negative values are lower priority 17:14:41 up 47 days, 2:27, 8 users, load average: 0.06, 0.03, processes: 59 sleeping, 2 running, 0 zombie, 0 stopped CPU states: 0.0% user 0.2% system 0.0% nice 0.0% iowait 99.8% idle Mem: k av, k used, k free, 0k shrd, 44976k buff 57692k actv, 11208k in_d, 1024k in_c Swap: k av, 9096k used, k free 34656k cached PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND 1 root S :15 0 init

02/06/ Analysing top output SIZE: The size of the task’s code plus data stack space, in kilobytes RSS: The total amount of physical memory used by the task in kilobytes SHARE: The amount of shared memory used by the task STATE: The state of the task, S: sleeping, D: uninterrupted sleep, R: running, Z: zombies, T: stopped or traced %CPU: The task’s share of the CPU since the last screen update as a a percentage of total CPU time %MEM: The task’s percentage of physical memory Time: Total CPU time used by process since it started COMMAND: The task’s command name PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND 1 root S :15 0 init

02/06/ Using top to control processes In addition to command-line options for controlling the appearance of top (not covered here) there are a number of commands that can be issued to top while running Space: immediately updates the display ^L: Erases and redraws the screen k: kill a process You will be prompted for the pid and a signal to send to the process (normally 15)

02/06/ Using top to control processes i: ignore zombie processes n: change the number of processes to view r: renice a process P: sort tasks by CPU usage M: sort tasks by Memory usage

02/06/ Renice The renice command is used to alter the priority of running processes The default nice value is 0 The range in Linux is -20 to +20 The lower the value the faster the process runs Can examine the nice value of a process using ps –l

02/06/ Renice The owner of and root can change the nice value of a process using renice Changes apply to all child processes renice priority [[-p] pid...] [[-g] pgrp...] [[-u] user...] ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 S wait4 pts/1 00:00:00 bash 0 R pts/1 00:00:00 ps renice : old priority 0, new priority 5 ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 S wait4 pts/1 00:00:00 bash 0 R pts/1 00:00:00 ps

02/06/ Renice Once a nice value has been increased, only the root user can reduce it again, not even to the default value renice : old priority 5, new priority 19 ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 S wait4 pts/1 00:00:00 bash 0 R pts/1 00:00:00 ps renice renice: 24496: setpriority: Permission denied

02/06/ How Much Swap Space? A quick rule of thumb often used is twice as much as you have physical memory This approach is a bit simplistic and does not scale well 1. Estimate total memory requirements 2. Add some megabytes as a spare 3. Subtract the amount of physical memory available 4. If the value from 3 is > 3 times the available physical memory, you need more memory

02/06/ How Much Swap Space Sometimes the above formula will show that you don’t need swap space at all It is a good policy to create some anyway Linux uses the swap space so that as much physical memory as possible is kept free It swaps out pages that have not been used for a while When memory is needed, it is available

02/06/ How Much Swap Space? If swap space is removed (using the swapoff command) the system will attempt to move any swapped pages into other swap space or physical memory If there is not enough space elsewhere the system may become unavailable for a time, while it sorts itself out, but it will come back