Thursday, May 17, 2012

Slashdot Comment of the Day #4


A recent post on slashdot by jd entitled "CPU Competition Heating Up in 2012" gets excited about processors that are anticipated to be released this year, noting " with three new 'Aptiv-class' MIPS64 cores being circulated in soft form, a quad-core ARM A15, a Samsung ARM A9 variant, a seriously beefed-up 8-core Intel Itanium and AMD's mobile processors."

Along the lines of "Hey 32 nanometer, where's my 16 cores?", Taco Cowboy notes:
"Intel has been dragging its feet on releasing an 8-core i7 desktop CPU to the users.  It took merely 2 years to upgrade from uni-processor machine to a 4-core CPU, and then it stopped.  It has been 10 years and counting, and there is still no 8-core i7 desktop CPU."

Too right Taco Cowboy. What's more, it's been 15 years since the first affordable dual processor system (Dual Celeron 300a with modded slockets). Intel is the once and future king of serial processor performance, with AMD a distant second, so I suppose it comes as no surprise that Intel is de-emphasizing the role of parallel processing.

What's more, many slashdot readers correctly recognize that, instead of being "radically different", as jd claims, the anticipated processors are merely an evolutionary development of current architectures. (though, to be fair, radical new computer architectures are not easy to invent, let alone productize!). Sponge Bath notes:

"Evolutionary upgrades to intel processors and memory standards, titanium is not dead yet, AMD still can't keep up and ARM rules low power applications. Yes, it will be a landmark year for processors." </sarcasm>

To which TheRaven64 responds:

"I think the news is that MIPS is not dead, it's just pining for the fjords!"


Congratulations TheRaven64, you win Best Slashdot Comment of the Day #4!

Wednesday, May 9, 2012

Mechanical Computers

Some people are surprised to find out that computers can be built from mechanical operations without any electronics.  I would like to some day implement a mechanical computer that can do things people would recognize, like word processing and other things - but getting these things to operate faster than ~10hertz can be tricky.  In addition, if an invalid instruction is programmed into the mechanical processor then it is possible to damage the computer, possibly taking months to repair.  (ouch!)

Here's an example of Charles Babbage's difference engine (invented in the early 1800's), reconstructed with legos, which can be seen operating in a video below.  The difference engine can calculate polynomial functions with sufficient accuracy to approximate non-polynomial functions like logarithm or square root.  These could then be used in a table to look up the approximate results of the function for a certain input.  Considering that slide rules were in common use as recently as the 70's, the difference engine was really ahead of its time.



Perhaps best of all, mechanical computers make mechanical noise - perfect for providing that steampunk atmosphere!



P.S. That picture is from The Guild.  The episode and show are definitely worth watching :-D

Monday, May 7, 2012

Trust & word of mouth

Here's an anecdote about the importance of trust and word of mouth.

Over the last 10 weeks I've had some mobility issues.  I woke up one day and my foot basically no longer worked.  I've had this problem before - it's basically a sprained ankle I get from kicking while I sleep (if this is TMI, feel free to skip the blog post :).  Second, the 2000 Saturn LS I drive (6-cylinder with an excellent second gear) started making terrible knocking sounds and so I parked it and began looking into getting it serviced.  During the process of fixing the Saturn I borrowed my Dad's OptiBike - a really excellent electric bike with a range of ~20 miles per charge.

I never took proper care of my foot which is why it took so long to get better - never went to see the doctor and never stopped wearing sandals.  My bad, but let's move on.

Saturn has no dealerships.  This may not seem like a big deal at first since Chevrolet has taken over servicing Saturns, but what it really means is that there really is no place to go for expert Saturn repairmen - i.e. no place where they say "Yeah, it's normally an extremely rare problem except it happens in this car every 80,000 miles".  Took it to Dave's Auto Repair, which has good reviews and was generally responsive on the phone.  They suspected the timing belt but couldn't be sure - $1500 to replace the timing belt but they could not guarantee it would work afterwards.  No charge for the diagnostic - it was not obvious they had moved the car at all but had probably just listened with the hood open.

About this time the Optibike failed in a cascade of events that led to a twisted chain and front gear that was constantly skipping.  There was no crash, the chain just kept falling off the gear worse and worse until it didn't catch much at all.  This repair took two weeks because Cognition Cyclery changed the chain, saying it should work, and refused to test ride the bike until after I tested it and it continually skipped riding 10 feet in front of the bike shop, leading to special ordering the front gear (which they had said did not need replacing despite my voiced suspicion) - which did not arrive with all of the other parts that had been special ordered because where they had ordered it from did not have it in stock... so it took 12 days to arrive (this part they thought did not need replacing..).  That's not a big deal for a regular bike but taking an expensive bike off the road for two weeks because you didn't check if a part was in stock is not so cool (I checked up on it every 2 days or so, which did not end up helping..).

Around this time we took the car to Mechanica Auto Repair.  They were very responsive and were quite confident (maybe 90%) that the timing belt was the problem, arguing that the engine would have much worse sounds/problems if the timing belt was not the problem, meaning some part of the crank attachment etc. was the problem (the traditional source of a "knocking" sound).  I was less sure than they were that the problem was the timing belt because Dave's auto had been less sure, and the quoted price of... wait for it... $1800... was too much to take the risk.  No charge for the diagnostic.

Next we had a mechanic from Craig's List come listen to it.  He was quite sure it WAS NOT the timing belt and was very hesitant to start the work.  He would have charged as little as $300-$500 (a "Craig's List Special" as it were) but did not want to do the work because of his lack of confidence in the timing belt being the problem - and his lack of confidence of getting paid if the car did not work in the end.  There were some language issues but my wife speaks Spanish so it was no problem.  No charge for the diagnostic - a good experience in general though he seemed to be less experienced than he claimed (no surprise there I guess).

Finally, the bike gets repaired, ending a two week stint in which I had no wheels or feet of my own to speak of (well, the foot was good enough for walks at that point, but that is less dramatic :).  Bike skips just a little bit, every couple minutes or so, and only in certain gears.  Certainly rideable but my Dad, like a soup Nazi, is a perfectionist and wants me to take it back to a different bike shop.  Hard to argue with experience, which, with the Optibike, he has a lot of (I think only two serious accidents </blue commedy>, but I wear a full face masking helmet, so I'll be ok right?).

Lastly, I get advice from a local friend after asking him if he knows of a cost-effective repair shop.  He points me to Mountain View Radiator.  Great experience here, they put the car up on the lift and were certain the sound was coming from under the timing belt cover.  Quoted ~$900, including water pump.  They were 100% confident it was the timing belt, and because their price was the best from a real shop I rolled the dice and OK'd the work.  Picked up the car the next day and it drives perfectly.  Hooray!

The final problem was not in fact the timing belt, which indeed would not normally make a knocking sound, but one of the idler/tensioners for the timing belt, which everyone knows should always be replaced with the timing belt, but are often not replaced by dealerships in order to result in a sooner future repair that will result in more money to the dealership.  I can't say for sure that they were not replaced, but it seems quite likely the original Saturn dealership that replaced the timing belt the first time did not appropriately replace the idler/tensioners along with the timing belt.

All is well that ends well.  Having moved quite a few time in the last 10 years I can easily say one of the most important things is to find a mechanic you trust and that charges fairly.  We found this in White River Junction  when we moved to Dartmouth by calling the local auto parts shop and getting refered to White River Automotive.  You won't find Cory running that shop anymore because the prices were a bit too low and he went out of business (a nice guy running a business can often end up that way.. too bad).  Along with a very forgiving inspection service place (New Hampshire's Live Free Or Die ends with the automotive repair's successful lobby for legally required car inspections I guess), which passed my Jeep with its very rusted underside (I can't name them publicly, they don't deserve any blowback).  A similar story to the one above could have been written for that Jeep which was quoted $2500 by Midas to fix an exhaust leak, which Cory fixed for $60 using a welder.  Ironically, Cory now works for Midas after his auto repair shop went out of business.

Car repair can be merciless for customers and even business owners.  Maybe in a future post I will figure out the proper metaphor for a computer hardware company - but trust and word of mouth are really universally important and perhaps further simplification is unnecessary.

Peace, out!

Sunday, May 6, 2012

Volunteer sysadmins for Mozilla

The open source organization Mozilla is looking for volunteers to help run their servers.  I imagine this would look fantastic on a resume' so for any that could use that or have wanted to get started helping open source this is your friendly "heads up".

Saturday, May 5, 2012

Beware of mixing mrjob & pythonwin

I installed mrjob during an excellent course given at the Hacker Dojo on MapReduce.  I love mrjob (it is great for programming MapReduce in python - try it!), but as soon as I installed it my pythonwin installation (a FANTASTIC editor, because there is intellisense INSIDE the interpreter, and it was the only python interpreter with this feature for a very long time).  Whenever I try to use the "Find" feature I get the error:


struct.error: unpack requires a string argument of length 20
win32ui.error: Error in Command Message handler for command ID 109, Code 0


It is very hard to edit code without the Find feature!  A member at python-forum named basc had the exact same issue back in 2010.  No matter how many times I uninstall/reinstall etc. (and remove old files so the uninstall is as complete as I can make it) the error doesn't go away.  I tried at length again today to fix the installation to no avail.  This really is one of those classic operating system problems we used to get all the time due to register errors back in the 90's, but I haven't had such a resilient OS error in a very long time.  It is enough to make me switch operating systems, but I am truly torn between Mac and Linux (Linux laptop battery life is historically terrible - so a Macbook Air and its incredible 10+ hours of battery life running Linux would lose one of its best features :-(

For now I installed a different version of Python and Pythonwin in a separate location and use that editor for now.  To run things in the old Python installation I'll have to copy/paste my source files, but that is not so bad.

Just a heads up for pythonwin users trying to do MapReduce with mrjob.  If anybody knows how to fix the above problem please leave a comment and I will post a follow-up so Google can find it.

Thursday, May 3, 2012

Useful C reinterpret_cast-like #define's

While starting to write a very large chunk of code with lots of casting I created the following set of #define's which I think anyone trying to perform C++ reinterpret_cast-style functionality will find useful.

//These just set up the regular types with useful mnemonics:

typedef char int8;
typedef char* int8p;
typedef unsigned char uint8;
typedef unsigned char * uint8p;
typedef short int16;
typedef short* int16p;
typedef unsigned short uint16;
typedef unsigned short * uint16p;
typedef int int32;
typedef int* int32p;
typedef unsigned int uint32;
typedef unsigned int * uint32p;
typedef long long int64;
typedef long long* int64p;
typedef unsigned long long uint64;
typedef unsigned long long * uint64p;
typedef float f32;
typedef float* f32p;
typedef double f64;
typedef double* f64p;

//These set up easy casting:


#define cast_uint8 *(uint8p)(void*)&
#define cast_int8 *(int8p)(void*)&
#define cast_uint16 *(uint16p)(void*)&
#define cast_int16 *(int16p)(void*)&
#define cast_uint32 *(uint32p)(void*)&
#define cast_int32 *(int32p)(void*)&
#define cast_uint64 *(uint64p)(void*)&
#define cast_int64 *(int64p)(void*)&
#define cast_f32 *(f32p)(void*)&
#define cast_f64 *(f64p)(void*)&

The above code lets you do things like this (note that 0x4a66666 is hexadecimal of the floating point value "5.2" in IEE 754 format) :


long long a = 0x40a66666;
long long b = 0x40a66666;
long long result;
cast_f64 result = cast_f32 a + cast_f32 b;
printf("result %f\n",result);


The result of the above code is the output "10.4".  We can see that the one line of "cast_f64 result = cast_f32 a + cast_f32 b;" does a lot quite concisely.  We converted from 32-bit integer to single precision floating point using 64-bit integer registers for data storage - and upconvert the result to double precision floating point (This is strangely different from the SystemCrafter synthesizer  which upconverts first using the destination type... probably in an attempt to be helpful). Wikipedia notes that the above code works thanks to x86 using little endian for both integer and floating point, but this is not the case on all architectures so the above code doesn't work everywhere. As with any kind of reinterpret casts, jury rigged C or otherwise, you have to know your hardware.

Note that you have be careful with #define's like this, because if you accidentally type something like:

cast_f64 result = 5.2 cast_f32 b;

you will get a confusing error:
'*' : illegal, right operand has type 'f32p'

This is because the compiler interprets the "*" in our #define as multiplication instead of the unary dereference operator.  These types of errors are why C++ uses templates etc... but one of the greatest programmers I have ever had the pleasure of knowing, Brandyn Webb, helped me appreciate the simplicity of C over the syntactic sugar of C++.  I appreciate C++ and historically have used Python and C++. (It is interesting to note that analysis of Cognitive hardware designs indicate it will do exceedingly well on C++, possibly even better than on C).  Compatibility has become more important in my current role and C is one of the most compatible (i.e. available on arbitrary hardware) programming languages of all time - hence my current attention to it.

Happy programming!  Like riding without training wheels, reinterpret casting is fun but dangerous!

Tuesday, May 1, 2012

Slashdot comments of the day #3

There are some hysterics going on over at Slashdot because a rumor about Hulu requiring a cable subscription is being reported as fact.  Lots of dialogue over whether this would apply to Hulu Plus members, whether it would be implemented soon or take several years, whether Hulu is acting like a cable company pawn because it is scared of being sued, or because it is being controlled by Comcast (which apparently controls NBCUniversal, which owns Hulu in part).

Many in the slashdot community are irate because they hate cable companies, which are seen as charging too much for falsely advertised bandwidth speeds, and generally manipulating the market and people in unfair ways due to a monopoly on what is the only high speed wire available to homes in many cases (was hard not to use First Person there).  Now that you have the setting, you can enjoy:

Ukemike comments:

"Not in a box.
Not with a fox.
Not in a house.
Not with a mouse.
I would not watch it
here or there.
I would not watch it anywhere.
I would not watch cable TV.
I do not like it, no-sir-ee"


BobNet cites this very funny comic: http://theoatmeal.com/comics/game_of_thrones


But the best has got to be this ill-typed comment by Moby Disk:
"People use Hulu because I don't have cable. Isn't that the point?"

To which an Anonymous Coward responded:
"I don't know about anyone else... but I use Hulu and I had no idea whether or not you had cable."