in Hacker School

Hacker School Day 23-24: Waiting to Submit a Patch to Go

edit: It’s been merged!

I’ve continued working on Programming Pearls this week. I’ve been taking each exercise slow and reimplementing some functions using different features of Go. I have tests so I can benchmark the different styles to see the differences.

Recently, I started storing numbers on disk in binary in order to save space and to increase processing speed. I’ve been profiling my code that reads and writes these numbers. I talked about some of this in the last post on Programming Pearls and Go.

I was looking through the profiling data and noticed tons of calls to the reflect package. I was writing unsigned 32 bit integers to a file, and the writer code wasn’t using the fast path (described yesterday as a big switch statement, before falling back to code that uses the slower reflect package). The encoding/binary package has a function to determine the size of the input, and if that function returns 0, the slow path gets taken.

The function to determine the size of the input was missing a check for plain-old unsigned integers. It included checks for signed integers of all sizes/signs, pointers to integers of all sizes/signs, and slices of integers. The check missed unsigned integers somehow. I added them in my local copy of Go and my code ended up taking the fast path.

So I looked up Go’s contribution guidelines, spun up a VPS to build on, and got to creating a patch. Go uses Mercurial for version control, which I hadn’t used before. Thankfully the contribution guidelines spell everything out pretty clearly. Before submitting the patch, I looked to see if an issue was open for this already — there was! Somebody had created the same patch as me and attached it to the issue, but refused to spend the time to follow the contribution guidelines. I updated the issue to point to my conforming changeset.

I received a reply from Brad Fitzpatrick saying that the codebase was frozen until December, and to ping the issue in December. It feels slightly disappointing to have to be a human cronjob, but I’m excited to work with people to get this change in. I’m also glad that he covered the issue, since I had talked with him before at a conference about his Camilstore project (which sounded a million miles ahead of my own system for knowledge management.) I also super want to have my name in the CONTRIBUTORS file 🙂

I’m working on the next question in column 2 in Programming Pearls, which deals with ways to rotate a string efficiently. My notebook still looks like it’s owned by a crazy person.

Write a Comment

Comment