Today I Learned: GNU parallel, plate tectonics

I wrote something slow in Python (I know, surprising isn’t it), and I wanted to run lots of it in parallel so the ridiculous 36 or whatever hypercores the machine I was using would actually get used. Python couldn’t find a thread if you linked it to 4chan, so I wanted to just invoke Python a few times on different parts of my input data and combine the outputs later.

Enter GNU parallel, with its delightfully dorky logo. I had about a thousand inputs, and I wanted to run enough of them to fill up my CPUs without causing undue thrashing and overhead from cache evictions and paging and so on. Which, blessedly, is exactly what parallel does.

$ parallel -j 16 "python -m slow_thing {}" < inputs

It runs up to 16 instances of the command you specify, replacing {} by each line of stdin. Perfect epoxy for the gaping holes in Python’s functionality. That’s the UNIX philosophy in action, friends.

Plate tectonics

I mentioned on Wednesday that I wanted to generate some terrain to go with my transport network generation, to give some underlying texture to the space. I didn’t just want to reach for Perlin noise, it’s so flat and uninteresting. I wanted something with more dynamic range, more capacity to create interesting features and relationships in the landscape.

I saw Loren Schmidt building some amazing stuff in the last few months with plate tectonic simulations and erosion, so I thought I’d go read a little about tectonics.

I’m still completely bewildered by how the heck tectonics work (and blown away that it’s such a recent theory!), so I’m hoping to go to the library tomorrow and find some wisdom there. But I did learn that geology is full of incredible words like arc volcanism, isostasy, asthenosphere and flexural.

I’m thinking that a first cut at tectonics could model plates of varying density and thickness, where the thickness grows as the material gets older. Dense plates would subduct under less dense plates, and thickness would relate to the amount of available material for forming mountains when two plates bash into each other (or converge, as the fancy science people say).

More tomorrow!

Show Comments