[ Bjarni R. Einarsson / blog: IS EN ]


Beanstalks Project and cleaning house

2010-07-19 10:29

Last Friday I launched the web-site of my fledgling company, the Beanstalks Project. I expect most of my work-related blogging is probably going to happen over there, not on this page.

Incidentally, for my geekier friends, I aggregate all my different RSS feeds into one at this URL: bre.klaki.net/u/?Bjarni.rss. That feed includes pretty much everything I write on the web (except for my Tweets) as well as links to Stuff I Like.

...

In other news, this weekend was a major weekend of mid-summer cleaning: Ewelina and I took everything out of the downstairs storage room and into the back-yard. There we sat in the sun and sorted it all into four different piles: trash, charity, keep and friends. The keep pile was the smallest of the three, so now there is lots of room in the store-room for more "stuff".

But more importantly, now we actually know what we have.

And, I got ever so slightly sunburned!

Permanent URL ]   [ Reply ]

Carpentry Sunday

2010-07-04 21:11

Today I made massive progress on a 6-year-old carpentry project: closets in my bedroom.

The sliding doors are assembled and in place, and the room already looks so much nicer. Later this week I may try to dye the wood a darker color, paint the internal shelves and put them all in place, and if all goes well, next weekend I'll finish the drawers under the window.

It's weird to suddenly make rapid progress on something I've been putting off or ignoring for so many years. Of course, I was distracted by things like a divorce, single life and living abroad for four of those six years... but still. It's strange, but very gratifying, to finally see this stuff getting done.

When Ewelina and I finally get around to having a house warming party, this place is going to look completely different. And awesome! :-)

Permanent URL ]   [ Reply ]

My kind of DB: redis

2010-06-24 00:58

I spent today evaluating what kind of back-end data storage system to use for my little startup.

(Oh yeah, I am starting a company, did I forget to mention that? It's gonna be awesome. Details later.)

As many of you may know, I detest RDBMS databases, and have since University. Every time I have tried to use one, it has sucked, possibly with the exception of sqlite. Luckily the data I am working with in this project is a terrible fit for an RDBMS, so I was free to go exploring the open-source NoSQL universe with a clear conscience. Whee!

There are some pretty cool projects out there.

I found some nice Bigtable work-alikes (Cassandra, Hypertable), which tempted me a bit after my experience with Bigtable at Google. But I don't need all their features, the complexity and requirements would probably be more of a hindrance than a help to my project. I was tempted a bit more by Voldemort, which is a fair bit simpler, as it is a plain key/value store, not an ordered table. But still, it looked too complicated in some areas, and not mature enough in others.

Finally, I discovered redis: an in-memory, disk-backed hash table which natively supports the most important data types (ints, floats, lists, sets) and allows high-level atomic operations. It also knows how to do replication, a requirement for my project, and the implementation is simple enough that I should be able to promote a slave to master status in an emergency with little difficulty. The 2.0 release (already in beta) adds support for pub/sub and larger-than-RAM data-sets (swapping out unpopular entries).

In short, it looks totally awesome!

It was really weird to read about the features of redis, though - I had this ridiculous feeling of deja-vu.

See, redis is exactly the program I would (try to) write if I rewrote BottleNeck (the data-store behind Partalistinn and Walkabot) for serious use.

It does the same things, in the same way: it is a single threaded, in-memory hash server. It has a human-readable client/server protocol, running over TCP. Every now and then it forks out a new process to write a checkpoint of the current DB state to disk. It can track incremental changes using an operation log. The up-coming 2.0 version even has pub/sub features (BottleNeck has "watches").

Freaky. But of course, redis is in almost every way superior to my naive Perl implementation. It is faster. It is properly tested. It has way more high-level operations, natively supports complex data-structures like lists and sets, and it supports replication. Version 2.0 even supports larger-than-RAM data-sets.

It's like I got to design the thing and set requirements, and then a much better programmer went and implemented it all (and more) while I wasn't looking.

I can't wait to start using it!

     Re: My kind of DB: redis (JBJ)
         Re: Re: My kind of DB: redis (Bjarni Rúnar)
             Re: Re: Re: My kind of DB:.. (JBJ)
                 Re: Re: Re: Re: My kind of.. (Bjarni Rúnar)
                     Re: Re: Re: Re: Re: My kin.. (JBJ)
                         Re: Re: Re: Re: Re: Re: My.. (Bjarni Rúnar)
         Re: Re: My kind of DB: redis (Bjarni Rúnar)
     Re: My kind of DB: redis (Nick Johnson)
         Re: Re: My kind of DB: redis (Bjarni Rúnar)
             Re: Re: Re: My kind of DB:.. (Anonymous)

Permanent URL ]   [ Reply ]

code.walkabot.net

2010-05-19 21:39

For the past few months I've been working on a system for building blogs and web-sites, named Walkabot.

(I was on 'walkabout' with my Android... Get it? Get it?)

Today I decided to document and release what I have written so far, which although far from perfect, is also decidedly non-trivial.

I started working on Walkabot when I hit a wall in my WhereBlogger development - I needed a site online to handle some of the heavy lifting for embedding maps and videos in WhereBlogger authored blog-posts.

Things quickly got out of hand (turns out I have lots of opinions on what systems like this should do) and now I'm just writing Walkabot because I want to. It's lots of fun.

Once I've got it working well enough, I hope to migrate both the Sacrifiction travel stuff and my own personal web-site to Walkabot - but it isn't quite ready for that yet. Soon!

However, Walkabot is ready to run a web-site dedicated to describing Walkabot itself. So in the spirit of release early and release often, I present: code.walkabot.net

Don't ruin my fun if you think I am wasting my time, but feel free to tell me if you think it's awesome. :-)

     Re: code.walkabot.net (Már Örlygsson)
         Re: Re: code.walkabot.net (Bjarni Rúnar)

Permanent URL ]   [ Reply ]

Perl IO::Select infinite loop bug, work-around and fix.

2010-05-16 09:47

I just sent an e-mail to the perl5-porters mailing list, describing a bug in and a potential fix for the IO::Select module.

Googling it, this bug has been reported at least once before (in 2005), but no fix was proposed and it seems no-one could be bothered to track it down. The bug is probably 12 years old by now. Crazy. I will be pretty happy if my solution is accepted.

Update: Resubmitted via perlbug, issue number 75156.

...

For the nerds in the audience, here is the story:

IO::Select is Perl's standard OO wrapper around the POSIX select() call. It is in my opinion an example of a good OO abstraction, hiding away the arcana of constructing select() bitmaps and interpreting their results behind a nice simple API.

However, every time I have used it, my IO::Select based servers have been prone to going into infinite CPU-sucking loops - every now and then, IO::Select would simply stop working.

This is trivially triggered by closing a file-handle which IO::Select is still watching.

I found I could avoid the problem (for the most part) by taking care to always remove file-handles from my IO::Select objects before closing them, but this was only a partial solution as either the OS or lower-level APIs could (and would) still close file-handles without 'asking me' first, on certain conditions.

I could trigger exactly that in an IO::Select based HTTP proxy I was working on this weekend, simply by hitting ESC at the right moment in my web-browser. Not exactly an edge case!

This problem can be detected with careful error handling around the IO::Select call, but it turns out that even when the problem has been detected, there is no way to remove the trouble-making file-handle from IO::Select. The only option left is to discard the IO::Select object entirely and build a new one, which I consider a relatively ugly workaround.

This is in my opinion a bug, and last Friday, on a rainy night in a guest-house in Kazimierz Dolny, I decided to see if I could fix it. I think I succeeded, but we'll see what the perl5-porters think.

The problem I found in the IO::Select module was that all the code to do with adding or removing file-handles depended on the result of a fileno() call - but fileno() returns undef once a file-handle has been closed. So, in the case of fileno() being undef, I simply added a linear search for the object in question. It seems to work.

Of course, my code still has the ugly work-around I described above (and probably always will), because it will take a while for my change to get reviewed, approved, integrated and then distributed to every single Linux machine on the planet... oh wait, that will probably never happen.

The workaround, for posterity, looks something like this:

my $newSel = IO::Select->new();
foreach my $handle ($oldSel->handles()) {
    $newSel->add($handle) if (defined $handle->fileno());
}
$oldSel = $newSel;

I hope my little bug-fix will make some future Perl programmers' life a little bit easier. And in the meantime, I hope people Googling for help will find this blog-post.

Permanent URL ]   [ Reply ]

Facebook recruiting

2010-05-16 08:50

I just wrote the following e-mail to Facebook recruiting, in response to a job offer they sent me:

Hello [recruiter],

Thank you for your e-mail and your offer. However, I must respectfully decline, as I do not want to support a company which has demonstrated such a profound lack of respect for their users and users' privacy, as Facebook has.

Sorry, Bjarni

     Re: Facebook recruiting (Siggi Palli)

Permanent URL ]   [ Reply ]

FSFÍ Freedom Award - a belated thank you!

2010-05-12 16:01

I just realized that I never blogged about receiving the FSFÍ Freedom Award last December. Oops!

My (possibly weak) excuses for not even saying thank-you at the time, were a lack of decent connectivity in the Peruvian jungle, worries about my health (Typhoid is scary) and generally being preoccupied with my trip.

Thinking about it now though, I feel like quite the ingrate. What I should have said, and will say now is: Thank you very much!

As I understand it, I was granted this award for being very involved in (and sometimes instigating) much of the early Icelandic grassroots activity to do with Free Software and digital rights.

It felt, and still feels, a bit odd to be awarded for my efforts in a field I have been neglecting of late, and odd to be singled out when I know I was rarely alone in those efforts, and odd to be awarded for work that I still don't really know whether made a difference... but I guess that is the nature of awards like this. And I am very grateful for the award, and more importantly, inspired by it.

I aim to do a better job living up to the award, now that I am no longer employed by a giant, secretive company and no longer backpacking around the Americas: if I don't release some interesting free software and take active part in the community in Iceland this summer, please spank me.

But anyway, I'll say it again: Thank you, FSFÍ!

Permanent URL ]   [ Reply ]

Launin mín, launamunur kynjanna

2010-05-11 13:57

Ég er að reyna að komast að því hvað ég á að biðja um há laun þegar ég kem heim til Íslands.

Það eru ýmsar leiðir færar.

Ein, sú einfaldasta, er að taka launin sem ég var með hjá Google, umreikna yfir í krónur og biðja um þá tölu. "Eftir hrun" veit ég ekki hversu raunhæf aðferð þetta er - það var nefnilega engin kreppa hjá Google, þvert á móti...

Önnur er að bera mig saman við fólk heima sem er að vinna svipaða vinnu. Spyrja kunningjana og svona. Kjarakönnun Félags Tölvunarfræðinga er ætluð í akkúrrat þetta, en ég er enn ekki kominn með eintak af henni.

Í dag fann ég hinsvegar annan góðan kost, tól sem hentar vel í akkúrrat svona samanburði: Hagtölur Hagstofunnar!

Ef þú eltir tengilinn að ofan, og smellir á "Laun fullvinnandi launamanna ..." færðu upp form sem leyfir þér að velja ár, stétt, kyn og ýmislegt fleira. Þú getur líka valið marga kosti í hverjum flokki ef þú vilt gera samanburð. Flott græja!

Það tók mig enga stund að finna tölur til að miða mig við í minni eigin væntanlegu kjarabaráttu. Nú er ég vopnaður í slaginn, ef einhver væntanlegur vinnuveitandi býður mér bág kjör fer ég sko með hann beint á Hagstofan.is og sýni honum í tvo heimana!

En það er auðvitað ekki sama hvernig það er gert.

Best er að bera mig saman við stjórnendur, eða allavegna sérfræðinga. Ég er alveg sérfróður um hitt og þetta og get verið stjórnsamur á köflum. Engin vandræði þar. Svo tel ég mig að sjálfsögðu ekki vera einhver meðaljón, ég verð því að bera mig saman við efri fjórðungsmörk í minni stétt, alls ekki meðaltal eða miðgildi (ojj). Og, síðast en alls ekki síst, verð ég að gæta þess að bera mig einungis saman við aðra einstaklinga með utanáliggjandi æxlunarfæri.

Að bera mig saman við "alla" hentar verr, og enn verr væri að bera mig saman við "konur". Þetta atriði skiptir meiru máli en að sniðganga meðaljóna - munurinn á kyjnunum í flokki sérfræðinga er hlutfallslega meiri en munurinn á meðaljóni og "efri fjórðungsmörkum"!

Svipaða sögu var að segja hjá öllum stéttum sem ég gat skoðað og nei, munurinn skýrðist ekki af ólíkum fjölda vinnustunda.

Sláandi, og ekkert sérstaklega fallegt.

En ég veit allavegna núna hvernig ég á a beita mér í minni kjarabaráttu: vera órakaður og bera mig karlmannlega.

     Re: Launin mín, launamunur.. (Vera)
         Re: Re: Launin mín, launam.. (Bjarni Rúnar)
     Re: Launin mín, launamunur.. (Anonymous)

Permanent URL ]   [ Reply ]

Fátækt

2010-04-11 13:56

Ég var að lesa grein um íslenska fátækt, þar sem fjallað var um fólk sem þiggur matarölmusu.

Greininni mistókst algjörlega að fylla mig af samúð fyrir þessu fólki.

Ég hef auðvitað aldrei upplifað atvinnuleysi, hvað þá fátækt, og er á seinustu stigum þess að eyða meirihluta sparifésins í bakpokaferðalag um S-Ameríku með kærustunni. Það má alveg leiða líkur að því að ég sé ekki lengur í tengslum við raunveruleikann á Íslandi.

Minn raunveruleiki er meira einhvernveginn svona:

Í gærkvöldi sátum við Ewelina fyrir utan veitingastað hér í miðborg Posadas, í Misiones héraði Argentínu. Við vorum þreytt eftir 6 klst. rútuferð, þunn eftir bjór-og-púl-partý á hostelinu okkar kvöldið áður, en glöð því klukkustunda labb um borgina hafði borið árangur og ég fundið hótel sem við höfðum efni á. Ewelina var í sjokki vegna Pólska flugslyssins í Rússlandi.

Við höfðum pantað okkur pizzu og ávaxtasafa, og höfðum svo mikinn mat að við áttum enga möguleika á að klára.

Betlarar höfðu angrað okkur alla máltíðina, bjóðandi blóm og ljóð og skóhreinsun, aðallega börn langt undir lögaldri. Ef maður vildi ekki kaupa drasl, var beðið um moneda, ef maður sagði nei var spurt aftur, og svo aftur, og svo aftur. Pirrandi. Flest börnin virtust vel heilbrigð og voru í hreinum fötum. Stelpa sem var að selja blóm þáði hamborgaraafganga af næsta borði, en var greinilega ekki svöng, og lét systur sína bera afgangana í pappakassa. Systirin gretti sig.

Ég gaf þeim ekki neitt, þrátt fyrir tveggja mínútna suð.

En svo kom lítill strákur að borðinu okkar, ekki að selja neitt, skömmustulegur og í skítugum fötum. Hann bað um ölmusu svo lágt að ég heyrði ekki hvað hann vildi - en þegar ég bauð honum pizzu heyrðist jáið hátt og snjallt. Augu hans ljómuðu og brosið var svo einlægt þegar ég rétti honum sneiðina að ég sá eftir að hafa ekki gefið honum hinar tvær líka. En hann hvarf svo fljótt að ég hafði ekki tíma til að gera neitt í því.

Svo í morgun, með kaffinu, les ég grein um íslenska fátækt. Dæmið sem er tekið, er kona sem þiggur matargjöf vegna þess að hún missti vinnuna og hefur lítið milli handanna. Hún á í vandræðum með að standa í skilum af tveimur bílalánum án þess að missa húsnæðið sitt.

Þetta er auðvitað ömurleg staða, en er þetta fátækt?

Þetta hljómar frekar eins og fólk sem er í vandræðum með að takast á við að það reyndi að lifa langt um efni fram, og það gekk ekki upp. Kannski þarf hún að láta eignir upp í skuldir, flytja í leiguhúsnæði eða leita á náðir vina og fjölskyldu? Lýsa sig gjaldþrota og þiggja atvinnuleysisbætur?

Erfitt, sárt, leiðinlegt... en þetta er enginn heimsendir og ég hika við að kalla þetta fátækt. Miðað við það sem ég sé í þessum heimshluta, tekst mér ekki einusinni að finna fyrir samúð - þetta eru lúxúsvandamál.

Eða hvað? Ég er auðvitað úr tengslum við íslenskan raunveruleika. Fólk má gjarnan leiðrétta mig.

     Re: Fátækt (Birgir Stefáns)
     Re: Fátækt (Kjartan Þór)
     Re: Fátækt (ella)
     Re: Fátækt (Einar Jón)

Permanent URL ]   [ Reply ]

EeePC SSD death: mods, hacks and optimization

2010-01-13 22:13

The other day, my EeePC's internal SSD (hard drive) decided to start rejecting writes - looks like I wore it out. Not a huge surprise, the drive has been very slow of late, making me look unfaithfully at new machines in shop windows.

The death of the drive resulted in a minor flurry of hurried nerding, here in the lovely city of Sucre, Bolivia.

First, I decided to try replacing the drive (for now) with a cheap USB thumb-drive. I wandered the streets, eventually finding a shop which sold me a nice 32GB Sony memory stick, for 50 USD. It seemed like an OK price...

Too bad it didn't work: when I tried formatting the drive as half VFAT and half Linux ext2, the ext2 partition kept turning out to be unreadable. Googling for help, I discovered that I had fallen for a common scam: selling 1GB memory sticks which have been modified to claim to have 32x more space, happily discarding data written to most of it. Very, very nasty, I consider myself lucky I caught it so soon, before losing any data.

Unfortunately, I hadn't gotten a receipt, so I ended up resorting to a slightly asshole-ish trick to be sure I would get a refund: instead of complaining, I requested a belated receipt "for work...". As soon as the friendly woman in the shop handed it to me, I apologized, explained my problem (in broken Spanish), and demanded an exchange or refund. It worked, I got my money back and the shopkeeper was still smiling afterwards. Bolivians are nice - as I left I wondered to myself whether I had been the victim of the scam, or whether she had.

My second purchase was a 16GB Kingston stick, which worked fine. Again no receipt, this time because the person selling it was avoiding tax...

After migrating my data to its new home and verifying that everything more-or-less worked, I decided to perform a basic 'mod' and install both a hub and the thumb-drive inside the EeePC chassis itself.

The mod itself was good fun, although I am limited by the fact that I have no soldering iron, only a leatherman tool and plenty of tape. A true McGuyver mod!

I stripped all the plastic from a cheap ($7) USB hub/card-reader, stripped all the plastic from a USB bluetooth adapter given to me by my brother (why I've been carrying it around S-America I cannot say...) and somehow managed to squeeze all these gadgets, including a spare 1GB MMC card into empty spaces inside the EeePC's tiny shell. A short tail of USB cable now emerges from the Eee's bottom, which I've taped to the chassis and keep plugged into one of the external slots - when I have a soldering iron I'll be able to clean that up and connect everything internally.

At one point I thought I had bricked my laptop - it wouldn't boot at all. Ewelina's working Internet connection came to my rescue though, telling me that I could hard-reset the BIOS by shorting a pair of connectors hidden underneath a sticker hidden underneath the memory. Phew!

At another point, I couldn't understand why the memory card kept showing up as read-only - until I realized that the USB hub's on-board card-reader, really was only a reader, not also a writer. Odd, but no matter, I'm just storing applications on that card so day-to-day, read-only access is all I need.

So, to sum-up, over the past 48 hours I have replaced my EeePC's worn-out, dog-slow 16GB SSD with: one 16GB USB thumb drive, one 1GB MMC card, and 1 bluetooth adaptor. Also, my laptop no longer locks up for ages when programs try to write new files...

When I find a larger thumb drive for a reasonable price, I'll be able to upgrade further, and when I find a soldering iron, I'll be able to clean up the mod and free up enough physical space for a second thumb drive or some other USB gadget.

I'm thinking an FM radio transmitter might be pretty cool...

...

That's just the hardware side though. The software side is at least as interesting.

The first trick, was to get the Ubuntu boot sequence to wait for all those USB devices to settle down before trying to run fsck or attach them to the file-system.

I solved this by adding a little script to /etc/rcS.d, which I named 'S29usbwait'. It's basically a loop which runs: dmesg |grep -c 'Attached SCSI removable disk' to count how many devices have been attached - when the number is 3, I know everything is ready.

The second problem was more subtle; I am under no illusions about the reliability of cheap USB flash drives. The more I write to the drive, the sooner it will suffer the same fate as the SSD it has replaced. So I made quite a few changes to the system to try and minimize writes.

The first change was to add the 'noatime' option to the fstab line for the memory stick. This is well documented and is pretty much standard practice. I also went with 'dirsync', which does the opposite (increases writes), but should reduce file-system corruption when the device decides to misbehave. (Comments on how dumb/clever this is, are most welcome).

But how to prevent truly unnecessary writes? Which programs are creating new files all the time, for no good reason?

Firefox is a well-known culprit, it has a disk cache, bookmarks, history and all sorts of session files. Online I found hints about how to move the disk cache to RAM (open up about: config and set browser.cache.disk.parent_directory to /dev/shm/bre or something like that).

But there's sure to be more, Firefox can't be the only bad-guy. So to figure out which files are being constantly created/changed, I turned to trusty old find: find . -mtime -1 -ls |less -S

This lists all the files in my home directory which have been created or modified within the past 24 hours. I can easily ignore the ones I'm actually working on and focus on the rest to look for things to tweak or turn off. The list was quite long.

I did find some more nasty Firefox stuff (read here about the urlclassifier bug, which sounds very bad for flash-media) and am experimenting with simply removing write access from files in the session directory (.mozilla/firefox/...). We'll see how many features I can break without noticing a difference.

However, it turns out the biggest file-writing culprit on my machine was Eclipse, which I use for Android development.

Eclipse is by default configured to automatically recompile code as it is edited, generating warnings and error-messages on the fly. This is actually quite a nice feature, which does a lot to make programming in Java less bothersome. However, it also generates dozens of files in the process, over and over and over again - pure evil from the point of view of my poor flash drive!

Looking through the Eclipse menus, I found that under Project > Properties, I could change the output path - so I changed it to a location in /var/tmp (actually a symlink from the project dir to /var/tmp), which just happens to be a RAM disk. This not only removes the write load from my flash drive, it also makes Eclipse quite a bit snappier. Score!

Eclipse also seems to like editing a whole pile of files in ~/.eclipse. History and settings, no doubt. To stop that nonsense I simply ran chmod -R -w ~/.eclipse. So far Eclipse hasn't complained.

There are also a bunch of KDE configuration files that seem to get updated quite frequently, but as I suspect they are providing useful UI features, I've left them alone for now. If I change my mind later, they also will get the chmod -w treatment.

...

Hopefully these hints will show up in search engines and help someone out.

I've seen dozens of articles mentioning individual optimization techniques, tweaks and hacks, but just running find and having a look at what is being changed, and then using chmod and symlinks to take control of the situation was nowhere mentioned - and yet I think it is a much more complete and 'sustainable' approach.

Did I just invent it, or is it just too obvious for tech journalists to mention in their articles?

     Re: EeePC SSD death: mods,.. (Óttar)
     Re: EeePC SSD death: mods,.. (EinarI)

Permanent URL ]   [ Reply ]

Fleiri nýlegar færslur:

Færslusafnið geymir restina...

Í dag fyrir einhverjum árum:

  •    1999    (no subject)
  •    1999    www.ompages.com
  •    1999    Shrinkwrap licenses
  •    2001    Darn coffee drinkers!
  •    2001    Tiles and paint
  •    2002    Stóra Klaka-betlið
  •    2002    Pilluvesen og tímaskortur
  •    2003    Perl Exegesis 6
  •    2003    Fjörfiskur og tár
  •    2004    Góði Hirðirinn og eitthvað