Thomas James Just a geek.

Technology, Gadgetry, Photography and Software Development

 

Latest Posts

Making Ubuntu apt faster on ec2

by

Note, this is based on experience in ap-southeast-2 only, using Ubuntu Cloud AMIs

I've found the performance of the default Ubuntu AWS region based apt mirror to vary greatly. Sometimes downloading a package will occur at 6+MB/s while other times it'll be barely 1KB/s.

This can be a problem if you're not pre-baking you're AMIs and you hit the grace period for instance spin-up in an autoscale group with a health check. If you're not careful you'll have a cycle of spin-up->unhealthy->terminate, which could end up being quite costly.

The source of this would appear to be load on the mirrors. Thankfully canonical have provided a simple solution. Switch over to the S3 backed apt mirror for that region. Why these aren't the default, who knows.

Step 1: Throw this in your instance's USER_DATA:

EC2_REGION="ap-southeast-2"
sed -i -e "s/${EC2_REGION}.ec2.archive.ubuntu.com/${EC2_REGION}.ec2.archive.ubuntu.com.s3.amazonaws.com/g" /etc/apt/sources.list
apt-get update

Step 2: Enjoy much faster apt-get.

Step 3: There is no step 3.

Brew Smith Kit - Hoppy Heart IPA; My first attempt at home brew

by

While out shopping for a few things at Biome in Paddington, we chanced upon the Brew Smith home brew kits. On a whim I decided to get the Hoppy Heart IPA kit ($80, it seems that biome put a $10 premium on them, the Brew Smith online store has them at $70) & an additional Chocolate Paradise Porter ingredient mix ($28, again cheaper at Brew Smith - $20). All up $108, or $105 direct from Brew Smith including interstate shipping. Sorry Biome, but if the brews work out, I'll be ordering the refills online.

Brew Smith Packaging

One of the things that drew me to the kits was the size, or the lack of. The kits are fairly small, only making 4.5L of brew, making them perfect for someone like me with a small apartment.

In the box

The packaging is professional, with the welcome letter a nice touch.

Welcome letter & brochure for cure you're own bacon

Inside the box

All the kit contents

Giving it a go

The instructions in the ingredient bag are easy to follow, but I did still check out a few of the great videos on the site just to make sure I didn't miss anything.

All laid out ready to start

On the boil, followed by the boil-over :(

Malt extract in

The boil over aftermath

It's now sitting in a cupboard for the next 2 days until the last of the hops go in. I'm looking forward to seeing how it turns out.


48 hours later, the magic is happening.

Airlock installed


Will let you know how it tastes in 3 weeks.

.net MicroFramework 4.3 BitConverter

by

The BitConverter was added to the .net microframework in version 4.3 and provides a way to turn an array of bytes into a meaningful primitive such as a long.

var bytes = new byte[] 
{
    0x01, 0x02,
    0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
}
var someValue = BitConverter.ToInt64(bytes, 2);

Using it in my netduino targeting code, I encountered a number of occurrences where the netduino would hard lock and require a reset to become responsive again. I traced this back to some usages of the BitConverter but not others. Essentially the var someValue = ... line in the above code snippet.

In researching this issue I stumbled upon a related bug report in the netmf project, BitConverter startIndex not correct, which suggested that with the way the code was implemented the values being converted needed to be word aligned otherwise it wouldn't work.

It looks like there are alignment issues. 32 bit pointers must be aligned on arm processors. Adding packed would solve this or use memory copy.

I was able to reproduce the issue on the EMX, G400, and Hydra. The Cerb and G120 perform properly, however they crash on non-zero start indexes for the 64bit conversions. I looked at the native code and it seems fine, it just adds the index to the pointer and casts it. It’s essentially: reinterpret_cast(buffer + start_index).

Giving this a try by padding the long value out was successful, ending the hard lock & reset cycle.

Eg

var bytes = new byte[] 
{
    0x01, 0x02, 0x00, 0x00, 
    0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
}
var someValue = BitConverter.ToInt64(bytes, 4);