Изменения

Ceph performance

1099 байтов убрано, 11:08, 24 апреля 2019
м
Нет описания правки
But that’s not the case with modern SSDs, they are very fast and last very long. Even cheap models are usually rather strong. But why? The credit goes to SSD controllers: SSDs contain very smart and powerful controllers, usually with at least 4 cores and 1-2 GHz clock frequency, which means they’re as powerful as mobile phones' processors. All that power is required to make FTL firmware run smoothly. FTL stands for «Flash Translation Layer» and it is the firmware responsible for translating addresses of small blocks into physical addresses on flash memory chips. Every write request is always put into the space freed in advance, and FTL just remembers the new physical location of the data. This makes writes very fast. FTL also defragments free space and moves blocks around to achieve uniform wear across all memory cells. This feature is called Wear Leveling. SSDs also usually have some extra physical space reserved to add even more endurance and to make wear leveling easier; this is called overprovisioning. Pricier server SSDs have a lot of space overprovisioned, for example, Micron 5100 Max has extra 60 % of the user capacity on top of it.
And this is also the FTL which makes power loss protection a problem. The mapping tables are the metadata which must also be forced into the non-volatile memory when you flush the cache, and it's it’s what makes desktop SSDs slow with fsync. As I wrote it I thought that they could use RocksDB or similar LSM-tree based system for storing mapping tables and that could make fsyncs fast even without the capacitors. It would lead to some waste of journal space, but still it would make writes fast. So… either they don’t know about LSM trees or the fsync problem is not caused only by the FTL metadata.
Дополнение: когда я попытался кого-то в списке рассылки полечить на тему, что «все SSD делают fsync», мне в ответ кинули статьюWhen I tried to lecture someone in the mailing list about «all SSDs doing fsyncs correctly» I got this as the reply: https://www.usenix.org/system/files/conference/fast13/fast13-final80.pdf. В общемLong story short, суть статьи в том, что в it says that in 2013 году нормой было то, что SSD вообще не сбрасывали метаданные на диск при a common scenario was SSDs not syncing metadata on fsynccalls at all which lead to all kinds of funny things on a power loss, и при отключении питания это приводило к разным весёлым вещам вплоть до up to (!!!) полного отказа SSDtotal failures of some SSDs.
Есть экземпляры старых SSD без конденсаторов There also exist some very old SSDs without capacitors (OCZ Vector/Vertex), которые при этом выдают большие which are capable of very large sync iops на запись с fsyncnumbers. Как это возможноHow do they work? НеизвестноNobody knows, но есть предположение, что суть как раз в небезопасности записиbut I suspect that they just don’t do safe writes :). Принцип работы флеш-памяти за последние годы вроде как не менялся — в SSD как раньше был FTLThe core principle of flash memory overwrites didn’t change in the last years, так и сейчас FTL. Как достигнуть быстрой записи, если постоянно сбрасывать на диск карты трансляции — хз… наверное, если только сделать некое подобие лог-структурированной ФС внутри — писать всё время вперемешку метаданные и данные. Но при этом, по идее, при старте всё это «добро» придётся сканировать и старт/монтирование станет долгим. А в SSD долгого монтирования вроде как нетand SSDs were also based on FTLs just as they do now.
Ну и, собственно, So it seems there are two kinds of «power loss protection»: simple PLP means «we do fsyncs and don’t die or lose your data when a power loss occurs», видимо, бывает простой, а бывает and advancedPLP means fsync’ed writes are just as fast as non-fsynced. Простой означает просто «мы корректно делаем fsync и не сдохнем при отключении питания», а advanced означает наличие конденсаторов и быструю безопасную запись с fsync. Сейчас, в It also seems that in the current years (2018—2019 годах, «обычный» ) simple PLP, похоже, всё-таки стал нормой и при отключении питания большая часть SSD терять данные и умирать уже не должнаis already a standard and most SSDs don’t lose data on power failure.
=== БонусA bonus: USB-флешки thumb drives ===
А почему тогда USB-флешки такие медленные? Случайная запись на флешку 512-байтными (или 4 Кб) блоками обычно идёт со скоростью 2-3 iops. А флеш-память там ровно та же, что в SSD — ну, может, более дешёвые вариации, но разница же не на порядки. Ответ кроется в том, что на флешках тоже есть FTL (и даже Wear Leveling), но по сравнению с SSD-шным он маленький и тупой. У него слабый процессор и мало памяти. Из-за малого объёма RAM контроллеру флешки, в отличие от контроллера SSD, негде хранить полную таблицу сопоставления виртуальных и реальных секторов — поэтому отображаются не сектора, а крупные блоки где-то по мегабайту или больше, а при записи есть лимит на количество «открытых» блоков. Как это происходит: