|
When determining the optimal number and size of buffers, it is important to note that an interrupt is generated every time a buffer is filled.
Therefore, the size of buffers will be a function of the data rate and the desired number of interrupts in a given time interval. E.g. for 100 interrupts/second for SDI data (270 Mbps):
Buffer size = (data rate) / (interrupt rate) = (270 * 10^6) / 100 = 2.7 Mbits or 337.5 Kbytes
The number of buffers should be high enough to account for the worst case time it takes to handle the data contained in a buffer. E.g. assuming it takes 10 seconds to store 1 buffer worth of data the required number of buffers from above would be:
Buffer number = (data rate) * time / (buffer size) = (270 * 10^6) * (10) / (2.7 * 10^6) = 1000 = (interrupt rate) * time = 100 * 10 = 1000
The sector size and packet size are additional factors to consider when determining the optimal buffer size. Buffers that are a multiple of the sector size (usually 512 Bytes) allow for faster operation when reading from (or writing to) file systems. Using Direct I/O in Windows, for example, requires that the buffer size be a multiple of sector size.
NOTE: Sector size is a disk drive/controller unit and should not be confused with cluster size (which is a file system unit).
Similarly, buffers that are a multiple of packet size prevent partial packets from being written at the end of the file. Another benefit is that analysis programs can refer to the same buffer locations to look at packets rather than realigning buffers. This reduces the CPU cycle time and increases performance.
To calculate the buffer size, take the product of the packet size and the sector size and divide by the greatest common factor of the two. The optimal buffer size will be a multiple, k, of this value (where k can be chosen such that the buffer size will generate the required interrupt rate as per above). Eg. For a sector size of 512 Bytes and 188 byte packets:
Buffer size = k * (packet size) *(sector size) greatest_common_factor (packet size, sector size) = 4 * [(188)*(512) / 4 ] = 96,256 (or 0x17800 in hex) for k = 4
[Top] |