-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LITTLEFS 10 times slower than SPIFFS on ESP32 #6345
Comments
@lorol Any ideas? |
I can confirm that my application sees a 10X-15X slower performance of LittleFS on the ESP32 compared to the ESP8266. I created a minimal reproducible example (see below) which shows roughly:
Minimal Reproducible Example #include <Arduino.h>
#include <LittleFS.h>
#define FILE_SYSTEM LittleFS
//-----------------------------------------------------------------------------
void createFile(const char* fileName, uint32_t fileSize) {
unsigned long startMillis = millis();
File f = FILE_SYSTEM.open(fileName, "w");
for (uint32_t i = 0; i < fileSize; i++) {
f.write((uint8_t) i);
}
f.close();
unsigned long elapsedMillis = millis() - startMillis;
Serial.printf("%-10s(%-11s, %6lu): %6lu millis\n",
"createFile", fileName, (unsigned long) fileSize, elapsedMillis);
}
void readFile(const char* fileName, uint32_t fileSize) {
unsigned long startMillis = millis();
File f = FILE_SYSTEM.open(fileName, "r");
for (uint32_t i = 0; i < fileSize; i++) {
uint8_t c = f.read();
if (c != (uint8_t) i) {
Serial.printf("Unexpected byte at index %lu\n", (unsigned long) i);
}
}
f.close();
unsigned long elapsedMillis = millis() - startMillis;
Serial.printf("%-10s(%-11s, %6lu): %6lu millis\n",
"readFile", fileName, (unsigned long) fileSize, elapsedMillis);
}
void seekFile(
const char* fileName,
uint32_t fileSize,
uint16_t numSeeks,
uint32_t readSize
) {
unsigned long startMillis = millis();
File f = FILE_SYSTEM.open(fileName, "r");
for (uint16_t i = 0; i < numSeeks; i++) {
uint32_t offset = random(fileSize);
f.seek(offset);
for (uint32_t i = offset; i < offset + readSize && i < fileSize; i++) {
uint8_t c = f.read();
if (c != (uint8_t) i) {
Serial.printf("Unexpected byte at index %lu\n", (unsigned long) i);
}
}
}
f.close();
unsigned long elapsedMillis = millis() - startMillis;
Serial.printf("%-10s(%-11s, %4u, %4lu): %6lu millis\n",
"seekFile", fileName, (unsigned) numSeeks, (unsigned long) readSize,
elapsedMillis);
}
//-----------------------------------------------------------------------------
void setup() {
delay(1000);
Serial.begin(115200);
Serial.println(F("==== Initializing file system."));
if (! FILE_SYSTEM.begin()) {
Serial.println(F("File system failed."));
exit(1);
}
createFile("/file0.txt", 1000);
createFile("/file1.txt", 2000);
createFile("/file2.txt", 4000);
createFile("/file3.txt", 8000);
createFile("/file4.txt", 16000);
createFile("/file5.txt", 32000);
createFile("/file6.txt", 64000);
readFile("/file0.txt", 1000);
readFile("/file1.txt", 2000);
readFile("/file2.txt", 4000);
readFile("/file3.txt", 8000);
readFile("/file4.txt", 16000);
readFile("/file5.txt", 32000);
readFile("/file6.txt", 64000);
seekFile("/file0.txt", 1000, 1000, 30);
seekFile("/file1.txt", 2000, 1000, 30);
seekFile("/file2.txt", 4000, 1000, 30);
seekFile("/file3.txt", 8000, 1000, 30);
seekFile("/file4.txt", 16000, 1000, 30);
seekFile("/file5.txt", 32000, 1000, 30);
seekFile("/file6.txt", 64000, 1000, 30);
seekFile("/file0.txt", 1000, 1000, 100);
seekFile("/file1.txt", 2000, 1000, 100);
seekFile("/file2.txt", 4000, 1000, 100);
seekFile("/file3.txt", 8000, 1000, 100);
seekFile("/file4.txt", 16000, 1000, 100);
seekFile("/file5.txt", 32000, 1000, 100);
seekFile("/file6.txt", 64000, 1000, 100);
Serial.println("==== Done");
}
void loop() {} The output is: ESP8266
ESP32
Environments
|
Hello, are you able to retest this with Arduino core ESP32 version 2.0.3-rc1? Thanks! |
Any updates? |
I'm experiencing exactly the same, with arduino-esp32 2.0.2 and 2.0.3 As workound, downgrading to arduino-esp32 1.0.6 and adding https://github.com/lorol/LITTLEFS LittleFS library seems to have fixed the performance issue. |
@VojtechBartoska: Who is the "you" that you are asking? In my case, for various reasons, I don't have the environment and hardware to re-run the example that I uploaded, at least not for a while. But I uploaded a complete reproducible example, so anyone else can. |
Adding this to our Roadmap. |
Thank you so much from me too |
Almost the same results for me on ESP32-Wrover-E ( 8mb psram 16mb flash ) So i'm testing external ram, internal ram and flash too. Here is my results: ******************** External ram test ********************
Read Speed 8bit ArraySize 1kb time: 0.0 sec 12.5 mb/sec
Read Speed 8bit ArraySize 2kb time: 0.0 sec 12.6 mb/sec
Read Speed 8bit ArraySize 4kb time: 0.0 sec 12.6 mb/sec
Read Speed 8bit ArraySize 8kb time: 0.0 sec 12.6 mb/sec
Read Speed 8bit ArraySize 16kb time: 0.1 sec 12.6 mb/sec
Read Speed 8bit ArraySize 32kb time: 0.1 sec 12.2 mb/sec
Read Speed 8bit ArraySize 64kb time: 0.4 sec 8.6 mb/sec
Read Speed 8bit ArraySize 128kb time: 0.7 sec 8.6 mb/sec
Read Speed 8bit ArraySize 256kb time: 1.5 sec 8.6 mb/sec
Read Speed 8bit ArraySize 512kb time: 0.6 sec 8.6 mb/sec
Read Speed 8bit ArraySize 1024kb time: 1.2 sec 8.6 mb/sec
Read Speed 8bit ArraySize 2048kb time: 2.3 sec 8.6 mb/sec
Read Speed 8bit ArraySize 4000kb time: 4.6 sec 8.5 mb/sec
Read Speed 16bit ArraySize 1kb time: 0.0 sec 22.3 mb/sec
Read Speed 16bit ArraySize 2kb time: 0.0 sec 22.5 mb/sec
Read Speed 16bit ArraySize 4kb time: 0.0 sec 22.5 mb/sec
Read Speed 16bit ArraySize 8kb time: 0.0 sec 22.5 mb/sec
Read Speed 16bit ArraySize 16kb time: 0.0 sec 22.5 mb/sec
Read Speed 16bit ArraySize 32kb time: 0.1 sec 21.8 mb/sec
Read Speed 16bit ArraySize 64kb time: 0.3 sec 12.4 mb/sec
Read Speed 16bit ArraySize 128kb time: 0.5 sec 12.3 mb/sec
Read Speed 16bit ArraySize 256kb time: 1.0 sec 12.3 mb/sec
Read Speed 16bit ArraySize 512kb time: 0.4 sec 12.3 mb/sec
Read Speed 16bit ArraySize 1024kb time: 0.8 sec 12.3 mb/sec
Read Speed 16bit ArraySize 2048kb time: 1.6 sec 12.3 mb/sec
Read Speed 16bit ArraySize 4000kb time: 3.2 sec 12.4 mb/sec
Read Speed 32bit ArraySize 1kb time: 0.0 sec 43.7 mb/sec
Read Speed 32bit ArraySize 2kb time: 0.0 sec 44.6 mb/sec
Read Speed 32bit ArraySize 4kb time: 0.0 sec 44.6 mb/sec
Read Speed 32bit ArraySize 8kb time: 0.0 sec 44.7 mb/sec
Read Speed 32bit ArraySize 16kb time: 0.0 sec 44.7 mb/sec
Read Speed 32bit ArraySize 32kb time: 0.0 sec 42.1 mb/sec
Read Speed 32bit ArraySize 64kb time: 0.2 sec 17.0 mb/sec
Read Speed 32bit ArraySize 128kb time: 0.4 sec 16.9 mb/sec
Read Speed 32bit ArraySize 256kb time: 0.7 sec 16.9 mb/sec
Read Speed 32bit ArraySize 512kb time: 0.3 sec 16.9 mb/sec
Read Speed 32bit ArraySize 1024kb time: 0.6 sec 16.9 mb/sec
Read Speed 32bit ArraySize 2048kb time: 1.2 sec 16.9 mb/sec
Read Speed 32bit ArraySize 4000kb time: 2.3 sec 16.9 mb/sec
****************** External ram test DONE ******************
******************** Internal ram test ********************
Read Speed 8bit ArraySize 1kb time: 0.0 sec 12.6 mb/sec
Read Speed 8bit ArraySize 2kb time: 0.0 sec 12.6 mb/sec
Read Speed 8bit ArraySize 4kb time: 0.0 sec 12.6 mb/sec
Read Speed 8bit ArraySize 8kb time: 0.0 sec 12.5 mb/sec
Read Speed 8bit ArraySize 16kb time: 0.1 sec 12.6 mb/sec
Read Speed 8bit ArraySize 32kb time: 0.1 sec 12.2 mb/sec
Read Speed 8bit ArraySize 64kb time: 0.4 sec 8.6 mb/sec
Read Speed 8bit ArraySize 128kb time: 0.7 sec 8.6 mb/sec
Read Speed 16bit ArraySize 1kb time: 0.0 sec 22.6 mb/sec
Read Speed 16bit ArraySize 2kb time: 0.0 sec 22.7 mb/sec
Read Speed 16bit ArraySize 4kb time: 0.0 sec 22.7 mb/sec
Read Speed 16bit ArraySize 8kb time: 0.0 sec 22.3 mb/sec
Read Speed 16bit ArraySize 16kb time: 0.0 sec 22.5 mb/sec
Read Speed 16bit ArraySize 32kb time: 0.1 sec 21.8 mb/sec
Read Speed 16bit ArraySize 64kb time: 0.3 sec 12.4 mb/sec
Read Speed 16bit ArraySize 128kb time: 0.5 sec 12.3 mb/sec
Read Speed 32bit ArraySize 1kb time: 0.0 sec 45.2 mb/sec
Read Speed 32bit ArraySize 2kb time: 0.0 sec 45.3 mb/sec
Read Speed 32bit ArraySize 4kb time: 0.0 sec 45.3 mb/sec
Read Speed 32bit ArraySize 8kb time: 0.0 sec 43.9 mb/sec
Read Speed 32bit ArraySize 16kb time: 0.0 sec 44.7 mb/sec
Read Speed 32bit ArraySize 32kb time: 0.0 sec 42.1 mb/sec
Read Speed 32bit ArraySize 64kb time: 0.2 sec 17.0 mb/sec
Read Speed 32bit ArraySize 128kb time: 0.4 sec 16.9 mb/sec
****************** Internal ram test DONE ******************
******************** Flash speed test ********************
File system mounted.
createFile(/file0.txt , 1000): 248 millis
createFile(/file1.txt , 2000): 80 millis
createFile(/file2.txt , 4000): 538 millis
createFile(/file3.txt , 8000): 163 millis
createFile(/file4.txt , 16000): 308 millis
createFile(/file5.txt , 32000): 595 millis
createFile(/file6.txt , 64000): 1161 millis
readFile (/file0.txt , 1000): 40 millis
readFile (/file1.txt , 2000): 50 millis
readFile (/file2.txt , 4000): 68 millis
readFile (/file3.txt , 8000): 105 millis
readFile (/file4.txt , 16000): 183 millis
readFile (/file5.txt , 32000): 342 millis
readFile (/file6.txt , 64000): 663 millis
seekFile (/file0.txt , 1000, 30): 330 millis
seekFile (/file1.txt , 1000, 30): 331 millis
seekFile (/file2.txt , 1000, 30): 331 millis
seekFile (/file3.txt , 1000, 30): 750 millis
seekFile (/file4.txt , 1000, 30): 1206 millis
seekFile (/file5.txt , 1000, 30): 1669 millis
seekFile (/file6.txt , 1000, 30): 2103 millis
seekFile (/file0.txt , 1000, 100): 958 millis
seekFile (/file1.txt , 1000, 100): 987 millis
seekFile (/file2.txt , 1000, 100): 1001 millis
seekFile (/file3.txt , 1000, 100): 1434 millis
seekFile (/file4.txt , 1000, 100): 1881 millis
seekFile (/file5.txt , 1000, 100): 2337 millis
seekFile (/file6.txt , 1000, 100): 2847 millis
******************** Flash speed DONE ******************** Ram testing looks like this: int hshTest::ramSpeed( boolean isExtRam = true ) {
if( isExtRam ){
printf("\n******************** External ram test ********************\n");
}else{
printf("\n******************** Internal ram test ********************\n");
}
char xx = 0;
for (int a = 0; a < 13; a++) {
// Internal ram overflow protection
if( !isExtRam && rs[a] > 128 ){ printf("\n");break; }
printf("Read Speed 8bit ArraySize %4dkb ", rs[a]);
int ramsize = rs[a] * 1024;
char* rm;
if( isExtRam ){
rm = (char*)ps_malloc(ramsize);
}else{
rm = (char*)malloc(ramsize);
}
int iters = 10; // Just enuff to boot the dog
if (rs[a] < 512) iters = 50;
double st = getTime();
for (int b = 0; b < iters; b++)
for (int c = 0; c < ramsize; c++)
xx |= rm[c];
st = getTime() - st;
vTaskDelay(1); // Dog it!
double speed = ((double)(iters * ramsize) / (1024 * 1024)) / (st);
printf(" time: %2.1f sec %2.1f mb/sec \n", st, speed);
free(rm);
}
printf("\n");
for (int a = 0; a < 13; a++) {
// Internal ram overflow protection
if( !isExtRam && rs[a] > 128 ){ printf("\n");break; }
printf( "Read Speed 16bit ArraySize %4dkb ", rs[a]);
int ramsize = rs[a] * 1024;
short* rm;
if( isExtRam ){
rm = (short*)ps_malloc(ramsize);
}else{
rm = (short*)malloc(ramsize);
}
int iters = 10; // Just enuff to boot the dog
if (rs[a] < 512) iters = 50;
double st = getTime();
for (int b = 0; b < iters; b++)
for (int c = 0; c < ramsize / 2; c++)
xx |= rm[c];
st = getTime() - st;
vTaskDelay(1); // Dog it!
double speed = ((double)(iters * ramsize) / (1024 * 1024)) / (st);
printf(" time: %2.1f sec %2.1f mb/sec \n", st, speed);
free(rm);
}
printf("\n");
for (int a = 0; a < 13; a++) {
// Internal ram overflow protection
if( !isExtRam && rs[a] > 128 ){ printf("\n");break; }
printf("Read Speed 32bit ArraySize %4dkb ", rs[a]);
int ramsize = rs[a] * 1024;
int* rm;
if( isExtRam ){
rm = (int*)ps_malloc(ramsize);
}else{
rm = (int*)malloc(ramsize);
}
int iters = 10; // Just enuff to boot the dog
if (rs[a] < 512) iters = 50;
double st = getTime();
for (int b = 0; b < iters; b++)
for (int c = 0; c < ramsize / 4; c++)
xx |= rm[c];
st = getTime() - st;
vTaskDelay(1); // Dog it!
double speed = ((double)(iters * ramsize) / (1024 * 1024)) / (st);
printf(" time: %2.1f sec %2.1f mb/sec \n", st, speed);
free(rm);
}
if( isExtRam ){
printf("****************** External ram test DONE ******************\n\n");
}else{
printf("****************** Internal ram test DONE ******************\n\n");
}
return xx;
} Here is my test sketch: https://github.com/zekageri/HsH_ESP_Tester/tree/main |
Just as un update to another thing that I have noticed, which may be related to this problem. I'm using this library to store log entries in a partition. I have noticed that vs SPIFFS not only do row inserts become slower, but that for the same amount of data, on LittleFS the used space has grown 3x when compared to SPIFFS. |
any update on this ? |
Waiting |
Does it mean using SPIFFS.h is better than LittleFS.h ? |
I just did some quick testing on 3.0.4. LittleFS writes do get a bit slower as the disk gets fragmented (goes from 96ms to 200ms for open/write 4096/close), but is comparable to SPIFFS on a clean FS. SPIFFS does not get slower as it gets more fragmented, but it never says that it is out of space, so when it gets to the limit it dramatically slows down (1500ms for a write), but it will continue behaving as though it is writing, even though the disk is clearly full. |
Thank you. |
Any update? |
Hello, I close this since this report contains the release we no longer support. Please try the new versions and in case the issue persists, feel free to reopen it. Thanks |
Thanks. Will reopen it because it still exists on latest arduino |
Board
ESP32 Dev Module 4MB
Device Description
The ESP32 board info:
Board: "ESP32 Dev Module"
Upload Speed: "921600"
CPU Frequency: "240MHz (WiFi/BT"
Flash Frequency: "80MHz"
Flash Mode: "QIO"
Flash Size: "4MB (32Mb)"
Partition Scheme: "No OTA (2MB APP 2MB SPIFFS)"
Core Debug Level: "None"
PSRAM: "Disabled"
Arduino Runs On: Core1
Events Run On: Core1
Port: "COM9"
Hardware Configuration
no external devices
Version
v2.0.2
IDE Name
Arduino IDE 1.8.19
Operating System
Win10 64bit
Flash frequency
80MHz
PSRAM enabled
no
Upload speed
115200
Description
Hi,
I initially posted it on forum.arduino.cc but got no replies there. Maybe that was the wrong place to post it.
I have a project in mind where I have to write sensor data into file in ESP32 flash memory (yes, I am aware of 10000 writes limit). As I understood SPIFFS is deprecated and LittleFS would be the way to go.
I decided to do a little speed test first. I uploaded the Arduino IDE ESP32 LITTLEFS_test.ino sketch onto the regular ESP32 Dev Module and added a couple of lines of code into loop to measure the append time of text "qwerty" to the file data.txt on ESP32 file system. I uploaded the file via ESP32 Sketch Data Upload tool with LittleFS, that seems to format the flash for using LittleFS.
To my great surprise the append function run time was 20-30ms in the beginning and when the data.txt file grew to a few hundred bytes it became 50-70ms. And there is very odd behavior - every 15th time the append operation takes 250-350ms. That does not depend on the append function call period. Extra long append time occurs every 15th time would the call period be 1, 2 or 3 seconds.
When I run the same script modified to use SPIFFS the append function run time is steady 5ms.
I tested the sketch on 2 different boards with the same results. I also uninstalled ESP32 boards from Arduino IDE and reinstalled. No difference.
Thank you in advance to get the LittleFS working.
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: