Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

File Buffering

LabVIEW 2013 Help

Edition Date: June 2013

Part Number: 371361K-01

»View Product Info

During each file I/O operation, LabVIEW calls the operating system (OS) and requests a data transfer to and from a file on a disk. Sending data to or receiving data from a disk may take a few milliseconds to complete. These milliseconds can accumulate because LabVIEW must call the OS each time you write a line to a file or request to read a file. 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. This technique 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.

Sometimes, 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, you must 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.

 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit