ZFS Optimal Array Size

So there I was looking at a pile of eight drives and an empty storage array, and wondering how to cofigure it for best performance under ZFS. “Everyone knows” the formula right? The best performance in a raidz array comes if you use 2^D+P drives. That’s to say your data drives should be a power of two (i.e. 2,4,8,16) plus however many redundant (parity) drives for the raidz level you desire. This is mentioned quite often in the Lucas book FreeBSD Mastery:ZFS; although it didn’t originate there I’ll call it the Lucas rule anyway

I have my own rule – redundancy should be two drives or 30%. Why? Well drives in an array have a really nasty habit of failing two at a time. It’s not sods law, it’s a real phenomenon caused by the stress of re-silvering shaking out any other drives that are “on the edge”. This means I go for configurations such as 4+2, 5+2, 6+2. From there on I go to raidz3 with 7+3, 8+3, 9+3. As there’s no raidz4, 12 drives is the limit – for 14 drives I’d have two vdevs (LUNs) of 5+2 each.

However, If you merge my rule with the Lucas rule the only valid sizes are 2+2 and 4+2 and 8+3. And I had just eight drives to play with.

I was curious – how was the Lucas rule derived? I dug out the book, and it doesn’t say. Anywhere. Having a highly developed suspicion of anything described as “best practice” I decided to test it on my rag-bag collection of drives in the Dell backplane, and guess what? No statistically significant difference.

Now the trouble with IT “best practice” guides is they’re written by technicians based on observation, not OS programmers who know how stuff actually works. The first approach has a lot of merit, but unless you know the reason for your observations you won’t know when the reason has become irrelevant. Unfortuantely, as an OS programmer, I now had a duty to figure out what this reason might have been.

After wading through the code and finding nothing much helpful, I did what I should have done first and considered the low-level disk layout. It’s actually quite simple.

Your stuff is written to disk in a series of blocks, right? In a striped array, each drive gets a block in turn to spread the load. No problem there. Well there will be a problem if your ZFS block size doesn’t match the block size on the drives, but that’s a complication I’m going to overlook – lets just assume you got that bit right.

So where does the optimal number of disks come from? I contend that on a striped vdev there never was one. The problem only comes when you add redundant drives.

I’m going to digress here to explain how error correcting data happens – in very simple terms. Suppose you have a sequence of numbers such as:

5 8 2 3

Each number is stored on a separate piece of paper, and to guard against loss you add a fifth number so that when you add them all up you get a total ending in zero. In this example, the total of the first 4 is 18. You can add an extra 2 to make the total 20, which ends in zero, so the fifth number is going to be 2.

5 8 2 3 2

Now, if we lose any one of those five numbers we can work out what it must have been – just work out which digit when added to the remaining four gives you a total ending in zero. For example, supposing ‘3’ when missing. Add up the remainder and you get 17. You need 3 more to get to a zero, so the missing number must be 3.

Digression over. ZFS calculates a block of error correction data for the blocks of data it’s just written and adds this as the last block in the sequence. If If ZFS blocks and sectors were the same size, this would be fine writing another sector is quick. But ZFS blocks no longer match sectors. In fact, they’re tunable over a wide range. We’ve also got 4k sectors instead of the traditional 512b. So, suppose you had 2k ZFS blocks on a 4k sector disk? Your parity data could end up being just half a sector, meaning that ZFS has to read it, overwrite half, and write it back rather than just writing it. This sucks. But if you choose the number of disks carefully, you end up with parity blocks that do fit. So, always make sure you follow Lucas’ rule, and make sure your data drives are a power of two.

Except…

This may have been true once, but now we have variable ZFS blocks sizes, and they tend to be much larger than the sector size anyway. In this situation the “magic” configurations no longer matter. And, now we have lz4 compression, the physical block sizes are variable anyway.

For those not in the know about this, lz4 compression is a no-brainer. It wont’ compress stuff it can’t, and its fast. Most files will compress to at least 2:1, often more – which means when you read a block only half the data needs to travel down the bus to get in memory. Everything suddenly goes twice as fast, at the expense of one core having to do some work. It’s true that the block and sector sizes are nowhere near matching, and this is bound to have a performance hit, but this is more-than eclipsed by the improved transfer rate.

So in summary, forget the 2^D+P “best practice” formula. It was only valid in the early days. Have whatever config you like, but I do commend my rule about the number of redundant drives. This is based on a hardware issue, and no update to the software is going to fix this any time soon.

Media in concerted racist christianphobic rant

I’ve just been listening to a DUP representative being given a hard time on Radio 4’s Today program over his religious views. How could May work with these bigots?

Actually, their views are taken direct from the Christian Bible, and somewhat watered down at that. Yet their religious convictions are considered fair game.

Compare and contrast the media treatment of politicians from other religions, which can basically be summarized as deferential respect.

So the Bible comes out strongly against abortion, homosexuality and a lot of stuff that modern society considers perfectly acceptable. The people are entitled to vote for representatives holding whatever views they like, and in Northern Ireland these views are mainstream. The Catholic church uses the same Bible, and Mohammedans have similar rules written down. The media says nothing to them.

Sadiq Khan, socialist mayor of London, happens to be a Muslim. This doesn’t appear to have bothered the people who elected him, but does seem of concern to some people. However, his religion-inspired views are unknown because they’re off-limits to the media. Personally, I doubt I’d have a problem with them although I find non-scientific views in general problematic. However, neither I nor his critics have ever even heard them. By not questioning everyone to the same standard the media leaves the public to draw conclusions that may be wholly unjustified.

But the BBC sees fit to attack representatives of one group and question their beliefs.

And spare a thought for poor Tim Farron, Christian leader of the Liberal Democrats. The media was obsessed with asking him if homosexuality was a sin. Of course it’s a sin; it says it’s a sin in the Bible. So are a lot of other things, like feeling jealous of someone. If you follow Christian teaching, everyone’s a sinner (baby), including homosexuals. So what? This line of questioning was very unfair indeed, as non-Christians would have a completely different understanding of the answer. And I’d hazard a guess that most Christians don’t understand their religion that well either.

Now I’m not against questioning religious beliefs. But it has to be ALL religious beliefs. If people wish to elect representatives who are also guided by a particular religion that’s their right; it’s how our democracy works. But unequal treatment of religions by the media cannot be allowed.

Why May did badly (and Corbyn did well)

There’s a lot of soul-searching going on as to why so many people voted for Crobyn’s Labour instead of Mrs “Strong and Stable” May

It’s not that hard, and neither was it unexpected outside the Westminster/Media echo chamber. And it wasn’t because May hacked off the elderly by appearing to raid their savings to pay for care that’s give to others for nothing, although it really didn’t help.

Neither was it because May is perceived boring in a superficial celebrity world.

It’s because Corbyn offered to give people free money and they believed him. People like free money.

There was an age-based split in the voting. A lot of young people, who haven’t lived through the false promise of socialism, have no reason to question the reality of what is being proposed. (And Blair’s government wasn’t socialist).

So, tell young people they’ll be let off paying university tuition fees and they’ll love you. Even better, refund fees already paid and even more people, and their parents, will love you.

Policies like nationalising the railways play well to anyone under the age of 50. If you’re older than this you’ll know just what a mess British Rail was and would never want a return to the bad old days (unless you’re a Rail Union).

But to young people, quick fixes and free money are always going to be a vote winner. As the population ages towards 2022 and more of those with long memories have dropped off their perch, the balance may well tip.

Labour, in order to be a credible opposition, needs to do something about this. Most Labour MP’s know the score, which is why they were so distraught when Corbyn became their leader. (At least I hope it was this rather than concern for their re-electability). If they can’t, the Conservatives need to learn how to fight fire with fire. And they need better leadership.

Higher Education doesn’t need more subsidy, it needs major reform; we’re failing or children by putting them through inappropriate degrees and charging them for it. The academic world is complicit as there are a lot of people making a good living at their expense, paid for by the young people who believe it’s the thing they need to do.

The UK has five years to get it’s politics in order or we’re all in trouble. I told you so.

Update:

You couldn’t make this up. Everyone in the country heard Labour say they’d scrap tuition fees and write off student loans. Now Corbyn is claiming he only said he’d “look at the problem”. ‘sfunny, but that’s not the impression he gave. Everyone from Twitter to those I met on the doorstep were really excited about the prospect of free money. Labour activists were repeating it ad-nauseum. Did the leadership do anything to prevent this lie from spreading? I don’t remember a word being said.

Trump 1, LePen 0, Corbyn ? How to succeed in politics with cynicism.

This is going to appear after the polls have closed in the general election, but before the results. The Conservatives have had a disastrous campaign, by assuming that if Corbyn was a fool then no one would vote for him. I’ve been saying for years that this is a really stupid assumption. I hope my predictions prove wrong.

In the meantime, watching the disaster that is Trump unfold, I’ve been really struck with the parallels he has with Corbyn.

  1. Both have privileged backgrounds, and have achieved their place in life following a leg-up.
  2. Both have cultivated an image that puts them outside the political establishment.
  3. Both speak plainly in words that a simpleton can understand.
  4. Both tell people what they want to hear.
  5. Both have no particular difficulty with telling lies.
  6. Both whip up hatred for the mob against particular sections of society likely to oppose them.
  7. Both are clearly not great thinkers.
  8. Both are hated by their MPs/Representatives so have nothing to temper their excess.
  9. Both were elected by party members, not MPs/Congressmen. They were the activist people’s choices.
  10. No one believed either could possibly get the nomination or get the top job, and they were regarded as a joke.

Following this simple formula, you can probably get enough people to vote for you – those who feel hard done by (especially if you keep on telling them they are). Trump told the workers that he was going to bring back jobs and build a wall. Corbyn told young people he was going to give them money from the magic tree. Trump blamed foreigners. Corbyn blamed rich people (a bit rich given his background),

As I said back in 2015, Corbyn could win in the right circumstances. This is if people are fed up. They voted for Ken Livingstone because they were fed up with the establishment and wanted to cause maximum annoyance. He made a career out of spouting rubbish, which added to his appeal.

The economy has done well under the Conservatives, seeing off the nightmare scenario. However, Theresa May is gaff prone.  She clearly has some silly ideas, one of which is that she’s in touch. Some people seem to like her; I’m not a fan.

Could the British public be as foolish as the Americans? The French voted for anyone but LePen; will Britain vote for anyone but Corbyn? Or will they blindly believe he can deliver these impossible promises because they really want to believe them, and put reason and arithmetic to one side.

I really hope I’ve been wrong all along.