Search Results: "John Goerzen"

6 March 2007

John Goerzen: Re-Examining Darcs & Mercurial

I recently wrote an article or two about distributed version control systems.

I've been using Darcs since 2005. I switched to Darcs, in fact, 10 days after the simultaneous founding announcements of git and Mercurial.

Overall, I have been happy. I continue to believe that it is the most distributed of the distributed VCSs, which is a Good Thing.

However, I have lately started having trouble with Darcs hanging while working on my Debian packages. My post to the Darcs user list drew out a few other people whith this problem, which is a design flaw of Darcs.

So I revisited the VCS landscape. I re-examined git, Mercurial, and bzr. I eventually decided to give Mercurial a try. I avoided git because I write some code that is portable to Windows, and git isn't (or isn't very well). Also, git is complex to pick up for me, and I certainly don't want to force something complex onto my contributors. bzr seemed to still have some strange behaviors that it's had for awhile, and I couldn't find even one advantage of it over Mercurial. So off I went with Mercurial.

I quickly learned a bit of a philosophical difference from Darcs to Mercurial.

Darcs avoids conflicts at all costs. Mercurial makes handling conflict easy and, in many cases, automatic.

It is exactly this Darcs behavior that permits both is excellent "darcs send" feature (still unmatched in any other VCS), but also causes its hang problems.

I found Mercurial quite pleasant to work with, and *fast*. It seems to be edging out git in speed tests sometimes these days.

It is easy to get started with Mercurial. The mq system -- similar to quilt or other patch-management programs -- is really quite an amazing hybrid between patch management and version control. I frankly don't see any need for other patch-management tools anymore.

Mercurial has a "patchbomb" feature where you can select a range of changesets to send off, and it will generate nice emails with one changeset per email, and send them to your selected destination, optionally with an introductory message. The normal way of interacting with other Mercurial users is via the hg export/import commands, which send around simple unified diffs plus some additional header information, optionally in the git extended diff format.

I am happy with Mercurial and am in the process of converting my Debian repositories from Darcs to Mercurial. I'm going to keep my personal code in Darcs for the moment because "darcs send" is still easier than "hg email", but that may change before long, depending on how my experience goes.

I'd encourage others to give Mercurial a try. The community is also very nice and helpful.

I have contributed patches to Tailor to make it make exact copies of Darcs repos into Mercurial, which are now in its Darcs repo. There is also a thread on the Mercurial list with some of my initial questions/concerns coming from a Darcs perspective.

3 March 2007

John Goerzen: A better environment for shell scripting

Shell scripts are good for a lot of things. It's quick and easy to design shell scripts that take input from one program, pass it to another program, munge it for filenames, etc.

But there are a few drawbacks to shell scripts.

The #1 drawback, in my opinion, is that it is extremely difficult to get quoting and escaping right. I often see things like $@ in shell scripts (breaks if a parameter has a space in it). I also see people failing to check for errors properly (set -e helps that). It's also difficult to do a more modern style of exception handling (do a sequence of actions in a temporary directory, and always remove that directory, even if there's an error, but stop processing and propogate the error). Command-line parsing is esoteric and odd, even with getopt. That's not to say that it's impossible to make a secure shell script that handles filenames with spaces in them properly. Just that it's difficult, and makes using common operators like backticks difficult.

Awhile back, I toyed with the idea of making Haskell a shell scripting language. This week, I spent some time to make this a reality. I released HSH, a shell scripting environment for Haskell.

HSH makes it easy to run shell commands, set up pipelines, etc. straight from Haskell. You can either use simple strings to invoke commands (they'll be passed to sh -c), or you can specify arguments as a list (like exec...() takes), which eliminates the strange filename problems.

But the really cool thing is that HSH doesn't just let you pipe from one external program to another. It also lets you pipe to/from pure Haskell functions. Yes, you can pipe the output of ls -l straight into a Haskell version of grep. I've found it to be very nice, especially for more complex processing tasks.

I put these simple examples on the HSH homepage:

run $ "echo /etc/pass*" :: IO String
 -> "/etc/passwd /etc/passwd-"
runIO $ "ls -l" - - "wc -l" 
 -> 12
runIO $ "ls -l" - - wcL
 -> 12
In this example, wcL is a pure-Haskell line-counting function.


The results were surprising. According to SLOCCount, porting hg-buildpackage from a shell script to a HSH script achieved a 20% reduction in source lines of code. And at the same time, gained better error handling, better safety of filenames, better type safety (compile-time type checking), etc. Yet it does exactly the same thing in almost exactly the same way.

Even greater savings will occur too. I decided to reimplement a small part of sed just for fun, and that code is still in my tree. If I removed that and replaced it with a call to sed as in the shell version, that would probably buy another 5% savings.

I didn't really expect to achieve a reduction in lines of code. I thought that I'd be lucky to come close to breaking even. After all, who'd expect something other than the shell to be better at shell scripting?

I don't know if these results are generalizable, but I'm really excited about it.

24 February 2007

John Goerzen: Rebase Considered Harmful

Today I was musing about different version control systems and merge algorithms. I've been thinking specifically about how I maintain Debian packages in Darcs. I tend to import upstream tarballs into one branch, and maintain the Debian packages in another, simply merging when a new upstream is released.

Now, there seem to be two prevailing philosophies on how to handle merges in this case. I'm thinking here about merges back to upstream. Say I want to contribute my Debian patches to them.

  1. Commit "clean" patches upstream. Don't have a bunch of history -- the fixing typos commits, the fixing bugs commits, or the merging to track new upstream releases. Just something like a series of diffs against the current head.
  2. Bring across the full history, warts and all, and keep it around permanently.


git encourages option #1, with its rebase option. Darcs encourages option #2 (though some use its amend-record option to work more like #1).

As I got to thinking about it, it occured to me that git-rebase would be very nice if you are going to use philosophy #1. In short, rebase will remove your local patches from a repo, update it to the latest upstream, then re-apply your local changesets -- aborting to have you fix any conflicts. This is as opposed to a more traditional merge, where you add the upstream changesets to your local branch and then commit new changesets to resolve conflicts. (So a rebase would be totally useless in situation #2)

I got to thinking about this, and started wondering what would happen to people that I'm working with that in turn work off my branches. And sure enough, the git-rebase manpage says, "When you rebase a branch, you are changing its history in a way that will cause problems for anyone who already has a copy of the branch in their repository and tries to pull updates from you."

I maintain, therefore, that git-rebase is evil and should be avoided. It only works for a situation where someone maintains a private branch of a project, never shared in any way except to submit patches to an upstream. Forget it if you have a team maintaining that branch, or want to post that branch online for others to help with (as I do with my Debian darcs package). Even if you keep it private now, do you really want to adopt a work process that forces you to keep it private forever, or else completely change how you work?

And this brings me back to the original question of patch philosophy. Personally, I dislike philosophy #1. I'd much rather have the full history of a change, warts and all. Look at the Linux kernel example: changesets that introduced bugs that made it into the official tree have their fixes documented, but changesets that introduced bugs that were fixed before being merged into the official tree could be lost to the public due to rebasing by submitters. Is that really what we want? I don't think so.

With Darcs, tagging is very cheap and it is quite trivial to write an "apply a changeset bundle" script that makes a before tag, applies a series of patches, and makes an after tag. One could then run a darcs diff between the two tags to see the net effect on the repository, or could still look at the individual patches. (Or, you can avoid tagging and manually specify the "from" and "to" patches.) I find that a much better model: you can have it both ways. I'd think that most modern VCSs ought to support some variant on that, too.

And I think that git-rebase should be removed on the grounds that it encourages poor version tracking practices.

8 February 2007

John Goerzen: Haskell Time Travel

There is something very cool about a language in which the easiest, most direct way to explain how it solves a problem is to say, "When we pass the output of [this function] into the input for the oracle we are actually sending the data backwards in time. So when [the code] queries the oracle we get a result from the future."

Sweet.

The story goes on to say, however, "Time travel is a very dangerous business. One false move and you can create a temporal paradox that will destroy the universe (which in this case means that the computation will diverge). When programming with values from the future, it is important never, never, to do anything with the values that might change the future. This is the temporal prime directive."

6 February 2007

John Goerzen: Why We Live In The Country

Views like this from our house, almost every single day:









Maybe we're not quite as crazy as we thought after all.

22 January 2007

John Goerzen: We're Home

We had some wonderful weather yesterday. I've always said that I like snow. It can completely change the landscape in an instant. And it looks so beautiful.

Yesterday we had a nice snowstorm all day. Large, wet flakes. It was the most snow we've had at once in a few years right around here. It was beautiful just like always. It started early in the morning before we got up and continued until almost midnight. This morning, I went out into a big open area and measured the snow -- 7.5".

There are two problems with snow. One is that it's difficult to get anywhere. The other is that it blows into everything.

And guess what -- yesterday was our moving day.

Fortunately, on Friday evening, most of the furniture that needed to go in a pickup did. But we still had to wrap some things in plastic on Saturday. We didn't get everything moved that we wanted to. Between icy ground outside, travel at less than half the usual speed on the roads, and snow blowing everywhere, things were slow. But that's fine; we'll get the rest later.

This was the scene during the move:



Not long after that picture was taken, it was announced that church was canceled today. We kept moving things though.

Although we didn't get everything moved that we had hoped to, we got enough moved to consider ourselves moved in. We have one fully-functional bathroom. Jacob's bedroom and our bedroom are done. The kitchen will get its floor Monday and we'll get appliances Thursday. The only big thing left is guttering, plus there are still a few doorknobs and light fixtures pending. But it was enough that the three of us spent our first night here last night!

We're very appreciative of the help we got from family & friends, who helped us move and brought us food (since we don't have a fridge for the next few days).

Jacob doesn't like change very much (he cried when he noticed that some clutter in our apartment living room was gone). But he likes to learn about his environment. So today, he woke up at 6AM (and got us up at 6AM), spent an hour happily looking around, then promptly started fussing. That's how the day has been for him -- interest and crying.

At about 7:30AM, we were shocked to see a road maintainer plowing our road. Why shocked? Well, nobody else lives on this road for a couple of miles. It's not exactly a popular spot. And it hadn't been in all that great of shape before winter.

Later in the day, I went out to take some pictures. Here's one of our driveway:



Doesn't it look fun?

I decided to see if we could get out. The short answer is yes. The long answer is "yes, if you have patience." After rocking the car back and forth to get it turned around in the yard, I was able to keep up enough speed to get to the road and back. So Terah and I had lunch with my parents, then went into town to get another carload of stuff. There were children out playing everywhere, and well-worn sledding paths down hillsides. Too bad Jacob isn't old enough to enjoy this!

It was last April when we first started thinking about this. By June we had bought the property out here, and in October we moved to the apartment. It's been a long time feeling like we were living somewhere temporarily.

And, right now, it is great to be home.

19 January 2007

John Goerzen: Everything Update

It's been very busy lately. So here's an update on lots of things.

We move in to the farmhouse this weekend, starting this evening. It's not completely done, but close enough! That's exciting. But I spent 12 hours out there on Tuesday cleaning out the attic (took the day off work to do that). So I'm exhausted, and the moving hasn't even started yet.

The wood floors are all done and looking nice.

Jacob is starting teething. We have discovered that he likes both the taste and effect of infant tylenol. Though he's been better in the past few days.

More pictures of Jacob and the house will be posted once we have a chance to get them assembled.

My MacBook Pro at work finally can suspend to RAM! 2.6.19.2 with the latest mactel patches makes it work with uswsusp.

We'll probably be without Internet at home for a few days -- at least until I get the place wired up and the firewall set up.

One of our neighbors out by the farm died this week. He was out working with his tractor when it slipped off an icy road and landed on him. His wife had just moved from Tennessee last spring when they got married, and has enjoyed working with all their animals. I didn't know either of them very well, and had only met his wife. But she was interested in our house renovation project and stopped by every so often to check on it and chat (their animals are across the road from us). We were looking forward to getting to know them both.

14 January 2007

John Goerzen: You Know You're In Kansas When...

You're raising money for a renovation project on a nursing home, you've got $180,000 left to raise, and a potential donor says, "Hey, that's less than a new combine!"

13 January 2007

John Goerzen: A New Breakthrough

Today, Terah:



And all of that in a single blog post (which is also very amusing). Oh, and on Tuesday, she wrote about debconf.

I think this is the surest evidence yet that both Terah and I are geeks. She claims that only one of us is. What does everyone else think?

I should also add that she has strong operating system preferences (OS X or Linux), likes OpenOffice, uses Firefox and IMP, used Pine as her first email system when she was a student at Purdue, remembers using telnet, uses ssh to this day, and is more bothered than I am when the Internet link goes down.

That's right, more bothered than a Debian hacker.

She's talking about forming a "wives of geeks" BoF at debconf. I think just a simple "geeks" BoF would be fine.

11 January 2007

John Goerzen: Dial Tone

Yesterday I went to activate phone service out at the farm. It got me to thinking a bit about how things change, and how they stay the same, too.

Before I go on, I'll have to say that every one of my history books is in storage, so if I get some details wrong, it's because I'm not remembering correctly.

Anyhow, phone service came to our community via an unusual route about 100 years ago. It wasn't Bell/AT&T or some other company that brought it there, as it was most places. I'm sure they figured that a small, scattered rural community would cost too much to support. So the community organized, built, and supported the phone system themselves.

Even today, roads around here can be impassible after a good rain. I'm sure that, in the early 1900s, before heavy road-maintaining machinery, things were worse -- and, of course, transportation was a lot slower then anyway. There were real problems: getting the word out about funerals, being able to summon a doctor when necessary, or letting people know that church was cancelled because of too much snow.

People in the community saw a phone system as a real need. So did the churches, which have left a legacy that is still reflected in phone company territories today.

Once phone service arrived, it was used for all the things that people expected, of course. But it also proved to be an important part of the social fabric of the community. Since party lines were the norm, it was possible to announce things to every listening subscriber pretty quickly. Older people remember announcements of fresh fruit arriving at the grocery store, funerals, or other news of the day.

To place a call, you would pick up your phone and turn your crank. That caused a bell to ring at the telephone office, which everyone called "Central." The operator would connect to your line and ask whom you wanted to talk to. The operator would then send the distinctive ring for your party down their party line, and patch -- manually -- your call through to them. And, if he was busy, the operator wouldn't listen in on your conversation -- but others on the party line very well might.

Central's hours were published. If you were making a call in the middle of the night, you were going to wake up someone at Central to do it -- plus everyone on the entire party line. So calls after hours were rare.

Fortunately, while some of the old Central operators were still around, some people in the community wrote down some of their stories.

There were some people in the community that were notorious for eavesdropping on other people's conversations. Two brothers one time figured that they knew somebody was listening to their conversations, so they devised a code. One called the other, and said, "I'll be going to McPherson in the morning for band practice." That meant something along the lines of going to town to buy groceries.

A few days later, their prime suspect came up to him and said, "What on earth are you going to band practice for? I didn't know you knew how to play an instrument!" Apparently she realized she was had when he burst out laughing uncontrollably.

The Central operators learned to know the habits of telephone users. Sometimes they would connect calls without even bothering to ask who people wanted to talk to -- and seemed to always get it right.

The phone system supported itself for about 50 years. But as the rest of the world moved on provide direct dialing, this proved a controversial subject in the community. People liked having their operators. The people that worked at Central were everybody's friend. They were people that were there, 24 hours a day, to assist with any emergency. They would gather volunteer firefighters to help fight a fire, or be able to spread community news quickly. This wouldn't be available with the newer phone systems. How would the community be informed of events quickly now? Who would just happen to know whose house the doctor was at when he was urgently needed?

The change was resisted for some years, but eventually the finances of the telephone cooperative turned out to be in deep trouble. Operators grew to be much more expensive than automation, and in the late 1960s, the telephone cooperative was no more -- sold to a phone company from a small town more than twice our size, and a for-profit company at that! Central no longer existed. I remember reading about this event -- it seems people were sad about that for quite some time. They felt that they had really lost an important part of the community when Central went away. Some machine locked in a cabinet doesn't care for people the way Central did. Even today, the older people in the community sound a little sad when they remember telephone modernization, and get the wistful look of somebody that has just remembered something that they miss.

The phone company that bought the system wasn't an AT&T, though. It was a small, independent phone company. To this day, that phone company serves only the two communities. And it was this company that I called yesterday to establish service out at our house.

They had already upgraded our lines -- over a mile of new copper, benefiting only us, at no charge to us -- last fall. The box was already on the outside of the house. Just need to get it activated.

So I called the phone company. They said I needed to drop by their office and sign some papers. Uh-oh, I think -- this is a bad sign. Sounds like a bunch of phone company bureaucracy.

But not so much. I went to the office and signed up. They asked the usual questions: name, address. Plus a few that bigger companies wouldn't ask: who used to have service at that address? Of course, most people would know that answer in our community. I couldn't have told you in Wichita, Dallas, or Indianapolis.

Then they asked when I'd like service to be activated. "As soon as possible," I say, figuring that this would be a couple of weeks like it is with AT&T or Sprint. "Well, we probably can't get out there for a couple of hours. Would it be OK if it's on at about 3?" Yes, that would be fine!

Now, how about DSL? "Well, we're a little backed up on that right now." Uh-oh. Sprint took several weeks when they *weren't* more backed up than usual. "So it'll probably be Monday or Tuesday before we can get out there. Should I just have the installer call you and arrange a time when it gets closer?" Yes, that would be fine, too!

Now, how about finding a phone number.

Out comes a large paper book. Yep, paper. They paged through it, and told me that my grandpa's old number would be available if I wanted it. I said yes -- after all, we've got his old address, so might as well keep the same phone number. OK, no problem. She whips out some white-out, whites out grandpa's name, and writes ours in. Done.

Now, do we want any optional services? Caller ID, call waiting, voicemail? How much is caller ID, I ask. $5 a month. We'll try it for now. "OK". A box was checked on the form and that was that. No high-pressure sales pitch on taking "the works" for some poorly-disclosed price, providing a ton of services I'll never use and don't want. No confusing "discounts" for having The Works and DSL at the same time.

Then I ask about an unlisted number, or at least an unlisted address. We figure that anybody that we really want to be able to reach us will figure out how without using a phone book, and these things get in so many databases these days. Sprint charged almost $10/mo for a fully unlisted number, but only a few dollars a month to just keep our address off the directories.

Our new company charged 50 cents a month for a fully unlisted number. Done.

Now it's time to pay for the first month's fees and the setup. Oops, I've forgotten my checkbook in the car. No problem, the secretary says, I'll watch your baby while you go get it! Jacob was with me, but had fallen asleep, so I brought him inside in his car seat. I went to get the checkbook -- just out the door and close by. I was back in a few seconds later, and the secretary was already on the other side of her desk talking and playing with Jacob. "My baby's 12 now," she said, and for a second, looked like a person that was remembering Central.

8 January 2007

John Goerzen: Christmas Memories, Part 4

In my other posts about Christmas, I wrote about my memories of Christmas awhile back.

In this final post, some more recent memories.

Terah and I don't really have a Christmas tradition yet -- things seem to keep changing.

Our first Christmas after being married was in Indianapolis. Our church there didn't have a Christmas Eve service, so we went to a different one. We also bought a tree from Tree Classics that year:



The next year, we moved to Kansas. Our church has a children's program on Christmas Eve, but Terah likes the more meditative lessons and carols service that her church used to have on Christmas Eve, so sometimes we've gone to a different church that evening -- or even to two different services.

This year, we're in an apartment, and we've got Jacob. That makes everything more fun. Here he is in a festive holidy mood:



Of course, the one thing that a festive holiday mood is sure to lead to in a 3-month-old is a not-so-festive holiday bout of fussiness.



Our tree this year is borrowed. Ours, along with all of our Christmas decorations, lights, and wrapping paper, is in storage. So some of our gifts aren't wrapped. But that's OK -- we enjoyed Christmas all the same.



In this, my last post on Christmas for this season, I wanted to follow up on my earlier post about my Grandpa Klassen. I wrote:

Grandpa was great with the harmonica. And the song I best remember him playing at is Nun Ist Sie Erschienen. I remember sitting on his lap many times listening to him play it. And I'm pretty sure it was a year-round song for him. Terah and I even had it sung at our October wedding -- if it was year-round for Grandpa, that was good enough for us. It's always special to sing the song in church.

I was going to have a picture of Grandpa with his harmonica here, but I didn't get it ready in time. So I'll have to describe it. Imagine a black and white picture of a gentle man, dressed conservatively, holding a harmonica in his hands. He's looking towards it tenderly -- it seems to be something important, and maybe it represented fond memories for him, too. I'll post the photo as soon as I get a copy of it.


Well, here's the photo:

28 December 2006

John Goerzen: Christmas Memories, Part 3

In the first two posts about Christmas, I remembered Christmas at home and with my dad's family. Today I'm remembering Christmas with my mom's family, and tomorrow -- the last post on this subject, I promise -- more recent Christmases.

The first thing that comes to mind about Christmas with mom's family is Grandma's peppernuts (pfeffernuesse to any Germans reading this). Grandma made wonderful peppernuts. And she made huge batches of them for Christmas. I remember gallon jugs being passed around.

Peppernuts are a small sweet dough, rolled out, and cut into pieces about the size of a peanut M&M, then baked. My mom has been making them, and they look like this:



In fact, I can't really remember what sort of main dishes we used to have. Guess I had a one-track mind. I suspect that we also had some of Grandma's famous cherry moos (rhymes with "close").

Us kids usually were the only ones to get gifts there, but that was fine with me. It was also great to spend time with my uncles and aunts, none of which lived in the area. They were always good for some jokes, or maybe a math puzzle.

I seem to recall that Grandma and Grandpa also joined our family for our Christmas celebration on Christmas Eve some years. Here's my Grandma reading from the Bible to my brother one of those Christmases:



Grandma has always loved being around her grandchildren, and she always seemed to have plenty of time for each one of us.

Thinking of my Grandpa Klassen reminds of first of the German hymn Nun Ist Sie Erschienen (MP3 and PDF in the comments at that link). It's still sung, in German and English, at Christmas in our church.

Grandpa was great with the harmonica. And the song I best remember him playing at is Nun Ist Sie Erschienen. I remember sitting on his lap many times listening to him play it. And I'm pretty sure it was a year-round song for him. Terah and I even had it sung at our October wedding -- if it was year-round for Grandpa, that was good enough for us. It's always special to sing the song in church.

I was going to have a picture of Grandpa with his harmonica here, but I didn't get it ready in time. So I'll have to describe it. Imagine a black and white picture of a gentle man, dressed conservatively, holding a harmonica in his hands. He's looking towards it tenderly -- it seems to be something important, and maybe it represented fond memories for him, too. I'll post the photo as soon as I get a copy of it.

Back on December 1, 1990, just at the start of Christmas season, I remember the phone ringing. Dad answered, and I knew quickly that something was wrong. Grandpa had died earlier that day, while doing something he loved -- visiting his children and grandchildren in western Kansas.

His funeral followed shortly. At 11, I was starting to become interested in photography, and I set up my tripod and took this picture of the church on the day of his funeral.



So many people still remember the church that day and commented that having the sanctuary all decorated for Christmas was the perfect way to remember Grandpa.

Grandma still talks about it, too. My mom and I played a piano duet arrangement of Nearer, My God, To Thee. After we finished, Pastor Epp said, "If the music in heaven is anything like that, it will be a wonderful place indeed." He passed away not long after that, too, but Grandma still remembers that comment verbatim (and I'm sure would gently correct me if I made the tiniest of mistakes recalling it here).

In a few days, we'll be celebrating Christmas with Grandma -- and also her 92nd birthday. I bet there will be some peppernuts there.

27 December 2006

John Goerzen: Memories of Christmas, part 2

In part 1, I wrote about Christmas at home growing up.

Today I'll write about Christmas at my Grandpa Goerzen's place.

The family usually got together sometime between Thanksgiving and New Year's, whenever it worked for everyone. Names for a gift exchange would be drawn well in advance. Each person would give and get one gift at the gift exchange.

Except for us kids. Grandpa always had something extra for us. And it always seemed to be just what we wanted, too. After all the other presents were exchanged, Grandpa would somehow produce a few more. He'd get a sly grin and say "Here's another one." And with that, we'd get to open it. As I got older, I knew my parents were probably giving him suggestions, but still -- there was always something special from Grandpa.

That grin went something like this.



The main dish for Christmas at Grandpa's was usually ham, or maybe his famous beef borscht. I always hoped for the beef borscht, anyway.

After the meal, people would do dishes or sit around and talk.



Sometimes I'd get bored and try to leave, but other times there was exploring to be done. Maybe I'd discover some long-forgotten game in the cold storage room upstairs.

On Sunday, I had the good fortune to have 5 reels of old family slides pass through my hands. I've been feverishly scanning all 500 of them on my slide scanner. At tomorrow's Goerzen Christmas, I'll bring along DVD+Rs of these scanned images for people -- I think it'll be great.

One of the slides was this picture of Grandma and Grandpa Goerzen's Christmas tree in 1971.



It's really neat to see pictures of the house we'll move into shortly from so long ago.

And just a few slides past that, there was this photo of my grandparents on the 25th anniversary. It wasn't at Christmas, but it's fitting:



That sure looks like a happy couple to me.

Terah and I had been talking that Christmas this year wasn't quite the same, with all our decorations and even wrapping paper being in storage, not having a house to decorate anyway (we're still in the temporary apartment), etc.

But being different doesn't mean that it's worse. The best gifts we have don't come in boxes under a tree. They're the love we get and give to each other every day of the year.

Grandpa had the same smile in his anniversary picture that he had at Christmas 19 years after Grandma died. I think he's understood what the best gifts are for a long time.

25 December 2006

John Goerzen: Memories of Christmas, part 1

Merry Christmas to everyone today!

Today, and for the next few days, I'm going to write about some of my Christmas memories from earlier years. Then I'll finish up with some photos from this year.

This post is about Christmas at home growing up.

One of the first signs of Christmas happened when my dad put up the lights on the outside of our house.



My brothers and I had (and still do) stockings that got one piece of candy per day during December, then got stuffed full when we opened our presents. The tree went up over the Thanksgiving weekend, and it was always a lot of fun to help with that.



On Christmas Eve, we'd always go to the program at church. It was the kids' Christmas play. Church would be packed. On the way out, everyone got a gift sack with fruit (apples or oranges), some peanuts, and maybe some candy. Then we'd go home. Mom or dad would read the Christmas story from the Bible, and after a prayer, it was time to open presents. In addition to the regular presents, dad would always give us a large paper gift sack. It would usually have a 12-pack of pop and some sort of nut (peanuts, pastachios, or maybe peanut brittle).

Sometimes we'd all stand still long enough for a photo.



We'd usually stay up late into the night Christmas Eve and sleep in on Christmas day.

10 December 2006

John Goerzen: Renovation: Week 24

Wow! What a week. (Click here for all of this week's photos) On Sunday afternoon, we walked into the house and saw this:



Yes, over the weekend, the cabinet makers had installed the cabinets earlier than expected! I never expected that I would get excited about kitchen cabinets, but I sure was. They look great.

My grandma's china cabinet is back up in the dining room. They've removed the tile from the dining room, exposing the wood floor underneath. The floor restoration people have spent some time doing some patching already.

Doors and doorjams are starting to go in. Trim is arriving. And the wood in the wall alongside one of the staircases has been seamlessly extended.

It's exciting. (photos here)

And check this out:



That hunk of ice is the exhaust from our furnace. No joke! The furnace is so efficient that, when its running, it's a moist and slightly warm breeze blowing out of that exhaust pipe. In winter, it condenses and drips down below, forming an ice hunk.

7 December 2006

John Goerzen: Saving Power with CPU Frequency Scaling

Yesterday I wrote about the climate crisis. Today, let's start doing something about it.

Electricity, especially in the United States and China, turns out to be a pretty dirty energy source. Most of our electricity is generated using coal, which despite promises of "clean coal" to come, burns dirty. Not only does it contribute to global warming, but it also has been shown to have an adverse impact on health.

So let's start simple: reduce the amount of electricity our computers consume. Even for an individual person, this can add up to quite a bit of energy (and money) savings in a year. When you think about multiplying this over companies, server rooms, etc., it adds up fast. This works on desktops, servers, laptops, whatever.

The easiest way to save power is with CPU frequency scaling. This is a technology that lets you adjust how fast a running CPU runs, while it's running. When CPUs run at slower speeds, they consume less power. Most CPUs are set to their maximum speed all the time, even when the system isn't using them. Linux has support for keeping the CPU at maximum speed unless it is idle. By turning on this feature, we can save power at virtually no cost to performance. The Linux feature to handle CPU frequency scaling is called cpufreq.

Set up modules

Let's start by checking to see whether cpufreq support is already enabled in your kernel. These commands will need to be run as root.

# cd /sys/devices/system/cpu/cpu0
# ls -l


If you see an entry called cpufreq, you are good and can skip to the governor selection below.

If not, you'll need to load cpufreq support into your kernel. Let's get a list of available drivers:

# ls /lib/modules/ uname -r /kernel/arch/*/kernel/cpu/cpufreq

Now it's guess time. It doesn't really hurt if you guess wrong; you'll just get a harmless error message. One hint, though: try acpi-cpufreq last; it's the option of last resort.

On my system, I see:

acpi-cpufreq.ko     longrun.ko      powernow-k8.ko         speedstep-smi.ko
cpufreq-nforce2.ko  p4-clockmod.ko  speedstep-centrino.ko
gx-suspmod.ko       powernow-k6.ko  speedstep-ich.ko
longhaul.ko         powernow-k7.ko  speedstep-lib.ko


For each guess, you'll run modprobe with the driver name. I have an Athlon64, which is a K8 machine, so I run:

#modprobe powernow-k8

Note that you leave off the ".ko" bit. If you don't get any error message, it worked.

Once you find a working module, edit /etc/modules and add the module name there (again without the ".ko") so it will be loaded for you on boot.

Governor Selection

Next, we need to load the driver that tells the kernel what governor to use. The governor is the thing that monitors the system and adjusts the speed accordingly.

I'm going to suggest the ondemand governor. This governor keeps the system's speed at maximum unless it is pretty sure that the system is idle. So this will be the one that will let you save power with the least performance impact.

Let's load the module now:

# modprobe cpufreq_ondemand

You should also edit /etc/modules and add a line that says simply cpufreq_ondemand to the end of the file so that the ondemand governor loads at next boot.

Turning It On

Now, back under /sys/devices/system/cpu/cpu0, you should see a cpufreq directory. cd into it.

To turn on the ondemand governor, run this:

# echo echo ondemand > scaling_governor

That's it, your governor is enabled. You can see what it's doing like this:

# cat cpuinfo_min_freq
800000
# cat cpuinfo_max_freq
2200000
# cat cpuinfo_cur_freq
800000


That shows that my CPU can go as low as 800MHz, as high as 2.2GHz, and that at the present moment, it's running at 800MHz presently.

Now, check your scaling governor settings:

# cat scaling_min_freq
800000
# cat scaling_max_freq
800000


This is showing that the system is constraining the governor to only ever operate on an 800MHz to 800MHz range. That's not what I want; I want it to scale over the entire range of the CPU. Since my cpuinfo_max_freq was 2200000, I want to write that out to scaling_max_freq as well:

echo 2200000 > scaling_max_freq

Making This The Default

The last step is to make this happen on each boot. Open up your /etc/sysfs.conf file. If you don't have one, you will want to run a command such as apt-get install sysfsutils (or the appropriate one for your distribution).

Add a line like this:

devices/system/cpu/cpu0/cpufreq/scaling_governor = ondemand
devices/system/cpu/cpu0/cpufreq/scaling_max_freq = 2200000


Remember to replace the 2200000 with your own cpu_max_freq value.

IMPORTANT NOTE: If you have a dual-core CPU, or more than one CPU, you'll need to add a line for each CPU. For instance:

devices/system/cpu/cpu1/cpufreq/scaling_governor = ondemand
devices/system/cpu/cpu1/cpufreq/scaling_max_freq = 2200000


You can see what all CPU devices you have with ls /sys/devices/system/cpu.

Now, save this file, and you'll have CPU frequency scaling saving you money, and helping the environment, every time you boot. And with the ondemand governor, chances are you'll never notice any performance loss.

This article showed you how to save power using CPU frequency scaling on Linux. I have no idea if it's possible to do the same on Windows, Mac, or the various BSDs, but it would be great if someone would leave comments with links to resources for doing that if so.

Updated: added scaling_max_freq info

John Goerzen: The Climate Crisis

Wow.

We just watched An Inconvenient Truth. Not much in there was new to me, but to see it all presented at once is amazing.

There are vast undisputed scientific facts out there -- for instance, that CO2 content in the atmosphere is higher than it's been ever -- and we can go back 650,000 years. The linkage between that and temperatures is inescapable.

Gore makes a good point: shouldn't we be worried about more than terrorism?

Does the thought of parts of Manhattan, San Francisco, and large parts of Florida going underwater suggest a problem exists?

This really is critical and urgent.

We've already been thinking about it lately as we renovate our house. We're paying a little more now for things like airtight insulation, low-energy lighting, efficient heating. Not only will it save us money in the long run, it will help improve our lives and Jacob's life down the road.

The movie's website is over at climatecrisis.net.

6 December 2006

John Goerzen: Insurance

I was visiting with our homeowners insurance company the other day (very good folks). Because we weren't living in our house during renovation, we had to get a more expensive type of policy. The agent that sold it do is is no longer with the company, so the new person handling our account asked me, "Why did he want you to get this policy?"

"Well, he said it was because we weren't living there." Then I suddenly remembered the rest of what he said, and couldn't help cracking up. "Plus, he said that if something like a fire happened, people might not notice."

What can I say. Psychic insurance salesman.

On that note, I was having a discussion with someone about large windows on a house. That person was saying that "everyone" always puts their large windows on the front (or back of their house, I forget which) so that potential burglers are easier to spot. He was concerned about where we were putting windows on our house.

This had never occured to me.

But I pointed out that our yard was on fire and nobody noticed for hours. What difference would it make where our windows are?

"Ah, good point," he said.

On that note, you ought to check out rush hour in the country. Truly this is a lot of traffic for roads around here.

5 December 2006

John Goerzen: Review of VPSLink

Back in June, I wrote about my switch to VPSLink for my virtual private server (VPS) host.

Now it's 6 months later, my initial contract is up, and it's time to consider whether to renew it.

Overall, VPSLink has worked out reasonably well. I have their Link-4 plan, which provides 512MB RAM, 20GB of disk storage, and 500GB of bandwidth for $40/mo (or down to $33/mo if you pay for 12 months in advance).

Reliability and Uptime

VPSLink has been reasonably reliable. I wouldn't say that they have been exceptionally reliable, though.

Some outages:



They have generally responded to support requests in a reasonable amount of time, and support has been approximately as helpful as I'd expect.

Overall, there've been a few issues but, aside from that 8-hour outage in July, nothing especially remarkable.

Automated Tools

VPSLink has a "control panel" where you can reboot, start, or stop your virtual machine. You can see how much bandwidth you've used in a month, your IPs, and billing information.

You can also create support requests and view the status of support requests there. You can also view all correspondence on a given ticket, and add new correspondence to it -- a nice touch that's useful if your email is down because your VPS is down.

The reboot/start/stop facility didn't work during one outage, though.

Resources

The 20GB of disk space is nice to have, though I never used it all. No complaints there.

But the memory setup is rather strange. This may be because VPSLink is using OpenVZ instead of its more popular (and featureful) commercial counterpart Virtuozzo, or something such as Xen.

Those that have used OpenVZ/Virtuozzo know there is a /proc/user_beancounters file in the virtual environment that reports on the limits of resources allocated to your virtual server. VZ lets the server admins regulate the amount of resident RAM, swap, inodes, pending IP connections, amount of virtual RAM, etc, etc. About 3 dozen items in total.

Unlike some companies like JohnCompanies, VPSLink was not willing to make any adjustments to this file for me. For instance, my mail server may need more simultaneous open files than they have by default, but they wouldn't work with me to make reasonable adjustments.

But the larger problem was with regard to RAM. This was particularly annoying. VPSLink does not permit any access to swap, so the 512MB is what you get. But tools like top show the entire memory allocation on the host, and are mostly useless in tracking down your own usage.

You can look at the privvmpages entry in /proc/user_beancounters to get an idea of your current usage, but that's it. There is a script on their wiki that will turn this into a more useful number, but again, it's not the most helpful.

The minute you try to allocate anything past 512MB, your processes start getting killed. According to /proc/user_beancounters, even though my system normally hovers around 70% of that 512MB allocated, I've had 290,567 instances where a process has been refused its request to allocate memory since the last reboot. Such instances usually cause a process to crash.

Other Virtuozzo companies like JohnCompanies will give you "burstable RAM", so if others aren't using their full RAM allocation at the moment that your machine goes over your regular limit, you can go over it to a certain extent. That was very effective at preventing crashes during times of higher than usual memory usage, and I never had trouble with this at JohnCompanies.

I've had a lot of trouble with VPSLink because of these hard, no-exceptions limits. Getting hit by the Google bot at the same time as the MSN bot could raise memory usage enough that processes would start getting killed. Depending on which process it is, it could take down cron, apache, the mail server, whatever. And there is no log of which processes die because of this.

In normal circumstances, this wouldn't pose even a noticeable impact to a server; inactive bits could be swapped out, etc.

I am also suspicious of exactly how OpenVZ calculates memory usage. Since moving to a physical Linux box, my memory usage seems to be much lower than the privvmpages would seem to indicate, even though it's running the exact same code.

So I had some outages on my server that were caused by OpenVZ memory limits, which didn't get listed in the overall outages above.

This problem is the #1 reason I'm leaving VPSLink.

Performance

Overall performance has been acceptable. The CPU speed appears to be reasonable and about as expected.

The disk performance has been more problematic, however. It tends to be rather slow. There have been times when I can type "ls" in a directory with about 10 files and it takes 5-10 seconds to respond. And I wasn't even using "-l".

Now that sort of thing is certainly the exception. But it makes databases -- and websites that rely on databases -- very slow.

The performance measurements over at RealMetrics also show VPSLink as being at the bottom of the pack for disk performance.

Overall

VPSLink is a reasonable value, and if monthly cost is important to you, probably a good choice. Don't expect it to be spotless, though. I would call the overall experience pretty average. Nothing too spectacular in either direction in any respect.

4 December 2006

John Goerzen: The Haskell Blog Tutorial

The first installment of Mark C. Chu-Carroll's Haskell tutorial series went up last week.

It begins this way:

Before diving in and starting to explain Haskell, I thought it would be good to take a moment and answer the most important question before we start:

Why should you want to learn Haskell?

It's always surprised me how many people don't ask questions like that.


Farther down:

So what makes Haskell so wonderful? Or, to ask the question in a slightly better way: what is so great about the pure functional programming model as exemplified by Haskell?

The answer is simple: glue.

Languages like Haskell have absolutely amazing support for modular development.


An interesting and though-provoking article, even for someone that's been using Haskell for more than 2 years now. (Yikes, I had no idea it was that long)

You can also see all his posts on Haskell, which include a couple more installments.

Next.

Previous.