< October 2005 >
2 3 4 5 6 7 8
Tue, 25 Oct 2005:

When shit happens, it pours. Half of Bangalore is under water (including Residency road). Hosur road is flooded and my bus to Kerala is probably going to be very late (even worse, cancelled).

Photo (c) someone else, I just pasted it from a mail.

All my life, good things and bad things have happened together. Looks like I'm in for a big thumb on the scales this time.

posted at: 18:03 | path: /rants | permalink | Tags:

Mon, 24 Oct 2005:
How many roads must a man walk down,
Before you call him a man?

Dylan wasn't asking a question there. The moment you grow up is when you stop depending on your parents and start depending on your friends instead. You never realize it till one fine day, your parents depend on you for something.

Something happened on Friday, that made me realize that I was now truly the Man of my family. My father no longer had it in him to throw back the slings and arrows of outrageous fortune. Rather than panicking, as I usually do - I found myself thinking very sensibly about what needs to be done and how. There was no phase of denial, no inner to be or not to be - only a vague feeling of anger at someone.

How many times can a man turn his head,
Pretend that he just doesn't see?

Anger is something I'm used to. I like feeling angry - it sort of makes me feel alive. I've used all my anger to do everything I've done so far. It drives me, feeds my fires and keeps me focused. I did so much in life because I was angry of being kicked around as the idiot. I had done so many things in life just because I wanted to prove a point. Sometimes it has been just Because I can. But this wasn't that kind of useful anger.

The feeling was purely selfish. I hated the fact that now I had to be responsible - and cannot be the wild haired wanderer I truly am. But being a Man was all about duties and responsibilties - at least that's what they say. I have to earn, save and more importantly stay alive. The last said is harder for me to do - mainly because my methods of crossing roads or driving can be hardly called safe. Just walk and dodge any cars as they come works for me. I guess the feeling of invulnerability will last till I get hit by a bicycle or something.

Despite my pessimism, I know that everything will soon be as they should be. But that unspoken question hovers in my mind, but I cannot bear to hear an answer. I need the uncertainity, to live in peace, to live in hope - whenever I've tried to peer into the future for answers, it has turned into a self-fulfilling prophecy. I do not want to decide anything - because to decide is to take responsibility. Some of us want to leave their muddy footprints in the sands of time - I want mine washed off in the next wave. That is all I ask of this life - To live, to die and to be forgotten.

To wish for the inevitable is the ultimate fulfilment.

The answer, my friend, is blowin' in the wind
The answer is blowin' in the wind.

posted at: 11:11 | path: /me | permalink | Tags:

Fri, 21 Oct 2005:

But apparently Radek Polak has hacked out a simplistic line step through debugger for pnet. It looks amazingly cool - especially since the video shows the UI working without barely any flicker. After all, anyone can push out amazing screenshots - a work video is teh stuff.

Click to see the demo

All in all some cool work by the chap. And the servers were down for a couple of days - but it's all up and running now. Hopefully the outage wasn't an prelude for things to come.

posted at: 02:21 | path: /dotgnu | permalink | Tags:

Mon, 17 Oct 2005:

Have you ever read about Pavlov's experiments ? Essentially it is the association of one stimuli with a reaction of a totally different stimuli by frequent occurrences of the two stimuli together. I read through an entire book (translated from russian, except for the diagrams) about the experiment in 1998 on a sleepless night. It deals with old problem where the mind creates causation patterns from mere correlation and wires itself up accordingly. A bell ringing has nothing to do with the fact that the dogs get food afterwards - except for validating the theory, that is.

I'm not a dog, still the experiment applies equally well to me - provided my conscious self is not involved. Consider music for instance. The term mood music has often been misused a lot in this world. What mood a particular tune puts you into doesn't have much to do with the actual lyrics or the song patterns - but mostly to nostalgia to what you were doing at that point. Let me qualify and put my tune moods in order, just to make that clear.

When I'm feeling really bad, nothing cheers me up like Eminem with Slim Shady or 8 Mile. A little better and I just switch to Dido - No Angel (the video was just too good) or Lucky Ali's O Sanam . When I want to work, I play Enigma - mainly Return to Innocence, Gravity of Love and Beyond the Invisible. These were songs I used to filter out all background noise, when I used to study at home. These songs have a sort of flow that you can totally ignore and sort of focusses your mind out of the body. You should really experience Deep Hack to know what I'm talking about - your body temperature inverts (sort of) , your head will be running a temperature, while your feet will be experiencing pin-pricks of numbness, hearing (more like feeling) your heart beat and that vein near your neck starts to pulse. It's a rare occurrence - but when you're in there, you can do no wrong - you're the master and the world obeys.

These are reverse associations - which I've exploited to manipulate myself. Some of these are accidental, for example the songs from Sapnay makes me want to draw stuff, which was what I was doing for about two weeks after I bought the tape. Shakira's La Tortura automatically pops up Tin Tin into my head as I read 6 books while that one was in the loop. Un Dos Tres always makes me feel cheerful, because that summer I spent at Cochin with all my cousins and just having a wild time at my uncle's wedding - and my cousins just would keep turning up the volume whenever Ricky Martin came up. My introduction to real rock has been too recent for me to cultivate these unconscious triggers - it doesn't work when you want it to happen (*duh*). But Let It Be or Summer of 69 does kick in those endorphins and get me chillin'.

There are songs which leave me totally blank too. That's my definition of pop - Britney Spears, Christina Aguilera and company. Even stuff like Westlife, Blue, Backstreet and N'Sync. They carry no message for me - they are just sound. Sounds that I like hearing better than silence, but not anything more. Even worse, there are songs that leave me feeling bad or guilty. That's mostly malayalam songs. Stuff like the one in Kireedam - kanneer poovinte kavilil thalodi. Sort of screams disappointment - come to think of it, I can't remember what happened back then.

Anyway this thing often gets in my way. Like, when you go to a party and they're playing some trance - and you pop into that Work Hard (tm) mode. But on the other hand, I passed all my engineering exams where studying was a single night affair only - a One Night Stand with the subject and then dump it. After all, who needs to pop in a Ritalin when you can just pop in a record and get in the mood - that reminds me I need to create a new association for some soft rock ;)

All in all, it just proves how easy it is to manipulate a person using external stimuli without even introducing conscious elements like greed or jealousy. Puts new meaning when you think back to Brave New World : "62,400 repetitions make one truth".

Pavlov's dogs were stupid, but thankfully so are most humans

posted at: 17:00 | path: /me | permalink | Tags:

Sat, 15 Oct 2005:

Before anyone gets grossed out, I'm talking about the third lesson into JIT 101. The first two being :-

  1. You do not talk about JITs
  2. Read lesson #1, again
I committed the cardinal sin last year, when I talked about VM design at LB/2004. I got the rewards as well - the simputer I was planning to demo ran out of battery and just died, half-way into my presentation. Most of the crowd sat through that whole presentation with the hopes of seeing it in action - I didn't have a demo after.

The history aside, the lesson is about a simple feature of a CPU called cache. It is something that isn't even supposed to exist, if you are a programmer. Most people relegate cache to the realms of hardware and therefore never think about a cache while writing their code (which is bad cause it really matters for the last mile). Too many people think link-lists are always better than arrays - even when they are writing code for megahertz cpus (cache optimisations are a totally different book altogether).

Cache is a very important feature of CPU for a JIT programmer, a step below the instruction set and word-size. When you write any data to memory, you are writing to cache and ditto when you read. Most programmers only deal with data reads and writes. Life is not so simple for JIT folks, we write code into memory - a problem usually faced only by the OS loader, otherwise. But ever since the concept of self-modifying code died out, very few CPU designers ever design their instruction sets to accomodate the likes of us. So all we get to work with are a set of instructions to write data to memory via cache (exception being AMD64 which has a few Non Temporal instructions).

So what exactly is the problem if the code written stays on cache ?. For a novice, it'll look as if keeping it in cache will be faster. Is is, if all CPUs used a single cache for both data and instructions. CPUs like PowerPC, ARM, Sparc and IA64 have seperate caches for data and instruction set. It is interesting to note that i386 used a single cache for both and intel is forced to keep backward compatibility with a weird cache system (idiotic thunderbox!!). But AMD64 has it's own quirks which are great if you a performance enthusiast (boy, do I love AMD). Keeping them seperate makes it easier - as the instruction cache is read-only and therefore doesn't need any flush circuitry or checks for write-backs when invalidating. But on the other hand, RISC needed more instructions to feed it's pipeline per clock than CISC does (which might spend a lot of pipeline in operand fetch). All in all, intel screwed up - and IA64 bombed heavily (so did Pentium 4, if you look at how it compares to Pentium-3 archs like Pentium-M for insn per clock performance). Let's not beat that dead horse up here.

So all the binary code that you wrote to memory right now went to a data cache and is held there. When you actually try to execute these, they are pulled from the given address via the instruction cache from main memory. Now do you see the problem ?. But as I said before, OS loaders have the very same problem - so every CPU does have a workaround. It is called a cache flush. Write out your data and then flush the data you wrote back to memory.

Here's how you do it - for PPC (copied from pnet engine).

    while(count > 0)
        /* Flush the data cache (coherence) */
        __asm__ __volatile__ ("dcbf 0,%0" :: "r"(p));
        /* Invalidate the cache lines in the instruction cache */
        __asm__ __volatile__ ("icbi 0,%0" :: "r"(p));
        p += cache_line_size;
        count -= cache_line_size;

    __asm__ __volatile__ ("sync"); 
    __asm__ __volatile__ ("isync");

Of course, it is a costly operation. The sync is a memory ordering instruction (isync is for the instruction pipeline). The cache-line size is the size of the single block read in a single cache read (read: multiples of 8, till it starts working).

The irritating part of the above lesson is that the moment you run unflushed code in gdb, the code works. So if you JIT works inside gdb and SIGILLs outside, make sure you have flushed. I debugged the above code over an ssh-tunnel from office via sshd on port 443, through two squid HTTPS proxies , over which I ssh-ed into a DMZ (metadistribution.org) and into the PPC dev box (sweden, thanks to pvdabeel from Gentoo) - with a latency of over 500ms. And I liked it !!.

Real programmers leave *it* up

posted at: 11:15 | path: /hacks | permalink | Tags:

Episode XXV of the 70's show. So Eric and friends decide to watch a movie. But we weren't to know that when the episode starts. Now, this is how it starts :- Point place, Eric Forman's basement. The galaxy backdrop, the words "The 70's show" appears and disappears into the background. Then the killer !!

After seeing a lot of 70's show over the years (it was shown a lot on Star World's evening comedies), I had an idea about how the episode would proceed. The entire series has hammered the fact into my head that Red (Eric's dad) is the villian - who believes in taking down Eric whenever he steps over the imaginary line of discipline (kids, these days !!). So I imagined that he would be Darth Vader in some way, allowing them to use the obligatory "I am your father" cliche. But as you'll see I was totally wrong.

They threw in a new disposable character - David, the son of the factory manager. A long blond haired hunk, who used to be an asthma cripple in school - and Eric had once kicked his ass on the school playground. In short, he hits on Donna - but in the wrong way. The poetry loving sensitive guy angle to a girl who does write verse, otherwise known as We're just Friends. Oh, and then there's the dream.

Yes, that's right. Eric has a Star Wars (tm) dream. Looking from left to right -

  • Eric - Luke
  • Red (Eric's dad) - Obiwan
  • Steven - Han Solo
  • Donna - Princess Leia
  • David - Darth Vader
  • Kelso - Chewbacca
And obviously in the dream, the light saber won't work. Leia goes along with Darth (at least he didn't say "I am your father" to her and ground her for a month).

Anyway, Eric gets all mad and challenges David to fight with him. Donna gets angry and claims that David and me are just friends and David says No. After Donna exits, David says that "Anyway, it wouldn't have worked. We're moving as soon as dad finishes closing the plant". Eric again gets angry and punches David in his face. David stading there breathing through a broken nose (*swish* ... *hizzz* respirator noises) and then the deep voice from behind the hand. I almost died laughing.

The show has it's unique moments of brilliance - like the Career Day episode. When Steven visits his mother (Edna - the lunch lady) at the cafeteria.

Edna: Steven, why don't you start by slicing these
Steven: No, I'm here strictly as an observer. I'll be like
a fly on the wall (*looks around*) - one of the many.

A good way to pass time - but doesn't compare to the good stuff like Simpsons or Coupling. Maybe it was because that Seventies were over long before I was born :)

posted at: 09:04 | path: /movies | permalink | Tags:

Thu, 13 Oct 2005:

What did you ask for when you joined your current job ? Did you ask for a pay raise that put you above your peers ?. Did you ask for an outrageous 35 days leave per year ? Did you ask for stock options ? Did you ask for a rise in position - did you become manager from being just a tech lead ? Did you ask for better work - more hard-core platform than app development ? Did you ask for easier work hours - 11 to 8 over 9 to 6 ? Did you even think about asking about working from home on monday mornings ?.

Q: Do you have any idea what I asked for ?
A: Nothing.

I gave up a team lead job in Wipro, to join Yahoo ! in a totally different capability, asking for a pay-package which was below what even a fresher was offered (this was offered to an exceptional fresher - but I'm pretty exceptional too). I didn't ask for more leaves, stock options (took what I got by default), took a demotion from module lead to become a mere engineer, didn't get the hard-core platforms stuff I wanted to work on. But I did get better working hours and can technically work from home once I get my net connection and that RSA card. I even got an authorization to work on my open source projects. I was happy.

7+ months have passed by since that day in february. I have done a re-assesment of what I've done here. In those months, I have worked on only one thing which has truly seen the light of day - which is the APC for PHP5. All my other work has gone into hiding, been hijacked or totally open-ended research stuff. Stuff I've done design for is being implemented by strangers (who are barely aware of my existence), other stuff I've done (undergoing much pain and learning a new language - Javascript) is just lying abandoned without moving to production. I'm just sitting in one corner of this huge house being virtually ignored by everyone around. Slowly, I'm developing an apathy towards my job - something which is the antithesis of all I stand for. In short, I'm not really happy.

I wish I was one of those guys who'd consider their job to be done if their bosses have nothing to complain about, the paycheck arrives every month and they can go home feeling happy about playing the system and winning. I'm the kind of guy who gets more of out his job than just money - I want my code to be used, to build something useful for someone (if not for just me), to justify and validate my existence by the things I do. Neglect and apathy is one of the things that just kill my motivation - you could say that my motivation is at rock bottom right now. Obviously that's when you look at what you get from work to justify this kind of death by a thousand cuts approach to my intellect (which has lived a very sheltered life out there in dotgnu). I've got hooked on respect, recognition and that simple feeling of Look ma, no bugs - to give it up for piddling cash, short vacations or flex-time.

Simspons had an episode in which Homer is forced to go back to the power plant and a de-motivation plaque is put on the wall before him which says "Do Not Forget, You Are Here For Ever". Homer had stuck maggie's pics all over the wall till it read "Do It For Her" (the i being start of 'N'). Right now, I don't have anyone to share my work with - not my company, not my co-workers, not the world. Even my open source project is slowly dying out and there's nothing I can do about it - the harder I clasp the more I lose it, like a fist-ful of beach sand.

I've hit a coder's block. I cannot code - I cannot even think in code right now. My brain won't stay focussed - a thing which it has never done before except while on stage. I know for a fact that whatever I write now will be pure bullshit - full of bugs and what not. I can write limericks instead of what were sonnets in the past, quick hacks which take less than an hour - but my work doesn't have any hour long hacks I can start and stop, admire the results and move on. It is the curse of the perfectionist when you lose it and cannot get it back because you are too afraid to face the truth that you aren't as good as you were. Without working very hard, without work pressure, without peer pressure, without enforced overtime - I have burnt out. In hindsight there were ways I could have stepped out, avoided it. The signs were crystal clear - especially in the last month - the hand in bandage, status reports which were partly works of fiction, forgetting documentation details, sleepiness in meetings, general apathy.

Somebody told me it was normal autumn melancholy. Could be true - my body clock now goes on totally differently from the sun or the moon. I just exist in another dimension - the real world just flashes by. I seem to be waiting for the world to make the first move. Hopefully that's not the end.

I just don't care. Whatever

Never look back, the view is never as good.
                  -- About your journey to the crypt, Terry Pratchett

posted at: 16:30 | path: /rants | permalink | Tags:

Do you read any Anne McCaffrey ?. If you have read the Pern series, the Wyrmberg parts of Colour of Magic will just slay you with laughter. I have always maintained that referential humour is much more funnier than the out and out gags. Which is why I like Simpsons more than I like Friends or why I suffer Southpark's vulgarity [read Reductio Ad Absurdum or Simpsons overload - maximum Homerdrive]. Ok, so here's the unique parallel. The dragon lady in Pern is called Lessa, all the male dragon riders have a ' in their names - like F'nor, F'lar. So Discworld's dragon lady are called Liessa, dragon riders called K!sdra, Lie!tt (Dune ref ?). Anyway, I thought the Weyrs of Pern vs Wyrmbrg was too similar to be left alone.

Light Fantastic has wordplay is what I'd call very interesting. Sort of at par with the H2G2 "Like being drunk" quote The part about the talking trees, for example.

'Trees,' said a voice out of the darkness, high above. 
It possessed what can only be described as timbre

Or the intimate knowledge that the author shows about science (a trait shared with the one and only). For example, the knowledge of special relativity in the following paragraph betrays an education in the sciences or at least an interest in them.

And the knife left Trymon's hand at such speed that (because of the 
somewhat sluggish nature of Disc light) it actually grew a bit shorter 
and a little more massive as it plunged, with unerring aim, towards Galder's 

Read relativstic mass and Lorentz Equations for an idea of how complicated the mass and length transformations really are. Though interestingly, at velocities a lot lesser than C, all these equations can be reduced to their Newtonian forms. All of Relativity could be called as a fine-tuning of what Newton put down in his laws.

All in all, nice book to read. I absolutely recommend it to anyone with a night to spare. Just don't miss all these oblique references. Watch out for the one with the rescued virgin, the hardware consultant who's flying in a new stone for the druid's broken circle or the description of trolls (water and rock both) - even the reflected-sounds-of-spirits-underneath.

posted at: 11:40 | path: /books | permalink | Tags:

Wed, 12 Oct 2005:

I headed out to Cochin on saturday night to meet my parents. It was anyway a holiday for my sister till wednesday (who has told me that she keeps a keen eye on this blog), who was also there. All in all the trip was bitter sweet or in true mallu style - "too bitter to swallow and too sweet to spit".

Travelling to cochin always makes me feel happy - for many reasons. Some clever guy has once said that Happiness is not something you experience, it is something you remember. Nostalgia of those days when you could be happy if everyone just left you alone is what keeps taking me back there every once in a while.

The trip started out with a rainy saturday night in Bangalore, where the hero (as in me) started trudging up to madiwala with the one true key safely in his jeans pocket. Reached around 15 minutes earlier and spent those with pretensions of dinner. The bus was supposed to arrive at 8:45 PM, it usually shows up at 9. So there I was with mp3 player plugged in, reading Falling Sideways. The bus finally arrived around at 9:45, nearly an hour later. I ran into an old acquiantace who was the first friendly face I ever saw in hyderabad. Alosh was in the seat just behind mine - we barely talked, except about Benoy leaving Oracle Hyderabad.

Arrived on time at Cochin, having literally flown the distance between Salem and Coimbatore. Father was happy to see me, but pre-occupied with his work - he doesn't like having too many masters too much, especially when some of them are politicians. There was some puja going on, which was essentially a lot of smoke without any mirrors (at least visibly). I stayed out of the smoke cover, unlike my mother who survived the experience on an empty stomach - women are wonderful. In the midst of this, my sister nicked my two Terry Pratchetts (Equal Rites and Sourcery) for my collection back at home.

It had been two months since I had driven anything (except other people mad), but I took out the Honda Dio and cruised cochin roads. It has just stepped out of service and was smooth upto around 80 km/h. Anyway, I managed to get back to the home alive, in one peice and not a fugitive from the law. Most of monday, I spent asleep. I woke up early enough to just get dinner in before shipping back to Bangalore.

If you didn't get the moral of the story yet, let me repeat :

Happiness is not something you experience, it is something you remember.

By those standards, this was nothing to keep notes about. So just forget about, get on with life - We've got a schedule to keep.

posted at: 05:44 | path: /travels | permalink | Tags:

More python magic stuff I ran into today. It's the most convoluted use of argument names to be amazingly flexible. It's a trick on how you can just flow down your init args down a set of factories and whatever. This is how the initial code looked.

class Worker(object):
	def __init__(self, name="", key=""):
		self.name = name
		self.key = key

	def __repr__(self):
		return "working %s <%s>" % (self.name, self.key)

class Driver:
	def __init__(self, worker = Worker, **kw):
		self.worker = worker(**kw)

	def __repr__(self):
		return "drive a %s, mad" % (self.worker)
class Master:
	def __init__(self, **kw):
		self.driver = Driver(**kw)

	def __repr__(self):
		return "I pay to %s" % (self.driver)

print Master(name="Gopal", key="t3")
I get the obvious output from the program: I pay to drive a working Gopal <t3>, mad.

So far, so good. But from now on, I need to grade my workers on the basis of the hardness of their work. So in a totally different module, I start writing the following code:

class GradedWorker(Worker):
	def __init__(self, hardness="very", name="", key=""):
		self.hardness = hardness
		self.name = name
		self.key = key
	def __repr__(self):
		return "%s working %s <%s>" % (self.hardness, self.name, self.key)

print Master(worker=GradedWorker, name="Gopal", key="t3", hardness="very very")

Voila, you have Master invoking the right worker with the right args (hardness) with no change in the original codebase at all. Tell me, how many of you knew you could do something like this with python ?. Now let me explain why I ended up writing this code - or in what codebase I started writing this. I have this WSDL file full of some cool methods, but the methods are accessible only If the HTTP call contains a particular cookie. So I started looking around the internet for a solution.

Activestate aspn didn't have an answer - python lists didn't have answer, sourceforge had a pending patch - which wasn't there in the release. Finally after giving up all hope, I hit the #python irc channel in the hope of some help.

-ChanServ- [#python] Welcome to #python, a support channel for Python programmers! If you're new, please see http://twistedmatrix.com/wiki/python/WelcomeToPoundPython.

Oct 12 01:27:30 *t3rmin4t0r is banging his head on soappy all night
Oct 12 01:27:35 t3rmin4t0r anyone know of any sane python SOAP libs ?
Oct 12 01:29:20 t3rmin4t0r does anyone know of any python SOAP libs ?
Oct 12 01:29:28 t3rmin4t0r or I'm going back to doing it in javascript hell
Oct 12 01:29:58 Erwin          t3rmin4t0r: t3rmin4t0r, meet Google. Google, meet t3rmin4t0r.
Oct 12 01:30:28 t3rmin4t0r none of them support cookies in their SOAP lib
Oct 12 01:30:59 t3rmin4t0r Erwin: it's not like I don't know how to search :)
Oct 12 01:30:33 t3rmin4t0r cannot use ClientCookie or something ...
Oct 12 01:31:25 * t3rmin4t0r realizes he didn't have to come here to hear RTFM ...
Oct 12 01:31:33 * You have left channel #python ("I feel insulted and violated ....")

So here's the solution for the problem ... I couldn't sleep till I figured it out.

import sys, os, string
from SOAPpy import WSDL,HTTPTransport,Config,SOAPAddress
import ClientCookie
import urllib2

Config.cookieJar = ClientCookie.MozillaCookieJar()
# Config.cookieJar.load("cookies.txt")

class CookieTransport(HTTPTransport):
  def call(self, addr, data, namespace, soapaction = None, encoding = None,
    http_proxy = None, config = Config):

    if not isinstance(addr, SOAPAddress):
      addr = SOAPAddress(addr, config)
    cookie_cutter = ClientCookie.HTTPCookieProcessor(config.cookieJar)
    hh = ClientCookie.HTTPHandler()

    # TODO proxy support
    opener = ClientCookie.build_opener(cookie_cutter, hh)

    t = 'text/xml';
    if encoding != None:
      t += '; charset="%s"' % encoding
    opener.addheaders = [("Content-Type", t),
              ("Cookie", "Username=foobar"),
              ("SOAPAction" , "%s" % (soapaction))]
    response = opener.open(addr.proto + "://" + addr.host + addr.path, data)
    data = response.read()

    # get the new namespace
    if namespace is None:
      new_ns = None
      new_ns = self.getNS(namespace, data)

    print '\n' * 4 , '-'*50
    # return response payload
    return data, new_ns

# From xmethods.net

wsdlURL = "http://www.doughughes.net/WebServices/fortune/fortune.cfc?wsdl"

proxy = WSDL.Proxy(wsdlURL, transport = CookieTransport)

print proxy.getFortune()

Sometimes, people just piss me off... But hopefully this should help someone somewhere use SOAPpy with cookie support.

posted at: 03:59 | path: /hacks | permalink | Tags:

Fri, 07 Oct 2005:

First impressions aren't best impressions - but when they are, it is often remarkable. Ever since I sat down and started reading The Hitchiker's Guide to the Galaxy, the first page was gripping and totally off-topic - the part about the girl in Rickmansworth, nearly two thousand years after one man got nailed to a tree ... I just picked up Colour of Magic and opened the cover - there it was, the excellent words to which I fell in love at first sight.

In a distant and second-hand set of dimensions, in
an astral plane that was never meant to fly, the
curling star-mists waver and part . . .

Great A'Tuin the turtle comes, swimming slowly
through the interstellar gulf, hydrogen frost on his
ponderous limbs, his huge and ancient shell pocked

Astropsychology has been, as yet, unable to
establish what they think about.

There was, for example, the theory that A'Tuin
had come from nowhere and would continue at a
uniform crawl, or steady gait, into nowhere, for all
time. This theory was popular among academics.

An alternative, favoured by those of a religious
persuasion, was that A'Tuin was crawling from
the Birthplace to the Time of Mating, as were all
the stars in the sky which were, obviously, also
carried by giant turtles. When they arrived they
would briefly and passionately mate, for the first
and only time, and from that fiery union new
turtles would be born to carry a new pattern of
worlds. This was known as the Big Bang 

Yes, the Big Bang hypothesis. It is these kinds of off-hand sideways (yes, I mean oblique) references that takes up these books from Excellent Reading to Excellent Re-Reading. So here I am, starting on a Discworld read-a-thon. I plan to read each and every one of those 27 books over the next month - in sequence. I have already read Sourceror and Equal Rites (which I picked up by mistake - lucky me).

Precisely why all the above should be so is not clear, but
goes some way to explain why, on the disc, the Gods are
not so much worshipped as blamed.

I wish I could stay and quote more - but if really liked it, why not just get the whole book and read it - just don't visit the Counterweight Continent.

- Wizzard

I shall go forth and multiply fractions

posted at: 18:30 | path: /books | permalink | Tags:

Thu, 06 Oct 2005:

I ran into two interesting concepts today. The first one was called Loss Leaders. For example Microsoft Internet Explorer is a loss leader, which is being given away at a huge loss, just so that Microsoft can keep some tabs on the direction and future of the Web (which is not the internet). Another example would be all these Google or Yahoo! betas, which don't make money by themselves - but build a sort of customer relationship (euphemism for lock in).

The other concept was the Trial Balloon, in connection with the announcement of the PlayOnce DVD. Slashdot is being used as a thermometer in a bath, both by lots of people these days. Especially to measure blogger opinionations about a particular topic. Seems to work really nicely along with plausible deniability - Google browser is an excellent example :)

Always two there are, no more, no less: a master and an apprentice

posted at: 18:34 | path: /misc | permalink | Tags:

Tue, 04 Oct 2005:

This is some code I re-did for lawgon, while on IRC. This one dates to the time I was trying to get BitTorrent to tunnel over HTTP and ran into trouble figuring out which function is called by what. This is not as good as the original version - but this is quite good if you want to debug python without putting too many print statements :)

import sys 

def tracer (frame, event, arg):
    if event == "call":
        print "%s() --> from %s:%d" % (frame.f_code.co_name, frame.f_back.f_code.co_filename, frame.f_back.f_lineno)

def fact(i):
    if(i == 1):
        return 1
    return fact(i-1) * i


def main():
    print fact(9)

This is by no means original code and shouldn't be misunderstood to be my invention. If you want, you could try playing around with frame.f_globals["__file__"] or __module__. I think you could even hack in linecache to build a debugger of sorts. Python rocks !!

* If you see this blog rockin', don't come a knockin'

posted at: 18:43 | path: /hacks | permalink | Tags:

Over the weekend, me and abhi hacked up the unroller for AMD64 instruction set. The instruction set is very similar to the x86 - so we just took the x86 unroller and are slowly pushing our way into modding it to work for 64 bit. md_amd64.h is already in CVS. The unroller is not enabled yet.

I am still having problems with some (int) casts in the code-base. AMD64 has 32 bit integers, 64 bit words and 64 bit pointers. Also the byte addressing logic is absolutely screwed, which makes it very hard to access a byte[] array properly without needing to waste space on padding. The register allocation ordering was swapped around to -

  1. RAX
  2. RCX
  3. RBP
  4. RBX
  5. RDX
  6. RSI
  7. RDI

The RBP was promoted up the order, though not really made use of properly. Ideally, the effect of that will kick in when we have the array opcodes done up. The benchmarks are promising already. Pnetmark scores are up from 1608 to 4210 after just two days of work (very very hard work).

I think it'll take around a week more to finish the unroller. This is the advantage that full JITs don't have - I can already test out the unroller fully by just commenting out the TODO areas and letting the interpreter handle those opcodes. Mixed mode execution is the holy grail of easy optimisation.

The null check elimination has to be re-done for AMD64. The system relies on catching the SIGSEGV, instead of doing an if(NULL ==) check, using signals and using sys/ucontext.h to figure out the registers. From that we work backward to find the the exception handler and jump there. Amazingly complicated code from tum, but works like a wonder. I need to understand how that works before I can re-implement it for this new CPU. It does wonders for your object access code - makes it faster than C with null checks.

The FPU code fox x87 would work for amd64 as well, I suppose. Might not need too many mods - far less compared to the other stuff that uses void * arithmetic. I'm tired of pushing bits right, right, right and then adding the regs. X86 is teh suck for us binary programmers.

If code is poetry, I write limericks.

posted at: 11:10 | path: /dotgnu | permalink | Tags:

Mon, 03 Oct 2005:

Gimme a break, who takes these stupid tests to actually test their nerdiness anyway. Needless to say, being a Geek I couldn't resist taking the test and even more needless to say - finished it. Curiosity killed the cat, so to speak - I stand classified as a Nerd God, instead of being the Geek God that I always wanted to be. Stereotypes are teh suck.

I am nerdier than 97% of all people. Are you nerdier? Click here to find out!

After all, I was a chemistry geek to start with ... and I know most scientists by their photographs. I have a photographic memory, the kind which remembers only pictures, not the actual text in it - I can probably remember the layout of my 10th standard history textbook which talks about World War II, but not about exactly what was written about it (or the dates).

posted at: 18:44 | path: /rants | permalink | Tags:

I think a little context is necessary before I embark on this rant. You could stick around and figure out who (Freud isn't) said the infamous 'is bunk' as was liberally quoted in Brave New World. On the other hand, you could just read on. This should be educational even if you disagree with me.

I re-re-read Axelrod's Evolution of Co-operation over the weekend. The book talks about why humans in a social situation co-operate instead of systematically screwing others. The book also deals with how simple selfish evolution makes sure that helping others would be helping themselves. In short, it explains why you might help someone instead of giving him the finger and exactly when you are likely to do the opposite.

For co-operation to evolve, there are two things necessary.

  • Induvidual recognition
  • Long term memory
First of all, you have to recognize the other induvidual you are dealing with, secondly you have to remember the result or experience during your last encounter with the particular induvidual. These two are the basic blocks needed to build co-operation into a group of such induviduals (remember this when you reach the ending paragraphs).

The next rule of the game is easily visible in a simple game called Prisoner's Dillema. The game is very simple, there are two players who can each chose to DEFECT or COOPERATE. If both players co-operate they win more than if one had defected. Defections from both sides gives more rewards than if your opponent defected while you were co-operating. Let's put some numbers on that.

Co-op  | Co-op  ==  200  |  200
Defect | Co-op  ==  100  | -200
Co-op  | Defect == -200  |  100
Defect | Defect ==   50  |   50

So eventhough the two players are likely to win more if they co-operated, they stand to lose if the other person defects against him. Basic probability theory states that to avoid losing you have to always defect. Notice that this is a Non-Zero Sum game, both players can win at the expense of the banker (or me - who's paying out/collecting points). But the simple mistrust between the two players might prevent them from co-operating in a single game of Prisoner's Dilemma.

Now, let's take this up a notch. We're having multiple rounds of the game with the same two players. It is worth noting that these two players are held incommunicado and do not know what the other person is likely to play next. But if we tell these guys that we're having a 100 round game of Prisoner's Dilemma, 100th game is the same as the single version. Since they already are going to defect in the last, it virtually becomes a game of 99 rounds and so forth. Essentially if they had any idea of when the game's going to end, it's virtually a single game in terms of analysis.

Now, what if they have no idea when the game is going to end ?. Then they won't be able to predict behavior of the opponent in any manner. This is exactly when co-operation can be built up. A defection will or can be responded with retaliation by defection from other side, in a following move. Sure, you can continue defecting and play safe, but that's a dead end strategy in the entire game plan. On the other hand co-operation from the opponent starts of a similar cycle where trust is built up, until one of you decides to defect again.

To actually test this theory Axelrod called for programs which have a given method which will return the next move when fed with the current move of the other player (which is also a program). These programs played against each other for an unspecified but constant number of runs. Guess which program got the most number of points ?. It was a simple Tit-for-Tat program (5 lines !!!) which won the tournament. The program just had a return opponent_move; which survived against a variety of opponents and even in a population of its own.

Ok, so my point was that the most successful form of co-operation features a threat of retaliation. So once there is no threat of retaliation, your opponent is likely to defect. This is essentially what I meant by the last move in the known round situation.

Scarily, this is very closely followed in a lot of places as stated. For example, look at what happened during Katrina in New Orleans. There will be a small (or even large) population who do not commit crimes (do not DEFECT) due to the deterrence of retaliation (execution for murders, siezure of property for fraud). This group of induviduals do not DEFECT because they have no idea when the game ends and co-operating right now seems to be the more profitable option. Make the game of one round only (when threat of death is near for example), these cheerful souls will happily defect and leave the co-operating population poorer and feeling foolish by some. If that wasn't bad enough, the only way to survive in a one round game is to defect yourself as well. Before you know everyone around is in I got mine. So, f*** you ! mode. The foundations of society viz Co-operation has broken down.

Ever since basic society evolved from purely selfish motives, we humans have fought against the basic evolutionary urges - kill your neighbour and covet his wife, steal his money and buy better food for your children, leave him hungry if you find him starving - all of which improves your immediate evolutionary future. Thanks to the basic threat of retaliation, we have stopped short of mutual destruction - but we have gone further to build something into our conscious brain which enforces wholly imaginary retaliation from inside when violated. In short, we have invented Guilt.

You only feel guilty for what you think you've done wrong. Integrity is that one bit which actually defines what you think is wrong and what is not. Cheating in an exam is wrong for some, while it's absolutely OK for some others (watch Lisa gets an A). It is a purely personal standpoint and then there are gray areas.

Finally, let me get to the point. How do you keep lazy people honest and productive members of society ?. You make sure that it takes more effort than just a guilty conscience to steal/cheat and on top of that pile consequences to weed out the really stupid who finally do attempt. You put locks on your stuff so that it doesn't get stolen. It is a sort of arms race which selects better and more careful owners while breeding a new generation of better theives as well. A better mousetrap always ensures a better mouse as a by-product - fewer of them in the short term maybe, but only the fittest survive. Evolution is simply beautiful.

Morover, to select for better owners the owner has to have some say in the strategy he follows - in other words, Responsibility for screw-ups, Credit for successes. In other words, induviduality. Unfortunately this is not where my bit of world is headed - You will be assimilated, Resistance is futile.

Most of the world has little choice on whom it welcomes in. Citizens are born into citizenhood, not confirmed after an integrity check up after the age of majority. The place where this particular problem doesn't apply is in the corporate world. Any company hiring, has a face-to-face interview where the person's teamwork and personality are reviewed. Unfortunately, the little time that was spent with the person might have been about whether the chap gets paid 5 lakhs or 5.2, instead of examining his priorities in life - God, Family, Career, Money. Most clubs faced with a similar situation goes for a peer review rather depend on the evaluation of a single induvidual. Black-balling is a simple strategy to ensure that the people being admitted into a club are of compatible, at least superficially, to the majority. The essential problem with majority votes being that people are sheep - most people don't actually have any strong preferences. They don't protest, they don't speak out, they just sit tight, think as a mob and irrationally hope it all gets better.

Silence is often Golden - fate of those who speak out are often worse. Herman Goering has so insightfully commented on human nature - All you have to do is to convince that they are being attacked and these new steps are for their protection - denouncing any opposers as being unpatriotic. Think of the PATRIOT act in US and the TERRORIST act in the UK. Why exactly would I oppose the PATRIOT act ?. Unless I wasn't ... You get the idea, don't you ?.

I will not approve of any law based on an assumption of crime and prevention of the afore-mentioned crime. I will suffer it, if only for the sake of my daily bread, shelter and survival. I will not celebrate it as a positive act of prevention. I will not enjoy it, nor will I want to afflict it on one of my own without adequate warning. I will not neglect the rules, but neither will I ignore them. There is much evil in this world worse than the indifference of a good man.

These are my principles. These are not for sale. They are not negotiable. They are what I didn't carry from my cradle, but what I will carry to my grave. They were not mine to create, but are mine to destroy. They are why I said No, they are why I said Yes. They shall live on, long past I'm gone, to serve as a beacon or warning, I know not what. Call them what you want - Religion, Truth, Love, Philosophy - but they are.

* the sleep of the Just and rest of the Valorous

posted at: 02:19 | path: /rants | permalink | Tags: