Shared Memory Segment Parameters

team bbl


Shared memory provides an efficient way to share large amounts of data between processes. Shared memory is one of the most important resources the IPC facility provides because it is heavily used in many database applications. A SysV shared memory segment is created by the shmget() system call. After the shared memory segment is created, a process can attach itself to the shared memory segment by issuing a shmat()system call. Then the process can perform operations (read or write) on it. The process can detach itself from the memory segment by a shmdt() system call. Because shared memory provides a common resource for multiple processes, it is often used with semaphores to prevent collisions.

Table 13-3 summarizes the shared memory segment parameters.

Table 13-3. Shared Memory Segment Parameters

Name

Description

Default

Maximum

shmmax

Maximum shared memory segment size in bytes

0x2000000

4GB

shmmin

Minimum shared memory segment size in bytes

1

2GB

shmmni

Maximum number of shared memory segments

4096

2GB

shmall

Maximum shared memory segment size in pages system-wide

0x200000

4GB


Note that some UNIX operating systems, such as Solaris, use the shmseg kernel parameter to restrict the total number of segments a process can attach itself to. Linux currently does not have this limitation but reserves this parameter in /usr/include/linux/shm.h.

The following sections describe in detail the shared memory segment parameters that are supported in Linux.

shmmni

shmmni is the total number of shared memory segments allowed in a system. Its data type is signed int on a 32-bit architecture, so theoretically its value can be increased up to 2GB. However, IPCMNI overrides this limit. You can configure IPCMNI to get more shared memory segments; however, each IPC identifier structure size is about 44 bytes. For 2GB shared memory segments, you need 2GB*44=88GB of memory.

shmmax

shmmax sets the limit of an individual shared memory segment size in bytes. The default value in the current Linux 2.4/2.6 kernel is 32MB. Some database applications might require a larger limit. shmmax is tunable dynamically but the new limit does not affect the existing shared memory segments. Increasing shmmax does not allocate additional kernel memory. The parameter itself is of type unsigned int, so theoretically you can tune it up to 4GB to fit your application needs. However, there is no point in changing this parameter to be larger than the physical memory available on your system.

shmmin

shmmin is the smallest a shared memory segment can be. We recommend that the default value be kept as is.

shmall

shmall defines the number of pages system-wide that can be used for shared memory segments. The default value is 0x200000. We recommend the value of shmall be adjusted based on the values of shmmax and shmmni.

    team bbl



    Performance Tuning for Linux Servers
    Performance Tuning for Linux Servers
    ISBN: 0137136285
    EAN: 2147483647
    Year: 2006
    Pages: 254

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net