adafruit / Adafruit_QSPI

MIT License
7 stars 6 forks source link

Metro M4 SPI / SdFat performance issue #2

Closed SapientHetero closed 6 years ago

SapientHetero commented 6 years ago

I just started working with the Metro M4. I mounted an Adafruit WINC1500 shield and ported Arduino-based software I wrote for a Mega to it expecting huge performance improvements, only to find that it crawls. I traced the slowdown to portions of my code that communicate with the shield, so I ran the SdFat bench example program to quantitatively compare the M4's performance to that of the Mega using the same shield, same software and same freshly formatted micro-SD card for both tests. The M4 performance on this test was on the order of 28x slower for writes and 50x slower for reads.

I haven't yet done quantitative benchmarking on WiFi performance but the software I ported to the M4 reports on its maximum loop time. When not actively serving pages the max loop time on the Mega is 2ms; on the M4, it's nearly 900ms. I've isolated the slowdown to a function that does WiFi communication, which leads me to believe the issue is SPI-related.

I've attached the version of SdFat bench I used. I modified it to use "SPI_FULL_SPEED" after my first run using the original SPI_HALF_SPEED setting produced poor results, but the results were virtually identical at each setting.

Any insights you might have into this would be deeply appreciated.

bench.zip

MEGA 2560 performance Use a freshly formatted SD for best performance.

Type any character to start FreeStack: 6711 Type is FAT32 Card size: 31.91 GB (GB = 1E9 bytes)

Manufacturer ID: 0X3 OEM ID: SD Product: SC32G Version: 8.0 Serial number: 0X111A0968 Manufacturing date: 2/2012

File size 5 MB Buffer size 512 bytes Starting write test, please wait.

write speed and latency speed,max,min,avg KB/Sec,usec,usec,usec 281.23,27624,1572,1813 284.88,95152,1540,1790

Starting read test, please wait.

read speed and latency speed,max,min,avg KB/Sec,usec,usec,usec 507.68,3108,988,1001 507.84,1992,988,1001

Metro M4 performance Use a freshly formatted SD for best performance.

Type any character to start FreeStack: 192112 Type is FAT32 Card size: 31.91 GB (GB = 1E9 bytes)

Manufacturer ID: 0X3 OEM ID: SD Product: SC32G Version: 8.0 Serial number: 0X111A0968 Manufacturing date: 2/2012

File size 5 MB Buffer size 512 bytes Starting write test, please wait.

write speed and latency speed,max,min,avg KB/Sec,usec,usec,usec 10.30,344156,49334,49677

Starting read test, please wait.

read speed and latency speed,max,min,avg KB/Sec,usec,usec,usec 10.69,95857,47883,47897 10.69,95857,47883,47897

Done

ladyada commented 6 years ago

are you using the QSPI flash??

SapientHetero commented 6 years ago

Both bench.ino and my software use the Arduino SPI library.

ladyada commented 6 years ago

this library is for QSPI flash, i think you want to open this issue here https://github.com/adafruit/ArduinoCore-samd