Advanced Hard Drive Caching Techniques
Using a benchmarking utility, the numbers will vary. On read operations, it is wholly dependent on whether the desired data resides in cache or whether the module needs to retrieve it from the slower disk. On write operations, it depends on the Flash technology itself, and whether it needs to go through a typical programmable erase (PE) cycle to write the new data. Regardless of this, the random read/write access to the slower drive has been increased significantly:
Sequential read: 105MB/s
Sequential write: 50MB/s
Random read: 67MB/s
Random write: 51MB/s
You can continue monitoring the cache status by typing:
$ sudo dmsetup status cache 0 20971520 cache stats: reads(301319), writes(353216), ↪cache hits(24485, 0.3),replacement(345972), ↪replaced dirty blocks(92857)
To remove the cache mapping, unmount the drive and invoke dmsetup:
$ sudo umount /mnt/cache $ sudo dmsetup remove cache
FlashCache is a project developed and maintained by Facebook. It was inspired by dm-cache. Much like dm-cache, it too is built from the device-mapper framework. It currently is hosted on GitHub and can be cloned from there. The repository encompasses the kernel module and administration utilities. Once built and installed, load the kernel module and in a similar fashion to the previous examples, create a mapping of the SSD and HDD:
$ sudo modprobe flashcache $ sudo flashcache_create -p back -b 8 cache /dev/sdb /dev/sda3 cachedev cache, ssd_devname /dev/sdb, disk_devname /dev/sda3 ↪cache mode WRITE_BACK block_size 8, md_block_size 8, ↪cache_size 0 FlashCache metadata will use 223MB of your 3944MB main memory
The flashcache_create administration utility is similar to the dmc-setup.pl Perl script used for dm-cache. It is a wrapper utility designed to simplify the dmsetup process. As with the dm-cache module, once the mapping has been created, you can view mapping details by typing:
$ sudo dmsetup table cache 0 20971520 flashcache conf: ssd dev (/dev/sdb), disk dev (/dev/sda3) cache mode(WRITE_BACK) capacity(57018M), associativity(512), data block size(4K) ↪metadata block size(4096b) skip sequential thresh(0K) total blocks(14596608), cached blocks(83), cache percent(0) dirty blocks(0), dirty percent(0) nr_queued(0) Size Hist: 4096:83 $ sudo dmsetup status cache 0 20971520 flashcache stats: reads(83), writes(0) read hits(0), read hit percent(0) write hits(0) write hit percent(0) dirty write hits(0) dirty write hit percent(0) replacement(0), write replacement(0) write invalidates(0), read invalidates(0) pending enqueues(0), pending inval(0) metadata dirties(0), metadata cleans(0) metadata batch(0) metadata ssd writes(0) cleanings(0) fallow cleanings(0) no room(0) front merge(0) back merge(0) disk reads(83), disk writes(0) ssd reads(0) ssd writes(83) uncached reads(0), uncached writes(0), uncached IO requeue(0) disk read errors(0), disk write errors(0) ssd read errors(0) ↪ssd write errors(0) uncached sequential reads(0), uncached sequential writes(0) pid_adds(0), pid_dels(0), pid_drops(0) pid_expiry(0)
Mount the mapping for file accessibility:
$ sudo mount /dev/mapper/cache /mnt/cache
Using the same benchmarking utility, observe the differences between FlashCache and the previous module:
Sequential read: 284MB/s
Sequential write: 72MB/s
Random read: 284MB/s
Random write: 71MB/s
The numbers look more like the native SSD performance. However, I want to note that this article is not intended to prove that one solution performs better than the other, but instead to enlighten readers of the many methods you can use to accelerate data access to existing and slower configurations.
To unmount and remove the drive mapping, type the following in the terminal:
$ sudo umount /mnt/cache $ sudo dmsetup remove /dev/mapper/cache
Petros Koutoupis is a full-time Linux kernel, device-driver and application developer for embedded and server platforms. He has been working in the data storage industry for over a decade.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Chris Birchall's Re-Engineering Legacy Software (Manning Publications)
- The Italian Army Switches to LibreOffice
- Linux Mint 18
- ServersCheck's Thermal Imaging Camera Sensor
- Petros Koutoupis' RapidDisk
- Oracle vs. Google: Round 2
- The FBI and the Mozilla Foundation Lock Horns over Known Security Hole
- Privacy and the New Math
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide