Red Echo

December 31, 2008

I’m back. Christmas visit with my family was busy and satisfying: there was something going on every day, and I had a chance to spend time talking to each person. We had a big family dinner on Christmas Eve, with presents and songs and dancing after, and a laid-back buffet-style Christmas Day; Christmas evening we all went over to Olivia’s apartment, played on Carolyn’s dance pole, and watched a “Christmas Carol” movie.

Friday I spent a few hours trying to upgrade Mom’s computer, with no success. Looks like she needs a new disc drive. In the evening we went down to Midtown for a night out swing-dancing, to celebrate Carolyn’s birthday. I was feeling pretty tired but everyone danced and we had a good time.

Saturday, Ava and I went to San Francisco with MJ and spent the day wandering around being tourists. We had chowder bread bowls at Fisherman’s Wharf, taxied over to the Castro and browsed the shops, then hiked up to Haight and nosed around the hippie strip. Eventually we headed for a restaurant where MJ’s friend Debbie works and killed an hour sipping scotch. I like SF; I haven’t been there in a few years but it still feels familiar and comfortable. I could happily live there someday.

Sunday I worked with Joel on his new robot kit. We started by practicing some splices with his new soldering iron, then got going on the kit itself. We had a mishap right at the beginning, when we soldered the IR-detector eyes in on the wrong side of the board, and ruined one of them trying to tease it back out again, but after that things went smoothly. Joel has never soldered anything before, but he has been interested in electronics for a long time, and I hope he’ll be able to finish the kit and build other projects.

After that I met up with my dad for a couple hours of volleyball at the gym near his house. It’s a regular thing; thirty or forty people show up and play all evening. We cut out early and headed for a brewpub downtown to spend a couple hours catching up.

Monday, Andrew picked me, Ava, and MJ up and we headed for the hills. I’ve gone skiing / boarding with Andrew and Mike every year for the last several; we decided for some variety this time and went to Sugarbowl instead of Sierra-at-Tahoe. The snow wasn’t great, but the weather was nice, and we got a decent few runs in. I still love my new skis. MJ and Ava signed up for lessons – MJ had a great time but Ava unfortunately injured her foot and had to bail out after half an hour. Not such a good day for her.

I spent today driving home, in one straight shot: we left at 8:45 this morning, and arrived in Seattle – 750 miles, half a dozen fuel/water breaks, and one dinner stop later – at 10:15. I was feeling pretty stiff by the end but still alert. I think yesterday’s ski trip actually tired me out more. Last time I tried to drive the whole distance in one go I was in an ’86 Suzuki Samurai – the nice little Pontiac rental I drove this time was vastly more comfortable.

Tomorrow I’ll go back to work. In the evening, I’ll be playing an hour-long set – improv downtempo electronica, live-PA style – at the Offspring New Year’s Ball. I’m doing the 10 PM shift so I will have plenty of time to enjoy the party afterward. I’m not sure I’ll make it all the way to the 11 AM brunch at the other end, but there should be plenty of music and dancing and catching up with friends, and I’m sure it’ll be great.

December 24, 2008

The Great Blizzard of 2008

December 23, 2008

Seattle has been buried under unusually heavy snowfall for the past week. The fact that there is snow at all is noteworthy; a series of snowstorms like this, piling up inches of snow, is something nobody has seen since the 1950s.

I crashed my Rover last Thursday, sliding out of control down a back street on Capitol Hill. Four-wheel drive and fancy electronic traction control do absolutely nothing when you’re driving on packed snow too slick to walk on, and it’s hard to completely avoid routes involving snowy hills when you live on the side of one. We weren’t going very fast, so nobody was hurt, but I did some damage to a parked car and rendered my own vehicle basically undrivable. It’s in the shop, but with Christmas and New Year’s approaching I don’t expect to see it again for a couple of weeks.

In about an hour, then, I’m getting into a rental car, swinging by downtown to pick up Ava, and leaving for California. Highway cameras and DOT reports suggest that I-5 is clear all the way to California, so I think we’ll make it in time for Christmas with my family. I have a shovel, some planks, and a bag of kitty litter in the trunk, just in case, and spare blankets and a sleeping bag in the car.

I’m looking forward to the visit. We’ll be back for New Year’s.

December 16, 2008

I don’t have a particularly good explanation for the slow pace of my journal updates lately. I’m more stressed and less satisfied than I used to be, but on balance life is still pretty good. I just don’t have the time, anymore, to sustain the kind of steady creative burn and extroverted social life I had when I was working from home at a job I had long since mastered. I just haven’t felt like much of a rockstar lately, and a lot of my inspiration to write here comes from thoughts about or progress made on creative projects.

Radian has become my primary creative outlet; working on it in my free time seems to provide enough programming-related stimulation to keep me from grinding to a halt at work. It is a big project, though, and I’m sure it will be at least another year before I have anything ready to call “finished”. The core design has been coming together well, so I am starting to feel more comfortable talking about it. Perhaps I will start digging into that project in more depth here.

The weekend started badly – getting home from work I spent an hour in backed-up traffic, on my motorcycle, in the rain – but after I got dried off and warmed up I ran a few errands and then met up with Ava, Adam, Doug, Michael, and eventually Jacqueline, and had fun banging around downtown. We talked and relaxed and unwound and drank a lot. It was good.

Next morning I started plowing through my to-do list. It felt good and I got a lot done. I eventually met up with Ava and we wrapped some Christmas presents. My family started doing a gift-exchange a couple of years ago – there are so many of us that all buying presents for each other is sort of ridiculous. Joel is still young enough to appreciate a heap of presents, though, so we’re each getting him something. It’s so much fun to shop for him; he’s interested in all the same things I was excited about when I was his age.

Saturday afternoon Cat organized a last-minute “let’s hang out in the basement and light a fire and drink wine” thing that turned into a really nice, happy, warm little party. Eventually she decided to call it an early birthday party, so we stuck candles into a plate of cookies and sang a round of “Happy Birthday.” Snow started falling around nine and continued for hours. We opened up all the curtains and watched the world turn white. Barry had plans to go skiing the next day, and planned to leave early – he ended up staying up til three with the rest of us, but along the way he talked me into joining him. So, a couple hours after going to bed, I bounced back out again, threw on all my gear, and headed for Crystal.

It was a terrific day: still early season, of course, with rocks and twigs peeking through here and there, but almost no ice, and after last night there was plenty of powder. Barry, Michael, and I showed up at the lift not long after they’d opened it, headed for the top, and started skiing. High winds made the peak unbearable – cold enough that Michael and Barry both developed some frostbite – so we spent the day on the mid slopes; stretching ourselves out and letting our muscles remember how it all works. We crossed paths with Chris and Colleen all afternoon, and eventually ran into Kevin, Elan, and Brady at the lodge, but mostly it was the three of us.

I am happy to report that I am no longer limited by my equipment. The new skis will go as fast and hard as I can push them, and they clearly have more to offer than I have skill to use. They go fast on the groomed runs, don’t bog down in the powder, carve easily, and don’t flop around on the rough stuff. This season it will be time to focus on proper technique. Maybe I should look into taking some lessons.

The air is painfully cold and the roads are icy, so I’ve been driving my Rover to work. I wonder how much of the winter will offer weather conducive to motorcycling?


PDF slideshow presentation by John Osterhout of Sun Microsystems: Why Threads Are Bad. It’s thirteen years old, but its information is current as ever.

People gave us a lot of hassle for not providing a simple, built-in preemptive threading class in REALbasic, but I remain convinced that we made the right decision. RB’s event-loop-driven architecture meant that very few operations actually needed to use threads – they are necessary only when some event needs to kick off a long-running process, while leaving the UI available for further interaction. The simple, non-preemptive thread class we offered was carefully constrained in ways which eliminated many of the tough problems usually encountered in threaded code. Threads would only yield to each other on loop boundaries: during the body of the loop, or in code which did not contain loops, you could ignore concurrency issues altogether.

It is hard to reason about your program’s state when you cannot predict when or in what order state changes will occur; since threads share memory, and preemptive threads can interrupt each other at any time, you have to be ready for anything to change at any time. This is complicated even with a single controller and a single worker; add in more threads and it rapidly becomes what a computer programmer might call a “hard problem”.

If we model threading as a network of independent, non-memory-sharing systems, instead of a group of mutually interrupting, state-munging threads, we can handle concurrency much more easily. The best model for multiprocessing is almost always a group of processes, not a group of threads. Each process has its own memory and manages its own state; the processes communicate with each other, and usually with some controller, over serialized, asynchronous communication channels. They may share read-only access to a common data set, but all modifications must be sent back asynchronously.

This allows each process to manage its interactions on its own terms. It updates its state when it is ready to update its state, and does not have to worry that some other process will step in and make its own changes.

There is more overhead this way, so in theory it’s not as fast as an equivalent multithreaded solution. If a host app has to break a problem down, parcel out bits of the task, and collate the results, that’s work which a threaded solution would not have to do – not to mention all the overhead involved in serializing objects to send over the pipe. But the programmer who starts with threads is in for a lot of slow, painful debugging, where the programmer who starts with processes will have time to optimize if necessary and get on with the next thing.

I had a plan for multiprocessor support in REALbasic. If I had stayed on with REAL Software, my solution would not have been to add a “PreemptiveThread” class in parallel to the existing “Thread” class, but to implement something completely different. A new project-item type, which we might call “Subprocess”, would have allowed you to effectively embed a little console app into your larger project. Creating and invoking a new instance of this class would spawn off a subprocess, which the OS kernel would then schedule on any available processor.

The limitation, of course, is that this would genuinely be a separate process. It could use the same classes as the host app, but none of the same object instances, and none of the same static/shared variables. Instead, you’d send data back and forth, as though on a socket: each subprocess would be automatically wired up with a pipe-style communications channel back to the host app. Some basic serialization primitives would let you send the contents of arrays, dictionaries, and structures back and forth, triggering an event in the receiver. This, I think, would have directed people straight toward the best solution for multiprocessing, instead of giving them primitive, low-level tools they’d have to use to build their way up from scratch.

While that would have been the right solution for REALbasic, I’m taking a very different approach with Radian, where all objects are immutable: threads can freely share object references, but once you have a reference to an object, nothing that any other thread ever does can change it. This allows threads to share data, eliminates the need for serialization and asynchronous pipes, and eliminates the overhead involved in starting up a process, while retaining most of the benefits of the process-based architecture. When it is time to merge the results back together, Radian allows sharing via transactions: an architectural style that should be familiar to anyone who has ever worked with a multiuser database. The transaction, from the point of view of the rest of the program, will happen atomically. Data will always stay in a consistent state, it is easy to see where external state may change, and it is thus possible to write code that composes nicely around those points.

December 6, 2008

Brady and Serena came back from their trip to east Asia today. Ava and I spent a few hours this morning cleaning, then I took off to run some errands while she waited to give them back the keys.

My first errand was a trip to REI, where I picked up my new skis and boots. I’m excited. None of the local resorts are open yet, but the season ought to kick off pretty soon now.

Back at home, I spent a couple of hours working on my motorcycles. The FJ600 came with a cut-down front fender that looks sassy but kicks up a lot of spray when riding on wet pavement. The water splashes back against the fairing and then spills out along my legs. Even wearing leather pants, this is a bit much. I found a new fender on eBay a couple of weeks ago, so today I installed it. Turns out you’re supposed to take off the front wheel before replacing the fender. I neglected to do this, but after a lot of twisting and heaving, and after deflating the tire, I did eventually manage to get the new fender installed.

I also put a new left-hand control unit on the Maxim, to replace the one I broke when attempting to replace its choke cable. The new control cluster came with a choke cable, but it turned out to be as worn-out as the one I was replacing, so I’ll have to keep looking.

The evening is winding along. There are a couple of events on tonight, but I think I’ll stay in, catch up on laundry, and work on Radian.