How Does Buffer Hashing Work?
Using VSAM buffer hashing, you can take advantage of using very large buffer pools, without the disadvantage of additional processor load.
VSAM Buffer Hashing uses a:
- Hash Table – A table in main storage in which each table entry is used as a pointer to a BCB (Buffer Control Block). A BCB contains the address of the buffer (for data or index), and information about the buffer itself. There is one BCB for each buffer in the LSR buffer pool.
- Synonym – When using a hashing technique, synonyms may occur when two or more entities hash to the same anchor point. In VSAM Buffer Hashing, synonyms are chained together in the BCB. However, the possibility that synonyms occur is very small, and the chain is usually very short.
- Hash Algorithm, which is calculated as follows:
-
X = remainder of (RBA/2 + DSID1/2 + DSID2/2) / DIM
where:
- X
- The remainder of the above calculation, and is used as the index to the hash table.
- RBA
- The Relative Byte Address, used by VSAM to identify a certain buffer in the LSR buffer pool.
- DSID1 and DSID2
- The Data Set Identifiers (DSIs), which are unique identifications of a certain opened VSAM data set component, either a data or an index component.
- DIM
- The number of entries in the Hash Table. DIM = (2N-1).
- N
- The number of buffers in the subpool.
-
Here is a "simple" example:
"Simple" in this case means that the values of this example were simplified to decimal values (not hexadecimal) to give a better understanding of the technique.
- Let us assume that we have an LSR pool with 10 buffers. The Hash
Table will have (2 * 10 -1) = 19 entries. Therefore:
DIM = 19
- A VSAM GET operation reads a data record from a certain VSAM data
set with the internal data set identifications DSD1 and DSD2 into
a data buffer. Therefore:
DSID1 = 220, DSID2 = 32
The BCB pointing to that data buffer is at storage location '640000'. The RBA (Relative Byte Address) of the VSAM data buffer is 800. Therefore:
RBA = 800
- The hash algorithm
X = remainder of (RBA/2 + DSID1/2 + DSID2/2) / DIMtherefore calculates the following index for the hash table:(800/2 + 220/2 + 32/2) /19 = 27, remainder = 13 = X
"13" will be used as index into the hash table.
- The BCB pointer '640000' will be stored in the 13th position of the hash table.
- Whenever another request is searching for a data buffer with RBA 800 from this certain dataset, the hash algorithm can calculate easily the index of 13 into the hash table and use the BCB at address '640000' and its related data buffer without a long pool search. This hashing technique also works, of course, with very large buffer pools (for example, 32767 buffers).