BUFFERS Option

Data set records are normally blocked. When a record is required, its block is read and the appropriate record is extracted. Blocks are always read in buffers in the DBS. These buffers are shared by all users of the structure. A block, after being used, is kept in memory until its memory space is needed for another block. If a subsequent request for a record in that block occurs, no physical I/O is required. Similarly, updated records are not immediately written out; rather, the buffer is marked to indicate it contains a changed block. This allows many records to be changed before any physical I/O is done. In general, increasing the number of buffers decreases the number of physical I/O operations performed.

The BUFFERS option controls the number of buffers the system allocates for each data set plus the number of additional buffers the system allocates and deallocates for each program that invokes the structure. The default values for buffers are as follows:

  • One system buffer

  • One random user buffer

  • Zero serial user buffers if REBLOCK is FALSE

  • Two serial user buffers if REBLOCK is TRUE

BUFFERS is a dynamic database parameter that can be changed through the Visible DBS facility. The maximum number of system buffers allowed is 1048575 plus an additional 254 for each random and serial user. To avoid using excessive memory, take care when setting buffers for sectioned structures. The number of buffers available for the structure is the number of buffers specified, multiplied by the number of sections in the structure.

When the aggregate of all buffers for all users exceeds the ALLOWEDCORE value, overlaying of buffers starts.

Structure BUFFER specifications are ignored when the OVERLAYGOAL parameter is not the number 0, except when any of the following conditions occur:

  • A structure is being accessed randomly and there are not buffer specifications, in which case a maximum of 512 buffers are used.

  • A structure is being accessed randomly and there are buffer specifications, in which case:

  • If the calculated value of SYSTEM BUFFERS + RANDOM BUFFERS PER USER is less than 512, a maximum of 512 buffers are used.

  • If the calculated value of SYSTEM BUFFERS + RANDOM BUFFERS PER USER is greater than 512, the calculated value is used for the maximum number of buffers.

  • An EXTENDED structure is being accessed serially and readahead is activated, in which case the serial buffer specification is used.

  • A non-EXTENDED structure is being accessed serially and readahead is activated, in which case 2 serial buffers are used.

ALLOWEDCORE is the ultimate limiting factor for any or all structures. Regardless of the 512 value or calculated value for SYSTEM BUFFERS + RANDOM BUFFERS PER USER for any individual structure, when ALLOWEDCORE is reached, OVERLAYs will begin and a new buffer allocation will be restricted.

You can use the BUFFERS option with the REBLOCK option to perform serial optimization (readahead or reblocking). Both readahead and reblocking cause a decrease in total elapsed time. To use the BUFFERS option to activate serial optimization, assign the serial user option a value greater than or equal to 2. To deactivate serial optimization, assign the serial user option a value less than 2.

Readahead is a type of serial optimization that enables the Accessroutines to read blocks before they are needed. Readahead reduces the time required to access records serially by decreasing buffer wait time, which in turn causes a decrease in total elapsed time. For data sets, readahead causes the next physical block of data to be retrieved. Serially accessing records through a set or subset causes the next set or subset table to be retrieved. The data set records pointed to by entries in that set or subset table are also retrieved and placed in the data set's data buffers.

Reblocking is another type of serial optimization that you activate by using the REBLOCK option. Reblocking enables you to optimize both random and serial access to a structure by enabling you to maintain two block sizes for the same structure simultaneously, as follows:

  • The smaller block is specified in the BLOCKSIZE option. The Enterprise Database Server uses this block for random access.

  • The larger block size is a multiple of the BLOCKSIZE option value. You specify in the REBLOCKFACTOR option how many times larger the enlarged block should be (for example, a value of 2 for an enlarged block that is twice the size specified in the BLOCKSIZE option). The Enterprise Database Server uses the enlarged block for serial access.

Depending on the REBLOCKFACTOR option value and on whether access is serial, reblocking can cause the Accessroutines to read data using an enlarged block rather than the block size specified in the BLOCKSIZE option.

The benefit of reblocking is that the larger block size increases the amount of serially accessed records placed in the buffers for each physical read operation.

The REBLOCK and REBLOCKFACTOR options can affect whether readahead occurs. When the REBLOCK option is turned on and the value of the REBLOCKFACTOR is set to a value greater than 1, readahead logic is turned off for data set accessing. The system performs this action even if the value of the BUFFERS option stipulates that readahead is to be activated.

Readahead logic reads one block (of BLOCKSIZE value) at a time. Readahead logic cannot read the enlarged blocks created by reblocking. When readahead logic is turned off and the value of the REBLOCKFACTOR option is 2 or greater, one physical I/O operation reads as much or more information as readahead logic would read.

The REBLOCK option is not valid for sets and subsets. When accessing data through sets or subsets, readahead logic is used, as follows:

  • For sets and subsets only, when a set or subset is accessed in a serial manner, even if the value of the REBLOCKFACTOR option is greater than 1 for the associated data set.

  • For data sets only, when the order of the data set is different from the order of the accessing set or subset, and the REBLOCK option is turned off or the value of the REBLOCKFACTOR option is set to 1.

However, when a data set is in the same order as the order of its accessing set or subset, reblocking is used if the value of the REBLOCKFACTOR option is greater than 1.

In database statistics, a read operation using the reblocking mechanism is counted as a readahead.

Readahead logic is still used when the sets are accessed serially, even if the value of the REBLOCKFACTOR is greater than 1 for the associated data set. A read operation using the reblocking mechanism is counted as a readahead in the database statistics.

When the READAHEAD option is set to TRUE, the Accessroutines detects whether a program is accessing a structure randomly or serially. When a structure is being accessed serially and 2 or more serial buffers are specified, the Accessroutines allocates the appropriate number of serial buffers for the program; otherwise, the specified number of random buffers is allocated. (The size of the serial buffers depends on the REBLOCK attribute. Refer to “REBLOCK and REBLOCKFACTOR Options” later in this section for more details.)

If a program oscillates between serial and random access, the Accessroutines detects this and make it increasingly more difficult for a program to change modes. This prevents spurious readaheads and avoids buffer allocation and deallocation.

The Accessroutines detects serial access on a program-by-program basis. If several consecutive accesses are made to the same block or to logically adjacent next blocks, then the program enters serial mode. Once serial mode is entered, a readahead or reblock operation is performed each time another block is required. Note that the access of the logically adjacent prior block is not considered to be serial access.

If a user program switches from random access to serial access or from serial access to random access, the DECLAREDBUFFERS parameter is adjusted accordingly. If the program switches repeatedly from random mode to serial mode, the Accessroutines increments the number of accesses needed to cause a state change. This prevents spurious readaheads and avoids buffer allocation and deallocation.