Better SD write performance is probably a common goal. My project uses the Adafruit SD Micro SDIO breakout, the Adafruit OV5640 Camera breakout and the Unexpected Maker ESP32S3 feather in a compact stack (with a custom PCB to connect them) that fits in a GoPro waterproof case. I want GoPro-like video recording but with BLE time synchronization and start/stop functions with multiple cameras. It's like a GoPro but it's not, it's a NoPro!
I'm programming with the Arduino IDE and using the SD_MMC library. The ESP32S3 has an SDIO interface with programmable pins, which the library supports. But for the longest time, I could only get sustainable write speeds of 150-200 kilobytes per second. I'm using a Sandisk Extreme V30 32GB which should get 30MB/s. For the frame rates and resolution I want, I need about 3MB/s.
I initially played with the file system buffer size but never got consistent results. I might occasionally get a few frames written at target speeds but never a whole video. So I set my code aside and started from scratch to explore how to get better speed.
There definitely seemed to be a dependence on file buffer size as well as on the size of data being written. So I tried lots of combinations and got the same results - usually about 150-200 kB/s but occasionally over 3MB/s.
But I had noticed a pattern of good performance when the write lengths were certain powers of 2 so I tried multiples of 512 bytes and got much better speeds. With a file buffer size of 4096 and data sizes over 75kB I could get consistent speed over 3MB/s, just what I need. 4096 also gets consistent small writes at over 1MB/s. Buffer sizes of 8192 and greater actually worked worse.
I'm saving frames as JPEGs in an AVI file. I can pad extra bytes at the end of each JPEG to get to 512 byte multiples and always start a new frame on a 512 byte boundary. Problem solved!
After I did this experiment, I found a discussion at https://github.com/ZuluSCSI/ZuluSCSI-firmware/issues/269 which included the author of the SdFat library. He can get blazing fast writes on other microcontrollers (over 40MB/s in one case) but it seems to require tuning for each and I don't think he's done EPS32 yet.
The github discussion includes an interesting explanation of modern SD operation but I'm not sure why 4096 buffer size and 512-padded writes works better. Modern SD cards have much bigger block sizes. I would expect the library to hide these details and, some day, it might. For now, I'm happy.