Improving Efficiency by Disabling File Buffering

FlexRIO Help

Edition Date: November 2015

Part Number: 372614J-01

»View Product Info

»Download the Help in ZIP Format

During each file I/O operation, LabVIEW takes a few milliseconds to call the operating system (OS) and request a data transfer to and from a file on a disk. These milliseconds accumulate every time LabVIEW calls the OS. To avoid these timely repetitions, most OS file systems provide a buffer to temporarily hold each piece of data waiting to be read or written to a file. When the buffer is full, the OS performs a single file I/O operation.

The process described in the previous paragraph is known as buffering, and LabVIEW enables it by default. Buffering reduces the number of times the OS must access the disk and expend processing time.

When to Disable Buffering

In some cases, you can achieve faster data streaming rates if you disable buffering. For example, you may use a Redundant Array of Independent Disks (RAID) to increase processing speed. A RAID is a set of hard disks acting as a single disk that the OS can simultaneously access, taking less time to read or write data. If you access a RAID with buffering enabled, LabVIEW can take more time to copy data to the OS than the OS takes to actually write the data to the disk. You can disable buffering with the disable buffering input of the Open/Create/Replace File function to avoid these data copies and force the OS to send data directly to disk.

However, if you disable buffering, make sure the following conditions are true:

  • You must make the size of the data in the file a multiple of the sector size, indicated in bytes, of the disk that contains or may eventually contain the file. A sector is a subdivision of disk space that stores a fixed amount of data, typically 512 bytes. Use the sector size (bytes) output of the Get Volume Info function to determine the sector size of the disk. For LabVIEW to save data to a disk, the data can span multiple sectors but must fill each sector completely. A 512-byte sector requires 512 bytes of data. If the data is not a multiple of the sector size, you must pad the data with filler data and delete the filler data before LabVIEW reads back the file.
  • The data in the file must be aligned to a multiple of the alignment the disk requires. LabVIEW aligns the data, and you cannot change that alignment. If the data does not meet the alignment requirement, LabVIEW returns an error and you must enable buffering and reopen the file.

Related Information

Buffering Data


Not Helpful