Tuesday, 26 June 2012


Bolo was a popular Mac multiplayer tank battle game back in the early 90s (predating the Web!). I played it a good deal in the computer science grad lab at Auckland University. It's probably the most fun multiplayer game I've ever played. The core gameplay was quite simple (it had to be, on that era's hardware), but team strategy and tactics got very deep and games would often get very intense. It didn't have the problem that has turned me off RTSes --- an initial "rush phase" that usually decides the game in the first five minutes. Skilled players could turn around an inferior position, but it mostly avoided endless see-sawing too.

I've been looking for classic games to play with my kids and yesterday I decided to see what had happened to Bolo. The original Mac version is long gone but a clone, Winbolo, was written for Windows and ported to Linux. It was shareware for a while but now it's been released under the GPL. There is actually no downloadable Linux client --- the port was not maintained --- but in a few hours of hacking last night I was able to bring it back to life. The gameplay feels great, closely matching what I remember.

Winbolo would be a great game to port to the Web. It's tons of fun, multiplayer, open source, and not very demanding on the client. The only difficult part (but it's a biggie) would be networking. Winbolo is client-server using UDP. You could use Websockets but that wouldn't be ideal. What we really need is WebRTC datagram support. Fortunately, that's coming!

Saturday, 23 June 2012

Computer Science In Beijing

The actual point of me being in Beijing was to give a talk at ISMM about memory management in Web browsers, to attend the PLDI and ECOOP conferences and some of the associated workshops, and to talk to CS researchers about all the things I'm interested in.

My ISMM talk was on Friday morning. I felt my delivery was a bit rough because it was all new content for me, but people seemed enthusiastic. I talked about some of the unusual constraints of browser development, such as having to optimize for both perceived performance as well as real performance (unusual for academic researchers, that is). I gave an overview of how we manage memory, with particular emphasis on the cycle collector and some of the optimizations we're doing with it. And I talked quite a bit about Memshrink. I tried to give a lot of credit to Nick Nethercote and others who did the actual work. I've uploaded the slides.

Many ISMM people were very interested in our use of reference counting. There's a paper by Rifat Shahriyar, Stephen Blackburn and Daniel Frampton at this year's ISMM on optimizing reference counting; its motif is that tracing GC has totally defeated reference counting and no-one uses reference counting in "high performance systems", but they will get reference counting "back in the ring". It's a very good paper but their motif is a bit misleading, since in fact reference counting is heavily used in large C++ applications, especially browsers, which we like to think of as high-performance systems! The disconnect is that academic research on reference counting has almost totally focused on memory management for Java virtual machines and similar systems, so what they meant by "high performance system" was "high performance safe-language runtime". Furthermore I realized that there's a critical difference between reference counting in most C++ apps and reference counting for JVM heap management. In the latter case it's generally assumed you don't know which objects are shared across threads, so every refcount update must be an atomic operation, which is incredibly expensive. But in Firefox we statically know which classes can be shared across threads, and in fact we know that most objects cannot, so most of our refcount operations don't need to be atomic and are therefore much cheaper. Thus most of the research results on reference counting do not directly apply to us. However, it would probably still be a good idea for us to mine the literature for good ideas to try --- Richard Jones apparently has a good survey book out, and we should look at Erez Petrank and Steve Blackburn's papers. (Let's not forget David Bacon, whose work inspired our cycle collector in the first place!)

There's a lot of academic research on Javascript. There was very little about compilation at these conferences, other than Brian's PLDI paper on type inference. But there are a lot of people doing static and dynamic analysis of Javascript, doing various tweaks to the language, exploring semantics, etc. That's good.

There's a real explosion in record-and-replay research. That's encouraging, although it's also a bit annoying because very few people are working on the precise problem I care about. A big theme in research these days is "PARALLELIZE ALL THE THINGS", so most of the record-and-replay research is about finding ways to record and replay shared-memory parallel programs, which Firefox isn't really yet. There are some cool ideas there but what we really need is a low-overhead easy-to-deploy record-and-replay system that doesn't depend on anything difficult such as code instrumentation or static analysis or heroic post-facto constraint solving, and we're willing to stick to a single core to get it ... but it's not clear who's working on this, except us with rr.

A related problem is a new instance of a common pattern: in order to carve out space in an area that's getting crowded, researchers are starting to make up interesting variations on record-and-replay to do research on --- variations that probably will never be relevant to real-world problems. I met some researchers trying to record the activities of particular objects, which I don't think will ever make sense if we get the ability to record a whole process at low overhead.

My friends at IBM presented their paper on Race Detection For Web Applications. This paper applies happens-before race detection techniques to detect a page's incorrect dependencies on the ordering of event dispatch. It's a great start, but there's a lot more that can be done to reduce false positives and to create a deployable tool.

One thing they and a lot of other researchers need is an instrumentation framework for Javascript in the browser. In Java there are well-known techniques for instrumenting bytecode to do all sorts of cool dynamic analyses, and the VM also provides lower level hooks like JVMTI. We need something like that for JS. Shu-yu Guo did a nice presentation of Mozilla-based tools, including Jason et al.'s Debugger object at the JSTools workshop, and it occurred to me (and not only me, I think) that it would be really great to extend Debugger with the ability to replace a script with an instrumented version. We already have a lot instrumentation points via DOM events and XPCOM observers, so just adding Debugger-based script instrumentation might be enough to build some really amazing tools, such as the aforementioned race detector.

Amer Diwan gave an interesting keynote about methodological flaws that endanger CS research results. I took the opportunity to ask a question about the bias coming from our reluctance to publish negative results. That week I heard about a few interesting projects that could have worked but didn't, where knowledge about why they didn't would be really valuable to the community. I harp on this regularly; I don't know if my nagging is going to have any effect, but if I ever have the chance to organize a workshop, it'll be the Workshop Investigating Negative Results ("WINR!").

I spent a lot of time talking to Leo Meyerovich. His work on synthesizing parallel layout engines from high-level descriptions is excellent. I used to think it could never scale to handle real CSS, but these days I'm rather more optimistic.

Overall there was a lot of interesting work, and certainly a lot of interesting people, but nothing really blew me away with "how could that possibly work!". Still, an excellent trip.

Friday, 22 June 2012

Google Plus Spam

Recently I removed Google+ from my Google account. Unfortunately, people are still adding my account to their Google+ circles. (I had assumed they wouldn't be able to do that anymore.) Worse, I now get an email every time they do that. The email has tiny text saying "To change what emails Google+ sends to you, you can always manage email subscriptions on the settings page." with a link. When I click on the link, guess what happens? It goes straight to a "Join Google+" page with no way to turn off the emails (unless I rejoin Google+ I guess) :-(. It's odious.

I'm still getting emails from Linkedin too. These sites are like malaria, once you've had them they're incurable.

Tuesday, 19 June 2012

Experiencing Beijing

There were some surprises. The weather was great --- hot, but the famous smog was barely noticeable and we had clear blue skies much of the time. On seven of the eight days you could see the mountains around Beijing; apparently this is unusual. There was a lot more English signage than I thought there would be --- not just for major services such as the subway system, but almost every street sign, many shop signs, and many menus all had English (or at least names in pinyin), and not just in major tourist areas but everywhere I went. It was easier to get about without language skills than I had expected.

I managed to cram in a good deal of sightseeing. I had two free Sundays that I spent roaming around. On the first I was alone and walked from the hotel to around the Olympics area --- the Bird's Nest Stadium, the Water Cube, and the vast plazas between them. It was a beautiful day and lots of people were out sightseeing or flying kites. I took the subway downtown, and walked around the Forbidden City and nearby hutongs --- old streets that preserve the character of centuries of urban living in China. It was all most impressive. (I took the subway frequently all through my trip, as it's easy to find one's way around the system and saves dealing with taxi drivers. It's also ridiculously cheap --- 2 yuan (about 40c NZ) to go anywhere I wanted to go. Obviously Beijing's high population density and low labour costs help, but I wonder if it pays for itself.) I returned to the hotel and went out for dinner nearby with some students, to a cheap but clean local restaurant with food that was simple but novel to me, such as spicy stewed chicken and some unidentified cucumber-like vegetable, cold in a tangy sauce. By the end of this day I already felt much more comfortable; I had stopped feeling self-conscious at being the sole white person in an environment, and I'd adjusted to the traffic behavior in Beijing. (It seems that any driver or cyclist can do anything at any time if they think they can get away with it.) I'd also become used to brushing aside people on the street who accosted me. I wonder what they would have said had I stopped to listen, but my curiosity did not overcome my caution.

During the six days of conferences I only went out in the evenings, for dinner. On Monday night I went with other students to a dumpling house. The dumplings were cheap and tasty but I've had better. Tuesday night was the PLDI banquet at an art gallery in the 798 art district. 798 is a gentrified industrial area (on a large scale, as everything seems to be in Beijing). In fact it feels a little self-consciously bohemian to me, but it certainly was interesting to walk around. The food at the PLDI banquet was a range of delicious finger-foods and I had a great time even though the setting, and big parties in general, aren't really my thing. On Wednesday night I went with a group to a night market downtown, but I wasn't feeling 100% (something I'd eaten earlier, not sure what, disagreed with me) so didn't end up eating anything there. Judging by the smell, that might have been a good idea under any circumstances, although the non-olfactory atmosphere was great to experience. On Thursday I went out with a professor friend to meet his family at the tiny hotel they were staying at in a hutong in a different part of town. This was a classic Chinese house arranged around a central courtyard. We ate at a tiny place nearby, tasty cheap local food at a makeshift table on the street, perfect! Friday was the ECOOP banquet, back in 798 but this time a sit-down meal in a converted factory with the sawtooth-style roofing that is characteristic of the area. On Saturday evening a local Beijing student volunteer took a group of us to Nanluogu Xiang, a famous hutong (near Houhai). We walked the main street, which is mostly shops now, and ate at one of the cafes there. The street, and the cafe, were rather touristy, but we were on the roof and had a great view over the neighbourhood, so it was lovely.

I was fortunate to be able to spend all of Sunday with one of my closest friends. We booked a car and driver for the day and went out to see the Great Wall at Huanghuacheng. Just traveling out there was very interesting, as our driver took some back streets and I finally saw the countryside outside Beijing: dusty, intensely cultivated in chestnut trees and corn, farmers drying crops on the road, run-down villages, strange three-wheeled pickup trucks, and despite the roads being less crowded, even more insane traffic behavior than I'd seen in the city. Huanghuacheng is an interesting place to visit the Wall, since it crosses a river there via a dam, but apparently it's less frequently visited than some of the other parts. We walked along the wall up and down a couple of hills for three hours: slow progress due to the extremely steep slope (hands-and-feet in places) and areas of disrepair. It was very hot: the temperature must have been around 40C and there was little shade. The glue holding the cheap plastic cover to my cellphone melted. Oddly, people on the dam were constantly letting off fireworks: mortar types much more powerful than I've seen in civilian hands before. From Huanghuacheng we went to the Ming Tombs area and visited the tomb of the Yongle Emperor at Changling. It has similar architecture to the Forbidden City, but smaller and in a completely different setting. We also we walked along the statue-lined "spirit way" at the entrance to the Ming Tombs complex.

I think building a massive funereal edifice for oneself would be a grave sin --- it's a monument to one's vanity with a side order of blasphemy --- but it does have the redeeming feature of leaving an artistic legacy for future generations, with luck. It also shows a refreshing acceptance of one's own mortality, which is certainly better than the delusions of immortality (both grand and wilfully blind) that are so common.

On Sunday night my friend and I visited a restaurant near the hotel that served somewhat fancy cuisine from northeastern China. This was a great place: an 86-page menu with lots of interesting dishes and drinks. The most interesting dish we ordered was fried silkworm pupae, which tasted disgusting. Everything else was very nice.

Overall the food during the trip was very interesting and tasty, and I'm glad to have had it, but often the ingredients seemed a bit bland. I think we're lucky to have high-quality produce in NZ.

My visit provoked lots of thoughts about geopolitics and the Chinese people, but mostly trite so I'll keep them to myself. I will say that the Great Firewall is much more painful than I'd realized. Lots of sites I use simply didn't work and although most of the bustage was presumably the Firewall, one of the worst aspects is that you can't easily tell when it's the Firewall, which makes diagnosing problems very frustrating. In some cases the Firewall seems to break only some pages in a given domain, or otherwise make random features on particular pages break or be very slow.

Overall I had a wonderful time and I'd love to go again. As in Europe, I get an enormous thrill just wandering around places where people have lived for thousands of years, and in many ways China's history is even more intriguing. However, I am very glad to come home, and to live in New Zealand.

Of course, the actual point of my trip wasn't sightseeing but to attend PLDI, ECOOP and workshops, give my ISMM invited talk and do a lot of talking about computer science with all the people there, many of whom I know well from my research days. But this blog entry is already far too long so I'll defer reporting on that to another post.

Thursday, 7 June 2012

To Beijing

I'm planning to be in Beijing next week. I've been invited to give a talk at the International Symposium on Memory Management 2012. It's colocated with PLDI, ECOOP and various workshops --- a key destination for my former colleagues in computer science research --- so I'm looking forward to hanging out with a lot of old friends and a few other Mozillians. Hopefully I'll learn something about what's going on in the field, too. Although I'll probably be stuck in the hotel most of the time, I will have some time to see a bit of Beijing and I'm very much looking forward to that as well.

I should have some connectivity but the onslaught of computer scientists is expected to crush local Internet service, so I don't expect much!

Leaving Linkedin

Inspired by others, I just quit Linkedin. There was almost no value in it to me --- probably negative value to due to having to deal with their email. I am now a member of zero social-networking sites, which I find very satisfying.

Tuesday, 5 June 2012

The City And The City

I've just finished reading China MiƩville's The City And The City. It's amazing. The premise is original and outrageous, and seems hard to sustain given he places it in the context of the real world, but he carries it through brilliantly. I've previously read his Bas-Lag novels; they were very good (if flawed); this is much better. Not only do I think it's a better book, but it doesn't creep me out the way Bas-Lag does.


This weekend was Queen's Birthday Weekend so we got Monday off. The weather was excellent the whole weekend. On Saturday my family went to Mangawhai Heads (about 1.5 hours drive from Auckland) and did the Mangawhai Cliffs Track. We walked up the beach, around the rocks to the headland, then up the hill on the track, through the bush and along the clifftops back to the beach and carpark. It was dazzlingly beautiful and a good reminder that although people here like to complain about the weather, having such brilliant and warm days in winter is one of the great blessings of the Auckland region.