apache / apache/nuttx

littlefs on SD/eMMC read/write performance is poor

Open
#9,080 19 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

Hi,

Utilising the littlefs filesystem on SD/eMMC is providing read/write speeds of approximately 50KiB/sec (calculated using dd command). I've tried optimising the menuconfig settings to improve it, including options such as below but still the performance is lacking:

- Turning on CONFIG_MEMCPY_VIK gave slight improvement
- Setting USEC_PER_TICK to 1000 or below gave most improvement, however at the detriment of other aspects of the system. The fastest speeds observed by adjusting this was ~370KiB/s write and 700KiB/s read though overall this was unacceptable given the effect on the rest of the system.
- Adjusting LittleFS parameters (e.g. CONFIG_FS_LITTLEFS_PROGRAM_SIZE_FACTOR, CONFIG_FS_LITTLEFS_READ_SIZE_FACTOR, CONFIG_FS_LITTLEFS_BLOCK_SIZE_FACTOR, CONFIG_FS_LITTLEFS_CACHE_SIZE_FACTOR, CONFIG_FS_LITTLEFS_LOOKAHEAD_SIZE
- Ensuring SD/eMMC DMA read/writes are enabled
- Setting MMCSD_MULTIBLOCK_LIMIT to 0

Details of build:

- risc-v architecture using running kernel in S-mode, main clock running @ 75MHz, SD peripheral @ 25MHz
- Toolchain: riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14
- Nuttx GIT version: https://github.com/apache/nuttx/pull/8922 with local changes in littlefs to use kmm_malloc/free due to using DMA and S-mode kernel
- Built with commands:
```
$ make distclean -j16
$ ./tools/configure.sh rv-virt:knsh64
$ make -j16
$ make export -j16
$ make import -j16
```
- Executed with command:
` $ qemu-system-riscv64 -semihosting -M virt,aclint=on -cpu rv64 -smp 8 -bios none -kernel nuttx -nographic -serial mon:stdio`

Our architecture and hardware design requires the product to boot from eMMC and have a fast boot time for a firmware image of > 2MiB. At 50KiB/s the image load itself would consume >40 seconds.

NOTE: Interestingly littlefs performs considerably better than vFAT on SD/eMMC, which on the same setup has read/writes speeds of ~12KiB/s. Littlefs however on a RAM disk gives speeds of 560KiB/s for write which is considerably slower than vFAT, which measures ~3225KiB/s.

Does anyone have a rough feel on what performance we could expect when using littefs on SD/eMMC in Nuttx for a configuration like described above and are there ways to improve this?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.