Archive for May 12, 2015

Tuesday, May 12, 2015 [Tweets] [Favorites]

Using Atomics to Get Rid of @synchronized

Bruno de Carvalho (tweet, comments):

This post talks about the use of OS low level atomic functions (compare-and-swap, fetch-and-increment) to achieve both wait and lock free, thread-safe concurrent algorithms in your iOS/OSX apps.

It introduces a few classes that abstract away the gory details of some of the atomic functions made available by libkern/OSAtomic.h into conceptually simpler components that use Foundation types.


While I’ve found plenty of use cases for atomic integers and booleans, references are something that I’ve rarely ever needed. I did come across one interesting usage for it recently.


If you’re looking to extract that extra bit of performance, instead of using AtomicInteger or AtomicBoolean go straight for std::atomic<> since objc_msgSend() — calling methods on classes — has a non-neglectable impact. Just make sure that when you do so, your code remains readable and self-explanatory.

BitTorrent Sync vs. Dropbox

Matt Henderson:

Dropbox costs me about $120 per year. To share data with my wife, without having to purchase a second subscription, required installing Dropbox on her Mac, but logged into my Dropbox account. Sharing data with my kids, however, would have required purchasing paid Dropbox accounts for them, as our shared “Family” data exceeds the Dropbox free account level.

For $40 per year, a single BTS license can be used on multiple computers. And if you can get by syncing up to 10 folders, it’s free!


BitTorrent Sync also supports selective sync, but dramatically improves on the Dropbox implementation by allowing you to continue to see the contents of excluded folders locally, and—here’s the killer feature—also allowing you to access that data on demand!

Storing SSDs Without Power

Jared Newman:

A new research presentation shows that solid state drives can lose data over time if they aren’t powered on, especially in warmer environments. A powered-off drive in 104 degrees Fahrenheit may start seeing data loss after a couple of weeks.

The information comes from Seagate’s Alvin Cox, who was part of a presentation to the Joint Electron Device Engineering Council (JEDEC). Though the presentation is a couple of months old, it was recently picked up by ZDNet, Slashdot and other sites.


The statements are actually completely accurate, but a bit misleading. First, this is about what JEDEC requires, not what actual SSDs deliver. Second, this is when SSDs are stored in idle at 55C.


That said, anybody conversant with SSD technology knows that SSDs are unsuitable for offline data storage as data obviously has potentially far shorter lifetimes than on magnetic disks, which in turn again have far shorter data lifetime than archival-grade tape. These is absolutely no surprise here for anybody that bothered to find out what the facts are. Of course, there are always those that expect every storage tech to keep data forever, and those dumb enough to have no or unverified backups and those often on media not suitable for long-term storage.

Mai Zheng et al. (PDF):

In this paper, we propose a new methodology to expose reliability issues in block devices under power faults. Our framework includes specially-designed hardware to inject power faults directly to devices, workloads to stress storage components, and techniques to detect various types of failures. Applying our testing framework, we test fifteen commodity SSDs from five different vendors using more than three thousand fault injection cycles in total. Our experimental results reveal that thirteen out of the fifteen tested SSD devices exhibit surprising failure behaviors under power faults, including bit corruption, shorn writes, unserializable writes, metadata corruption, and total device failure.

Update (2015-05-15): Kristian Vättö:

As always, there is a technical explanation to the data retention scaling. The conductivity of a semiconductor scales with temperature, which is bad news for NAND because when it’s unpowered the electrons are not supposed to move as that would change the charge of the cell. In other words, as the temperature increases, the electrons escape the floating gate faster that ultimately changes the voltage state of the cell and renders data unreadable (i.e. the drive no longer retains data).


All in all, there is absolutely zero reason to worry about SSD data retention in typical client environment. Remember that the figures presented here are for a drive that has already passed its endurance rating, so for new drives the data retention is considerably higher, typically over ten years for MLC NAND based SSDs. If you buy a drive today and stash it away, the drive itself will become totally obsolete quicker than it will lose its data. Besides, given the cost of SSDs, it’s not cost efficient to use them for cold storage anyway, so if you’re looking to archive data I would recommend going with hard drives for cost reasons alone.