March 25th, 2012

blockfreq, C++, Lua and random thoughts

I'm still hopping programming langauges. Cool that after so much hacking there are still new ones that are actually important to learn.

Juho is very gently introducing me to C++ a la Google. I admit I'm taking it up very slowly, but it seems inoffensive enough. I'm going back on my Erlang-hackerish resolution that "life is too short to learn C++". It'll be interesting to see how this experiment progresses.

Lua is what I'm learning for fun now. I've picked it because my programming has been getting more and more low-level lately, so that it ends up being mostly C, and I need something for the "non-mostly" bits. I'd like to be able to quickly prototype code and then incrementally port most of it to C. I tried SBCL for this for a while, but I never really loved the FFI, and I found that in the end code would have to become 100% C because the runtime system is too heavy to keep around. So I'd like something that's pleasant to prototype with, plays nicely with C, and has few enough moving parts that it can come along for the ride into production. Hopefully Lua works.. otherwise I really need to get good at C++.

So today I wrote my first random Lua program, called blockfreq. I'd be mighty obliged for any tips on how to write it better.

Incidentally the coolest hack we've done recently was to write an inline device driver for the Intel 82599 10Gbps networking chip. This contributed quite a bit towards a doubling in the speed of our already-pretty-optimized networking application at work. Intel did a good job on these chips: the hardware is nicer to integrate with than most software. We really benefited from dragging the DMA engine up to the application level. Quite a bit neater than some past escapades in device driver hacking. (Including the Intel HD Audio chip that was surely designed to annoy firmware hackers who're trying not to use interrupts.)

Randomly, I also discovered that Intel have a nice and simple profiler for bandwidth utilization on system memory and the QPI links that interconnect CPUs and PCIe. This actually makes it simple and easy to understand NUMA efficiency. Cool. There's really no need for this stuff to be a black art.

Last-randomly, I've gotten bored of Twitter and Google+ and nuked those accounts. Trying LJ again. Where are all the cool hacker-kids nowadays?