Hi all,
We are working on porting a real-time application from VxWorks to Linux as a sort of experiment to see if Linux fits our needs for this application. We are using a server distro of Ubuntu 9.04 running on a PCI-104 single-board computer with a Sandisk Extreme III 16 GB compact flash (rated 30 MB/s access) disk for storage. So far the port has gone quite well. We found a library called v2lin on SourceForge that allowed us to port the application making minimal changes to the actual code. For simplicity, we have ported the code to a single process, multi-threaded application, similar to how it ran in VxWorks.
One of the jobs of the application is to record the images that it is processing to disk for post-analysis/processing. The system processes these 640x480 images (300 kB each) at 10 Hz, giving a total of about 3 MB/s we want to write to disk. With the disk rated at 30 MB/s and tests showing at least a capacity of 10-15 MB/s, that seems like it should be possible for the system to maintain a 3 MB/s stream of data to the disk, even with file system overhead and all. In the current implementation, we get an image and write it to disk, the wait on the next image. So if it takes longer than 100 ms to write the image, we will miss the next image(s).
What we are seeing is that in most cases, it takes 1-3 ms to "write" each image file. Since this is obviously much faster than it is actually possible to write 300 kB of data, it is clear it is making good use of RAM to cache the file before actually writing it to the CF disk. However, sometimes it will take much longer to complete the image write call, from a few hundred ms to a few seconds. Using things like vmstat, iostat, and /proc/meminfo, we have been able to see that Linux is writing out the buffered data to disk in spurts. When it starts to get "behind" it will block the application and wait for some data to be written out to disk before continuing.
What we would like to do is to even out those spurts of actual disk writing to be more consistent. The application takes a relatively small portion of the 100 ms per image to process, so it should have quite a bit of time to write out an image to disk. But it seems to just sit there at times, content to let the disk cache build up. Does anyone know where we might look to tune something or change some setting that would get us more consistent disk writing? Thanks!
Jonathan