LocalFileSystem performance

07 Feb 2012

I want to play 44kHz stereo 16bit wav files from LocalFileSystem. However I measured the performance of fread() reading 4096 bytes at a time and I got a maximum read performance of about 100kbyte/s. It is much lower than 176kbyte/s I need to feed the external DAC. Is it the absolute maximum I can achieve with LocalFileSystem? Is there a way to boost performance?

07 Feb 2012

Yes, my second thought was the same. The only problem is I don't have any breakout board for that and I don't want to wait a week or so for one to arrive. I need workaround.

Perhaps I could use a USB breakout board to attach a thumb drive instead.

23 Nov 2013

Sheldon Cooper wrote:

I want to play 44kHz stereo 16bit wav files from LocalFileSystem. However I measured the performance of fread() reading 4096 bytes at a time and I got a maximum read performance of about 100kbyte/s. It is much lower than 176kbyte/s I need to feed the external DAC. Is it the absolute maximum I can achieve with LocalFileSystem? Is there a way to boost performance?

I guess by now Sheldon has found a solution. However, I am also interested in the LocalFileSystem performance, and I can't find much about it other than in this thread.

Well, I also found where somebody said "in general the localfilesystem is not meant for fast access". In comparison to what I guess you could get reading from an SD card instead, maybe 100kbytes per second is slow, but for what I am trying to do (coax an LPC11u24 into playing a midi file), I could live with 100 kbyte/s.

Actually, I would be real happy right now if I saw 10kbyte/s per second, but I am not even getting 1kbyte/s.

If I read 4096 bytes using fread(), I am seeing a blistering 627 bytes per second - it takes around 6.5 seconds to read the 4096 bytes! Unfortunately, it gets worse, particularly if I am playing a multi-track file, because I then have to read much smaller chunks of data, and I have to precede every read with an fseek, and I can be down to less than 400 bytes per second,

Can anybody else confirm a speed of 100kbytes per second for a LocalFileSystem read?

If my times are out of line with expectations, what might I be doing wrong?

23 Nov 2013

The fwrite/fread performance of the LocalFileSystem isn't as good on the LPC11U24 version of the mbed as it is on the LPC1768 version. This is due to differences in the Standard C Libraries. This forum post has more information on the issue and a way to work around it by calling LocalFileSystem's read/write routines directly and bypassing the Standard C Library.

I hope that helps,

Adam

24 Nov 2013

Adam Green wrote:

The fwrite/fread performance of the LocalFileSystem isn't as good on the LPC11U24 version of the mbed as it is on the LPC1768 version. This is due to differences in the Standard C Libraries. This forum post has more information on the issue and a way to work around it by calling LocalFileSystem's read/write routines directly and bypassing the Standard C Library.

I hope that helps,

Adam

Thanks Adam.

I tried using local_file_open() and LocalFileHandle and it makes a big difference.

Reading 4096 bytes at a time I am now getting better than 100kbytes/s - it varies a bit, but is around 120kbytes/s. Reading 1024 bytes at a time, it was down to around 70kbytes/s.

In reality, I might have to read much less than that as a time. For very short lengths, the times were all over the place. I saw the read of a single byte taking as long as 11ms, yet it also managed to read 512 bytes in 7ms.