SD card logging performance on Cube Orange

Hello,

I am using a Cubepilot Cubeorange flight controller and after enabling some more data to be logged with SDLOG_PROFILE in get lots of dropouts in my logfile.

When running the microSD card benchmark with sd_bench -r 50 I see a pattern of big hickups in the logging, probably where the dropouts come from (Run 4 and 10).

INFO  [sd_bench]   Run  0:   319.93 KB/s, max write time: 185 ms (=  21.62 KB/s), fsync: 6 ms
INFO  [sd_bench]   Run  1:   319.47 KB/s, max write time: 157 ms (=  25.48 KB/s), fsync: 6 ms
INFO  [sd_bench]   Run  2:   330.34 KB/s, max write time: 129 ms (=  31.01 KB/s), fsync: 6 ms
INFO  [sd_bench]   Run  3:   307.30 KB/s, max write time: 204 ms (=  19.61 KB/s), fsync: 12 ms
INFO  [sd_bench]   Run  4:   138.95 KB/s, max write time: 1625 ms (=   2.46 KB/s), fsync: 85 ms
INFO  [sd_bench]   Run  5:   337.34 KB/s, max write time: 88 ms (=  45.45 KB/s), fsync: 6 ms
INFO  [sd_bench]   Run  6:   356.05 KB/s, max write time: 37 ms (= 108.11 KB/s), fsync: 6 ms
INFO  [sd_bench]   Run  7:   342.80 KB/s, max write time: 36 ms (= 111.11 KB/s), fsync: 6 ms
INFO  [sd_bench]   Run  8:   345.92 KB/s, max write time: 29 ms (= 137.93 KB/s), fsync: 6 ms
INFO  [sd_bench]   Run  9:   350.31 KB/s, max write time: 27 ms (= 148.15 KB/s), fsync: 7 ms
INFO  [sd_bench]   Run 10:   170.73 KB/s, max write time: 1011 ms (=   3.96 KB/s), fsync: 95 ms

Therefore we decided to get a new, better microSD card and after looking at this github benchmark collection and the official PX4 docs we bought a SanDisk Extreme U3 card from Amazon expecting better results. However, the overall speed was much slower than the previous default card (SanDisk EDGE 16GB microSDHC I Class 4).

INFO  [sd_bench]   Run  0:   108.86 KB/s, max write time: 86 ms (=  46.51 KB/s), fsync: 55 ms
INFO  [sd_bench]   Run  1:   115.36 KB/s, max write time: 68 ms (=  58.82 KB/s), fsync: 21 ms
INFO  [sd_bench]   Run  2:   114.26 KB/s, max write time: 67 ms (=  59.70 KB/s), fsync: 53 ms
INFO  [sd_bench]   Run  3:   114.75 KB/s, max write time: 83 ms (=  48.19 KB/s), fsync: 14 ms
INFO  [sd_bench]   Run  4:   114.90 KB/s, max write time: 62 ms (=  64.52 KB/s), fsync: 16 ms
INFO  [sd_bench]   Run  5:   113.43 KB/s, max write time: 83 ms (=  48.19 KB/s), fsync: 40 ms
INFO  [sd_bench]   Run  6:   117.41 KB/s, max write time: 68 ms (=  58.82 KB/s), fsync: 17 ms
INFO  [sd_bench]   Run  7:   112.85 KB/s, max write time: 83 ms (=  48.19 KB/s), fsync: 11 ms
INFO  [sd_bench]   Run  8:   114.45 KB/s, max write time: 77 ms (=  51.95 KB/s), fsync: 17 ms
INFO  [sd_bench]   Run  9:   117.69 KB/s, max write time: 69 ms (=  57.97 KB/s), fsync: 11 ms
INFO  [sd_bench]   Run 10:   114.27 KB/s, max write time: 71 ms (=  56.34 KB/s), fsync: 36 ms

Even though the logging is much more consistent, the overall speed is much worse and not comparable to others using the same/similar microSD card.

After i commented my speeds on GitHub i was recommended to check if SDMMC1 or SDMMC2 is used. The only information I found about that was a discussion point at a Dev Call, but I don’t know what the result/talking point was exactly. How/where can I find more information about this?

Overall I expected the new microSD card to outperform the old, default Cubeorange card, but it does not seem the case. Is there anything I am doing wrong? How can I further test why my speeds are so much slower?

Hi, I just tried to run the logging command with our CubeOrange and a SanDisk Extreme U3 SD card, (therefore the same setup you used) and our results are much much better:

nsh> sd_bench -r 50
INFO  [sd_bench] Using block size = 4096 bytes, sync=0
INFO  [sd_bench] 
INFO  [sd_bench] Testing Sequential Write Speed...
INFO  [sd_bench]   Run  0:   283.09 KB/s, max write time: 75 ms (=  53.33 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run  1:   534.06 KB/s, max write time: 14 ms (= 285.71 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run  2:   540.80 KB/s, max write time: 15 ms (= 266.67 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run  3:   543.61 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 6 ms
INFO  [sd_bench]   Run  4:   462.98 KB/s, max write time: 61 ms (=  65.57 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run  5:   433.60 KB/s, max write time: 69 ms (=  57.97 KB/s), fsync: 37 ms
INFO  [sd_bench]   Run  6:   368.30 KB/s, max write time: 77 ms (=  51.95 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run  7:   536.63 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 6 ms
INFO  [sd_bench]   Run  8:   541.97 KB/s, max write time: 12 ms (= 333.33 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run  9:   542.24 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 6 ms
INFO  [sd_bench]   Run 10:   541.38 KB/s, max write time: 16 ms (= 250.00 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run 11:   539.74 KB/s, max write time: 14 ms (= 285.71 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 12:   538.69 KB/s, max write time: 14 ms (= 285.71 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 13:   540.95 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 14:   539.94 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 15:   540.26 KB/s, max write time: 14 ms (= 285.71 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run 16:   538.63 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run 17:   540.64 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 6 ms
INFO  [sd_bench]   Run 18:   539.44 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 19:   539.75 KB/s, max write time: 16 ms (= 250.00 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 20:   542.31 KB/s, max write time: 15 ms (= 266.67 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 21:   529.98 KB/s, max write time: 34 ms (= 117.65 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run 22:   541.73 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run 23:   542.88 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 9 ms
INFO  [sd_bench]   Run 24:   542.84 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 25:   536.41 KB/s, max write time: 12 ms (= 333.33 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run 26:   534.05 KB/s, max write time: 16 ms (= 250.00 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 27:   540.09 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run 28:   537.97 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 29:   537.97 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 30:   538.11 KB/s, max write time: 14 ms (= 285.71 KB/s), fsync: 6 ms
INFO  [sd_bench]   Run 31:   539.14 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 6 ms
INFO  [sd_bench]   Run 32:   539.01 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run 33:   540.35 KB/s, max write time: 12 ms (= 333.33 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 34:   540.04 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 35:   540.60 KB/s, max write time: 14 ms (= 285.71 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run 36:   530.37 KB/s, max write time: 30 ms (= 133.33 KB/s), fsync: 7 ms
INFO  [sd_bench]   Run 37:   537.91 KB/s, max write time: 15 ms (= 266.67 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 38:   540.80 KB/s, max write time: 16 ms (= 250.00 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 39:   541.15 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run 40:   535.51 KB/s, max write time: 15 ms (= 266.67 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 41:   545.00 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run 42:   539.04 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 8 ms
INFO  [sd_bench]   Run 43:   541.27 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 8 ms
INFO  [sd_bench]   Run 44:   543.16 KB/s, max write time: 14 ms (= 285.71 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 45:   541.15 KB/s, max write time: 13 ms (= 307.69 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run 46:   538.21 KB/s, max write time: 16 ms (= 250.00 KB/s), fsync: 4 ms
INFO  [sd_bench]   Run 47:   537.39 KB/s, max write time: 14 ms (= 285.71 KB/s), fsync: 7 ms
INFO  [sd_bench]   Run 48:   543.27 KB/s, max write time: 14 ms (= 285.71 KB/s), fsync: 5 ms
INFO  [sd_bench]   Run 49:   541.70 KB/s, max write time: 14 ms (= 285.71 KB/s), fsync: 4 ms
INFO  [sd_bench]   Avg   :   527.30 KB/s

As you can see, the writing rate and the delay are much more of what you would expect! Perhaps your SD card is just faulty? Anyways I also ordered another SD Card, we will see how that one performs.