Замечено что с разными картами разная скорость, например у меня аномально максимальную скорость показывала не sd а mmc карточка. Кстати Transcen SD (не SDHC) у меня рабоатают всех медленней.
У меня всех быстрей работала Kingston mmcm512 dual voltage - это rs-mmc вроде. Причем она подыхала, я думал ей конец, не читалась ни одним ридером, я потом ее проверил через какое-то время (месяц или два) и она чудесным образом ожила и работает до сих пор :) Но это все из личных наблюдений - нет никакой гарантии что у вас будет тоже самое...надо бы статистику собирать на этих платах :)
попробовал Kingston 2Gb (кажется true SD) - тот же результат.
до SDHC еще не дошел - картридер ранее пожег, форматнуть в ext2 нечем.
попробовал подмонтировать в асинхронном режиме и - о чудо!- скорость "волшебным образом" возросла в 10-20 раз!
правда каждые несколько мегабайт происходят тормоза на несколько секунд, но это еще не самое главное! попутно заметил одну вещь - если файл открыть и писать блоками (в моем случае по 660kB) через fwrite , то почему-то выжирается память, причем это получается и при синхронном монтировании (что самое странное!)!
причем выжрав всю память программа и дальше работает как ни в чем не бывало. Подчеркиваю - это не мой глюк: стоит только убрать fwrite как память нисколько не расходуется. вот вывод программы:
total RAM: 60.6 Mb
free RAM: 2.2 Mb
process: 21
write this data for a 54ms) free RAM: 50/60 Mb recs: 0 Mb
write this data for a 55ms) free RAM: 50/60 Mb recs: 1 Mb
write this data for a 54ms) free RAM: 49/60 Mb recs: 1 Mb
write this data for a 53ms) free RAM: 48/60 Mb recs: 2 Mb
write this data for a 70ms) free RAM: 48/60 Mb recs: 3 Mb
write this data for a 53ms) free RAM: 47/60 Mb recs: 3 Mb
write this data for a 93ms) free RAM: 47/60 Mb recs: 4 Mb
write this data for a 88ms) free RAM: 46/60 Mb recs: 5 Mb
write this data for a 94ms) free RAM: 45/60 Mb recs: 5 Mb
write this data for a 159ms) free RAM: 45/60 Mb recs: 6 Mb
write this data for a 95ms) free RAM: 44/60 Mb recs: 6 Mb
write this data for a 94ms) free RAM: 43/60 Mb recs: 7 Mb
write this data for a 106ms) free RAM: 43/60 Mb recs: 8 Mb
write this data for a 5360ms) free RAM: 42/60 Mb recs: 8 Mb
write this data for a 96ms) free RAM: 41/60 Mb recs: 9 Mb
write this data for a 60ms) free RAM: 41/60 Mb recs: 10 Mb
write this data for a 110ms) free RAM: 40/60 Mb recs: 10 Mb
write this data for a 99ms) free RAM: 40/60 Mb recs: 11 Mb
write this data for a 89ms) free RAM: 39/60 Mb recs: 11 Mb
write this data for a 107ms) free RAM: 38/60 Mb recs: 12 Mb
write this data for a 98ms) free RAM: 38/60 Mb recs: 13 Mb
write this data for a 55ms) free RAM: 37/60 Mb recs: 13 Mb
write this data for a 100ms) free RAM: 36/60 Mb recs: 14 Mb
write this data for a 5493ms) free RAM: 36/60 Mb recs: 15 Mb
write this data for a 104ms) free RAM: 35/60 Mb recs: 15 Mb
write this data for a 62ms) free RAM: 34/60 Mb recs: 16 Mb
write this data for a 103ms) free RAM: 34/60 Mb recs: 16 Mb
write this data for a 82ms) free RAM: 33/60 Mb recs: 17 Mb
write this data for a 106ms) free RAM: 33/60 Mb recs: 18 Mb
write this data for a 5764ms) free RAM: 32/60 Mb recs: 18 Mb
write this data for a 93ms) free RAM: 31/60 Mb recs: 19 Mb
write this data for a 56ms) free RAM: 31/60 Mb recs: 20 Mb
write this data for a 87ms) free RAM: 30/60 Mb recs: 20 Mb
write this data for a 141ms) free RAM: 29/60 Mb recs: 21 Mb
write this data for a 95ms) free RAM: 29/60 Mb recs: 22 Mb
write this data for a 5714ms) free RAM: 28/60 Mb recs: 22 Mb
write this data for a 85ms) free RAM: 27/60 Mb recs: 23 Mb
write this data for a 143ms) free RAM: 27/60 Mb recs: 23 Mb
write this data for a 75ms) free RAM: 26/60 Mb recs: 24 Mb
write this data for a 96ms) free RAM: 26/60 Mb recs: 25 Mb
write this data for a 99ms) free RAM: 25/60 Mb recs: 25 Mb
write this data for a 113ms) free RAM: 24/60 Mb recs: 26 Mb
write this data for a 100ms) free RAM: 24/60 Mb recs: 27 Mb
write this data for a 97ms) free RAM: 23/60 Mb recs: 27 Mb
write this data for a 86ms) free RAM: 22/60 Mb recs: 28 Mb
write this data for a 5618ms) free RAM: 22/60 Mb recs: 28 Mb
write this data for a 94ms) free RAM: 21/60 Mb recs: 29 Mb
write this data for a 55ms) free RAM: 20/60 Mb recs: 30 Mb
write this data for a 98ms) free RAM: 20/60 Mb recs: 30 Mb
write this data for a 161ms) free RAM: 19/60 Mb recs: 31 Mb
write this data for a 106ms) free RAM: 18/60 Mb recs: 32 Mb
write this data for a 6121ms) free RAM: 18/60 Mb recs: 32 Mb
write this data for a 92ms) free RAM: 17/60 Mb recs: 33 Mb
write this data for a 87ms) free RAM: 17/60 Mb recs: 33 Mb
write this data for a 140ms) free RAM: 16/60 Mb recs: 34 Mb
write this data for a 76ms) free RAM: 15/60 Mb recs: 35 Mb
write this data for a 100ms) free RAM: 15/60 Mb recs: 35 Mb
write this data for a 92ms) free RAM: 14/60 Mb recs: 36 Mb
write this data for a 101ms) free RAM: 13/60 Mb recs: 37 Mb
write this data for a 97ms) free RAM: 13/60 Mb recs: 37 Mb
write this data for a 5610ms) free RAM: 12/60 Mb recs: 38 Mb
write this data for a 100ms) free RAM: 11/60 Mb recs: 39 Mb
write this data for a 78ms) free RAM: 11/60 Mb recs: 39 Mb
write this data for a 99ms) free RAM: 10/60 Mb recs: 40 Mb
write this data for a 63ms) free RAM: 10/60 Mb recs: 40 Mb
write this data for a 103ms) free RAM: 9/60 Mb recs: 41 Mb
write this data for a 146ms) free RAM: 8/60 Mb recs: 42 Mb
write this data for a 98ms) free RAM: 8/60 Mb recs: 42 Mb
write this data for a 103ms) free RAM: 7/60 Mb recs: 43 Mb
write this data for a 103ms) free RAM: 6/60 Mb recs: 44 Mb
write this data for a 5396ms) free RAM: 6/60 Mb recs: 44 Mb
write this data for a 57ms) free RAM: 5/60 Mb recs: 45 Mb
write this data for a 101ms) free RAM: 4/60 Mb recs: 45 Mb
write this data for a 100ms) free RAM: 4/60 Mb recs: 46 Mb
write this data for a 101ms) free RAM: 3/60 Mb recs: 47 Mb
write this data for a 113ms) free RAM: 2/60 Mb recs: 47 Mb
write this data for a 5422ms) free RAM: 2/60 Mb recs: 48 Mb
write this data for a 98ms) free RAM: 1/60 Mb recs: 49 Mb
write this data for a 58ms) free RAM: 1/60 Mb recs: 49 Mb
write this data for a 74ms) free RAM: 3/60 Mb recs: 50 Mb
write this data for a 98ms) free RAM: 2/60 Mb recs: 50 Mb
write this data for a 100ms) free RAM: 1/60 Mb recs: 51 Mb
write this data for a 70ms) free RAM: 1/60 Mb recs: 52 Mb
write this data for a 106ms) free RAM: 1/60 Mb recs: 52 Mb
write this data for a 62ms) free RAM: 1/60 Mb recs: 53 Mb
write this data for a 5739ms) free RAM: 1/60 Mb recs: 54 Mb
write this data for a 100ms) free RAM: 1/60 Mb recs: 54 Mb
write this data for a 109ms) free RAM: 1/60 Mb recs: 55 Mb
write this data for a 793ms) free RAM: 1/60 Mb recs: 56 Mb
write this data for a 119ms) free RAM: 1/60 Mb recs: 56 Mb
write this data for a 107ms) free RAM: 1/60 Mb recs: 57 Mb
write this data for a 89ms) free RAM: 1/60 Mb recs: 57 Mb
write this data for a 158ms) free RAM: 1/60 Mb recs: 58 Mb
write this data for a 59ms) free RAM: 1/60 Mb recs: 59 Mb
write this data for a 104ms) free RAM: 1/60 Mb recs: 59 Mb
write this data for a 5617ms) free RAM: 1/60 Mb recs: 60 Mb
write this data for a 103ms) free RAM: 1/60 Mb recs: 61 Mb
write this data for a 61ms) free RAM: 1/60 Mb recs: 61 Mb
write this data for a 71ms) free RAM: 1/60 Mb recs: 62 Mb
write this data for a 61ms) free RAM: 1/60 Mb recs: 62 Mb
write this data for a 105ms) free RAM: 1/60 Mb recs: 63 Mb
write this data for a 5654ms) free RAM: 1/60 Mb recs: 64 Mb
write this data for a 148ms) free RAM: 1/60 Mb recs: 64 Mb
write this data for a 62ms) free RAM: 1/60 Mb recs: 65 Mb
write this data for a 88ms) free RAM: 1/60 Mb recs: 66 Mb
write this data for a 108ms) free RAM: 1/60 Mb recs: 66 Mb
write this data for a 59ms) free RAM: 1/60 Mb recs: 67 Mb
...
и это еще не все!!
если вести запись по другому- открыть файл, записать блок и закрыть файл, то исчезает эффект периодического "тормоза" и выжирания ОЗУ:
total RAM: 60.6 Mb
free RAM: 51.7 Mb
process: 21
write this data for a 62ms) free RAM: 51/60 Mb recs: 0 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 1 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 1 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 2 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 3 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 3 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 4 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 5 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 5 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 6 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 6 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 7 Mb
write this data for a 1088ms) free RAM: 51/60 Mb recs: 8 Mb
write this data for a 108ms) free RAM: 51/60 Mb recs: 8 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 9 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 10 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 10 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 11 Mb
write this data for a 110ms) free RAM: 51/60 Mb recs: 11 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 12 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 13 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 13 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 14 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 15 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 15 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 16 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 16 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 17 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 18 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 18 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 19 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 20 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 20 Mb
write this data for a 108ms) free RAM: 51/60 Mb recs: 21 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 22 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 22 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 23 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 23 Mb
write this data for a 110ms) free RAM: 51/60 Mb recs: 24 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 25 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 25 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 26 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 27 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 27 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 28 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 28 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 29 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 30 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 30 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 31 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 32 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 32 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 33 Mb
write this data for a 108ms) free RAM: 51/60 Mb recs: 33 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 34 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 35 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 35 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 36 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 37 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 37 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 38 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 39 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 39 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 40 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 40 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 41 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 42 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 42 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 43 Mb
write this data for a 870ms) free RAM: 51/60 Mb recs: 44 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 44 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 45 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 45 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 46 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 47 Mb
write this data for a 108ms) free RAM: 51/60 Mb recs: 47 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 48 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 49 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 49 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 50 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 50 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 51 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 52 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 52 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 53 Mb
write this data for a 108ms) free RAM: 51/60 Mb recs: 54 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 54 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 55 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 56 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 56 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 57 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 57 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 58 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 59 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 59 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 60 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 61 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 61 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 62 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 62 Mb
write this data for a 110ms) free RAM: 51/60 Mb recs: 63 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 64 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 64 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 65 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 66 Mb
write this data for a 108ms) free RAM: 51/60 Mb recs: 66 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 67 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 67 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 68 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 69 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 69 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 70 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 71 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 71 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 72 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 73 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 73 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 74 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 74 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 75 Mb
write this data for a 109ms) free RAM: 51/60 Mb recs: 76 Mb
write this data for a 61ms) free RAM: 51/60 Mb recs: 76 Mb
...
завтра еще попробую форматнуть карту в ФС yaffs - так форматирована встроенная NAND (и это правильно, ибо эта ФС как раз для флешек), ибо сдается мне, что резвость NAND обеспечена использованием именно yaffs, несмотря на то что она смонтирована с sync
Тут нет ничего сверхестественного :) это нормальное поведение системы - в linux ram используется до предела, сколько ее есть под буферы и кеши и это не влияет на нормальную работу системы. Все операции чтения/записи буферизуются (кроме случая когда устройство смонтировано с опцией -o sync). Насчет fflush смотрим man fflush
Note that __fflush() only flushes the user space buffers__ provided by the C library. To
ensure that the data is physically stored on disk the kernel buffers must be flushed too,
for example, with sync(2) or fsync(2).
попробовал подмонтировать в асинхронном режиме и - о чудо!- скорость "волшебным образом" возросла в 10-20 раз!
это особенность работы флэшпамяти - можно писать блоками или страницами, блоками в несколько раз быстрей потому что пишется сразу большой кусок а время на запись такое же как при записи одной страницы и используется как раз при использовании буферов, данные сначала записываются в буфер а потом большими блоками закидываются в устройство. При синхронной записи пишется постранично без буферизации.
Тут нет ничего сверхестественного :) это нормальное поведение системы - в linux ram используется до предела, сколько ее есть под буферы и кеши и это не влияет на нормальную работу системы. Все операции чтения/записи буферизуются (кроме случая когда устройство смонтировано с опцией -o sync).
я забыл написать, что при монтировании с sync - память так же выжирается! вот что странно!
не успел провести аналогичный опыт с встроенной NAND - интересно yaffs также будет себя вести, или нет.
попробовал подмонтировать в асинхронном режиме и - о чудо!- скорость "волшебным образом" возросла в 10-20 раз!
это особенность работы флэшпамяти - можно писать блоками или страницами, блоками в несколько раз быстрей потому что пишется сразу большой кусок а время на запись такое же как при записи одной страницы и используется как раз при использовании буферов, данные сначала записываются в буфер а потом большими блоками закидываются в устройство. При синхронной записи пишется постранично без буферизации.
я бы сказал то это особенность _любого_ носителя, и _такая_ разница в скорости была бы понятна при сравнении записи множества маленьких кусочков или одного большого.
но дело в том, что я писал блоками в обоих случаях. и во втором случае, когда файл каждый раз перед записью блока открывается, а потом закрывается - операций делается больше, поэтому ожидалось что скорость будет ниже, а на практике получаем "тормоза" в первом случае (когда файл открыли в начале программы и закрыли в конце).
и очевидно что это влияние кэша- при закрытии файла кэш очищается.
Много слов, я так и непонял в чем проблема. Повторюсь что это нормальное поведение системы. fwrite - потоковая запись, кроме сисетмных буферов существуют еще буферы userspace которые ничего не знают о том с какой опцией смонтировано устройство на которое происходит запись. Непонятно как вы определяете то что память занята
write this data for a 62ms) free RAM: 51/60 Mb recs: 0 Mb
смотрите выхлоп free, он явно показывает сколько занято а сколько свободно. То что занято буферами/кешами для системы считается свободной памятью.
bash-4.0$ free
total used free shared buffers cached
Mem: 903268 238092 665176 0 20416 108432
>>>-/+ buffers/cache: 109244 794024<<<
какая из них выполнится быстрее? казалось бы - первая? ан нет - вторая!
В первом случае тебе нужно реально записать огромный файл, во втором с учетом буферизации это будет однократная запись файла длиной в 100! раз меньше чем в первом. В чем тут неожиданное поведение ? Еще раз повторяю - fwrite это потоковая _буферизованная_ на уровне библиотеки libc запись, даже если устройство смонтировано sync буферизация все равно будет на уровне userspace. Для низкоуровневого ввода/вывода существуют ф-ции read/write
ЗЫ оптимизатору компилятора кстати никто не помешает увидеть во втором случае что буфер константный и он тогда вообще цикл выкинет и оставит однократную запись.
какая из них выполнится быстрее? казалось бы - первая? ан нет - вторая!
В первом случае тебе нужно реально записать огромный файл, во втором с учетом буферизации это будет однократная запись файла длиной в 100! раз меньше чем в первом.
файл открывается на добавление - объем записываемых данных там и там одинаков.
с точки зрения кэша/буфера- да, в первом случае ему пихают сто кусков подряд, во втором "по-отдельности". но тем не менее причина "тормозов" в первом случае мне не понятна.
ЗЫ оптимизатору компилятора кстати никто не помешает увидеть во втором случае что буфер константный и он тогда вообще цикл выкинет и оставит однократную запись.
ну это никогда. компилятор не знает что fwrite делает с буфером, поэтому цикл выкидывать не имеет права.