Filesystems and block I/O (devb-*) drivers
Here are the basic steps to improving the performance of your filesystems and block I/O (devb-*) drivers.
- Optimize the filesystem options:
- Determine how you want to balance system robustness and performance (see below).
- Concentrate on the cache and vnode (filesystem-independent inodes) options; the other sizes scale themselves to these.
- Set the commit option (either globally or as a mount option) to force or disable synchronous writes.
- Consider using a RAM disk for temporary files (e.g., /tmp).
- Optimize application code:
- Read and write in large chunks (16–32 KB is optimal).
- Read and write in multiples of a disk block on block boundaries (typically 512 bytes, but you can use stat() or statvfs() to determine the value at runtime).
- Avoid standard I/O where possible; use
The f* functions use an extra layer of buffering.
The default size is given by BUFSIZ; you can use
to specify a different buffer size.
As a BlackBerry 10 OS extension, you can use the STDIO_DEFAULT_BUFSIZE environment variable to override BUFSIZ as the default buffer size for stream I/O. The value of STDIO_DEFAULT_BUFSIZE must be greater than that of BUFSIZ.
- Pregrow files, if you know their ultimate sizes.
- Use direct I/O (DMA to user space).
- Use filenames that are no longer than 16 characters.
If you do this, the filesystem won't use the .inodes
file, so there won't be any inter-block references.
In addition, there will be one less disk write, and hence, one less
chance of corruption if the power fails.
Long filenames (i.e., longer than 48 characters) especially slow down the filesystem.
- Big directories are slower than small ones, because the filesystem uses a linear search.
Last modified: 2013-12-21