Download - Page 1 Kernel Tuning Introduction HP-UX Kernel Tuning A Primer Bill Hassell HP-UX Consultant
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 11
HP-UX Kernel Tuning HP-UX Kernel Tuning A PrimerA Primer
Bill HassellBill HassellHP-UX ConsultantHP-UX Consultant
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 22
Introduction Introduction
What is kernel ‘tuning’?What is kernel ‘tuning’? Parameters and their effectsParameters and their effects What tuning cannot doWhat tuning cannot do
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 33
VocabularyVocabulary Kernel fileKernel file
» /stand/system (and /stand/build/system)/stand/system (and /stand/build/system)» Tunable parametersTunable parameters» sysdefsysdef
Measurement toolsMeasurement tools» sar, vmstat, Glancesar, vmstat, Glance
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 44
Parameter changingParameter changing SAMSAM
» easiest to useeasiest to use» built-in documentationbuilt-in documentation» some bounds checking and interaction some bounds checking and interaction
teststests Manual methodManual method
» manual editmanual edit» no boundary checksno boundary checks
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 55
Filesystem ParametersFilesystem Parameters nfile, nflocksnfile, nflocks ninode, vx_ncsize, ninode, vx_ncsize, ncdnodencdnode
bufpages, nbuf, bufpages, nbuf, dbc_max_pct, dbc_min_pctdbc_max_pct, dbc_min_pct
maxfiles, maxfiles_limmaxfiles, maxfiles_lim fs_async, fs_async, default_disk_irdefault_disk_ir
disksort_secondsdisksort_seconds
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 66
nfile - max file opensnfile - max file opens
Maximum number of file opensMaximum number of file opens» open counted for same files or differentopen counted for same files or different» min 3 per processmin 3 per process
stdinstdin stdoutstdout stderrstderr
file: table is fullfile: table is full
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 77
nflocks - max file locksnflocks - max file locks
Maximum number of open file locksMaximum number of open file locks Highly application-dependentHighly application-dependent
» one file may have several locksone file may have several locks» Databases may need hundredsDatabases may need hundreds
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 88
ninode - kernel inode cacheninode - kernel inode cache In-core cache of In-core cache of uniqueunique current and current and
recent HFS inodes locationsrecent HFS inodes locations Speeds reopens, multi-process file accessSpeeds reopens, multi-process file access Keep small for typical databases, larger Keep small for typical databases, larger
for development and NFS (HFS only)for development and NFS (HFS only) ninode < nfileninode < nfileinode: table is fullinode: table is full
Formula may be way too large (vxfs)Formula may be way too large (vxfs)
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 99
ncdnodencdnode
In-core cache of In-core cache of uniqueunique current and current and recent CDROM inodesrecent CDROM inodes
Speeds reopens, multi-process file accessSpeeds reopens, multi-process file access Generally very small (one user for Generally very small (one user for
CDROM)CDROM) Copy CD’s to hard disk for multi-user Copy CD’s to hard disk for multi-user
accessaccess
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 1010
bufpages, nbuf, dbc_max_pct, bufpages, nbuf, dbc_max_pct, dbc_min_pct - buffer cachedbc_min_pct - buffer cache
Buffercache similar to DOS Buffercache similar to DOS SMARTDRVSMARTDRV
used only with file access, not rawused only with file access, not raw nbuf non-zero not recommendednbuf non-zero not recommended fix with bufpagesfix with bufpages range 200 Mb to 2 Gb (rd/wt ratio)range 200 Mb to 2 Gb (rd/wt ratio) Dynamic Buffer Cache min/max %Dynamic Buffer Cache min/max %
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 1111
maxfiles, maxfiles_limmaxfiles, maxfiles_lim
Single process file open limitsSingle process file open limits defaults to 60defaults to 60 soft limit, extend with soft limit, extend with setrlimitsetrlimit(2) up (2) up
to to maxfiles_limmaxfiles_lim POSIX shell: ulimit -fPOSIX shell: ulimit -f
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 1212
fs_async - sync policyfs_async - sync policy
Async filesystem writes (inc. metadata)Async filesystem writes (inc. metadata) 0 = safe for panics, powerfails0 = safe for panics, powerfails 1 = risky (filesystem corruption is likely) 1 = risky (filesystem corruption is likely)
but can improve writes (only) by 30%but can improve writes (only) by 30%
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 1313
default_disk_ir - immediate default_disk_ir - immediate reportingreporting
Disk Immediate Reporting - no wait for Disk Immediate Reporting - no wait for write to completewrite to complete
Similar to Similar to fs_asyncfs_async except applies to all except applies to all disk writes including rawdisk writes including raw
Kernel param or scsictl by diskKernel param or scsictl by disk
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 1414
disksort_secondsdisksort_seconds
HP-UX gives priority to serial rd/wtHP-UX gives priority to serial rd/wt Intense serial I/O slows random I/OIntense serial I/O slows random I/O Value to wait before changing priorityValue to wait before changing priority
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 1515
Process ParametersProcess Parameters
nproc, maxuprcnproc, maxuprc maxdsiz, maxdsiz_64bitmaxdsiz, maxdsiz_64bit maxssiz, maxssiz_64bitmaxssiz, maxssiz_64bit maxtsiz, maxtsiz_64bitmaxtsiz, maxtsiz_64bit
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 1616
nproc, maxuprc - processesnproc, maxuprc - processes
nproc nproc = max number of processes= max number of processes» proc: table is fullproc: table is full
maxuprc maxuprc = max processes per UID= max processes per UID» collective UID processes, not per logincollective UID processes, not per login
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 1717
maxdsiz - data segmentmaxdsiz - data segment Maximum data segment sizeMaximum data segment size Both default to 64 megs (typically too Both default to 64 megs (typically too
small)small) Set to apx. 900 megs or 1750 megs Set to apx. 900 megs or 1750 megs no kernel size penalty (just a fence for no kernel size penalty (just a fence for
runaways)runaways) maxdsiz_64bit max is 4 Tbmaxdsiz_64bit max is 4 Tb MAGIC notes (/usr/share/doc)MAGIC notes (/usr/share/doc)
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 1818
maxssiz - stack sizemaxssiz - stack size
Maximum stack sizeMaximum stack size runaway recursion can exceedrunaway recursion can exceed 79 megs is a 10.20 kernel limit, 200 79 megs is a 10.20 kernel limit, 200
megs for 32 bit 11.0 kernels and 64bit megs for 32 bit 11.0 kernels and 64bit 11.0 allows up to 1 Gb11.0 allows up to 1 Gb
FORTRAN arrays passed as data can FORTRAN arrays passed as data can easily exceed - use COMMONeasily exceed - use COMMON
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 1919
maxtsiz - text sizemaxtsiz - text size Unchanging executable instructionsUnchanging executable instructions Directly related to file sizeDirectly related to file size Seldom needs changing unless a process has an Seldom needs changing unless a process has an
exceptionally large number of instructionsexceptionally large number of instructions 10.20:10.20:
» 64 Mb default, 4 Gb max64 Mb default, 4 Gb max 11.x:11.x:
» 64 Mb default, 2 Gb max (32 bit), 4 Tb max (64 bit)64 Mb default, 2 Gb max (32 bit), 4 Tb max (64 bit)
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 2020
Network ParametersNetwork Parameters NetworkingNetworking
» nninni number of network interfacesnumber of network interfaces multiple LAN cardsmultiple LAN cards SLIP/CSLIP/PPP interfacesSLIP/CSLIP/PPP interfaces
» nettune nettune (10.20),(10.20), ndd ndd (11.0)(11.0) Setup in /etc/rc.config.dSetup in /etc/rc.config.d
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 2121
Virtual Memory (swap)Virtual Memory (swap) maxswapchunksmaxswapchunks swchunkswchunk nswapdev, nswapfsnswapdev, nswapfs swapmem_onswapmem_on
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 2222
maxswapchunks, swchunk - maxswapchunks, swchunk - Swap SpaceSwap Space
Maximum addressing limits for swapMaximum addressing limits for swap Usable swap is defined as: Usable swap is defined as:
» maxswapchunks * swchunk * dev_bsize where: maxswapchunks * swchunk * dev_bsize where: swchunk=2048 and dev_bsize=1024swchunk=2048 and dev_bsize=1024
Leave swchunk to defaultLeave swchunk to default Formula simplifies to:Formula simplifies to:
» maxswapchunks=DESIRED-SWAP / 2097152 or maxswapchunks=DESIRED-SWAP / 2097152 or » Maxswapchunks=DESIRED-SWAP / 2megsMaxswapchunks=DESIRED-SWAP / 2megs
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 2323
nswapdev, nswapfsnswapdev, nswapfs
nswapdevnswapdev - max number of swap - max number of swap devicesdevices
nswapfs - max number of filesystems that nswapfs - max number of filesystems that will be used for swapwill be used for swap» filesystem swap performancefilesystem swap performance» one way assignment policy (not returned)one way assignment policy (not returned)
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 2424
swapmem_onswapmem_on
HP-UX normally needs 1:1 RAM:swapHP-UX normally needs 1:1 RAM:swap swapmem_onswapmem_on creates an overallocation creates an overallocation
policy, typically 75% of RAMpolicy, typically 75% of RAM Can be used in both low RAM and high Can be used in both low RAM and high
RAM systemsRAM systems
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 2525
swapmem_onswapmem_on
SWAPSWAP500 meg500 meg
RAMRAM1 Gb1 Gb
Unusable forUnusable for processesprocesses
In this example, only 500 megs is usable In this example, only 500 megs is usable for processes since Virtual Memory is for processes since Virtual Memory is only 500 megs.only 500 megs.
swapmem_on=0swapmem_on=0
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 2626
swapmem_onswapmem_on
SWAPSWAP1 Gb1 Gb
RAMRAM1 Gb1 Gb
In this example, 1 Gb is usable for In this example, 1 Gb is usable for processes since Virtual Memory is 1 Gb processes since Virtual Memory is 1 Gb too...but no paging neededtoo...but no paging needed
swapmem_on=0swapmem_on=0
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 2727
swapmem_onswapmem_on
SWAPSWAP500 meg500 meg
RAMRAM1 Gb1 Gb
In this example, 1.25 Gb is usable In this example, 1.25 Gb is usable for processes since Virtual for processes since Virtual Memory is 75% RAM + swap Memory is 75% RAM + swap (750 + 500)(750 + 500)
swapmem_on=1swapmem_on=1
Total Total Vmemory = Vmemory = 1250 megs1250 megs
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 2828
Miscellaneous ParametersMiscellaneous Parameters MiscellaneousMiscellaneous
» timezonetimezone, , dstdst (0,1,2,3 policy) (0,1,2,3 policy)» nptynpty (SAM vs. manual) (SAM vs. manual)» timeslicetimeslice
Non-parameters:Non-parameters:» maxusersmaxusers (pseudo/formula parameter) (pseudo/formula parameter)
Kernel Tuning IntroductionKernel Tuning IntroductionPage Page 2929
Some last tipsSome last tips Web help: Web help: docs.hp.com//hpux/onlinedocs/os/KCparams.OverviewAll.htmldocs.hp.com//hpux/onlinedocs/os/KCparams.OverviewAll.html
SysAdmin CoursesSysAdmin Courses SAM help (10.xx+)SAM help (10.xx+) Adjust carefullyAdjust carefully
» Small changesSmall changes» Few changes per sysgenFew changes per sysgen