Wednesday, December 25, 2013

The Attack of Temporal Locality

Temporal Locality is an extremely interesting topic in Computer Architecture - something that has fascinated me enough to make me recollect it repeatedly in different contexts, despite not being a great Computer Science Engineer per se.
According to temporal locality,
If at one point in time a particular memory location is referenced, then it is likely that the same location will be referenced again in the near future.
The actual context is memory access in computers - where the objective is to increase data access speed (or reduce time taken to access data, to put it another way) by trying to "predict" where the next data-to-be-accessed would reside. There are 2 broad approaches to do this -
  1. Spatial Locality, i.e. locality of reference based on "location" - or where a particular data is stored. Suppose you are going to Usman Road Pothys to do some shopping. Seeing you're near Duraiswamy subway, you figure you might as well pay a visit to Venkataramana Boli Stall (which lies just on the other side of the subway) and get some Thengaa Poli which you haven't had for a long time. So if your computer were to control the world, once you were at Pothys, it would automatically activate places within, say a 1-2 km radius, with the expectation that you would go there next (Like how Venkataramana Boli Stall is supposed to produce an extra bunch of Thengaa Polis every time the SuperStar makes a visit to Raghavendra Kalyana Mandapam). This, in a gist, is what Spatial Locality is all about.
  2. Temporal Locality is however more intriguing. It is based on "time" or when a particular data was accessed. So going back to our example, according to this concept, if you visited Pothys on 25th December 2013, chances are that you'll visit Pothys or that area within the next couple of days. Now this is both intuitive as well as intriguing. Intuitive because if you go to a particular place, chances are that you might go to that place again. Pothys might be a bad example for an irregular customer, but if you consider your local kirana store or your workplace for that matter, temporal locality works like a charm. Intriguing because of its irrelevance to our example. Why would you keep going to a place, especially if it is far-off, when you can get done things in one go.
Despite its intriguing and possibly questionable efficacy, I am seeing increasing instances of temporal locality in real life.
This past week has been an overdose of temporal locality for me, culminating in a grand finale today.
First was when I'd been to watch the torrid Endrendum Punnagai at Fame Cinemas in Vadapalani on Saturday. The very next day, for a totally different reason, I passed by that place, in a matter of 12 hours, when I live at least 13 km away. Then, to continue the game, temporal locality happened again - the same day, with a different memory location. Sunday I already had plans for the night show of Dhoom-3 at Devi Cinemas. By a queer twist of fate, I ended up going to Tarapore Towers at noon itself, for a different purpose.
Now both these could be dismissed as coincidences, considering I was in an epic break-free mood that weekend anyhow.
But what was most intriguing is what happened today. Just this Saturday (yes, immediately prior to my Endrendum Punnagai experience), I had gone to pick up my vehicle from service - what was noteworthy is that this was the first time I was using my insurance after close to 3 years of owning the vehicle. Though the claim was for reasonably minor repairs, it anyhow wiped out my NCB (No-Claim Bonus). Barely 5 days after my first insurance claim, I met with a minor-but-by-no-means-small accident about 40 km away from the place of my first claim - the first major one for my vehicle. I could almost see temporal locality cocking a snook at spatial locality. The insurance advisor at the service centre who was, by now, familiar with me, could barely suppress a chuckle when I took my vehicle back to him within a week.

Now coming to the actual accident, without ambling along in paragraphs, I'll list a few key points here -
  • The actual moments of impact flew by in slow-motion, almost like this Spiderman scene. In fact, today I could distinctly feel the crunching sound of the glass and there were almost multiple events playing out in front of me in a collision that probably lasted for 2-3 seconds. I've felt it before and I've also had others tell me their accidents to be similarly slo-mo-experiences. If only life in general flew by at such a pace, we'd have so much time to do things. Sigh. This incident anyhow seeked to increase my faith in the belief that during the last few moments of your life, your entire life will be replayed.
  • On the positive front : the immediate moment of impact & some minutes after - there were no thoughts of tweeting/blogging, something I have begun to fear over the past few years. However, after 10 min or so, once reality had sunk in, twitter came to the mind's forefront. Thankfully, live-tweeting didn't happen because of the absence of a data plan.
  • At the police station, this was the picture that greeted me from the Inspector's desk. Enough said. Female simply refuses to refrain from stalking trailing me wherever I go.


  • Needless to say, this was my 1st proper case-based visit to a police station. And any visit to a police station, I assume, is bound to have several stories. Out of the many stories that I was witness to, today, this one took the cake -
    There was this rather pretty girl (ostensibly from the lower middle class) who'd come all alone, to file a case against a guy. What unraveled over the next half-an-hour or so was straight out of a movie. The girl, originally from Karnataka, was settled in TN and was all of 22 years old. She had already been married once (when barely out of college, in her own words) and had exited it in a jiffy. Her divorce papers are apparently due in January. In the meanwhile, she appears to have moved on to the next relationship and going by her own candid admission, had consummated it. The 2nd guy, however, appears to have been in the dark about her 1st marriage and when he came to know of it, promptly backed out of the relationship, despite having done it. Girl then files a rape case against him. Guy attempts suicide. Girl 1.has no father. 2.has come to the station alone, without any relatives, 3.without the knowledge of her mother. Icing on the cake: she is in a relationship with a 3rd guy now, details of which were uncovered by the Police in course of their investigations. Girl asks the Inspector without batting an eyelid "Adhellam ungalukku epdi theriyum sir? Seri, epdiyo therinju pochu, adha vidunga ippo." Me and my parents watched with our mouths agape.
  • Coming back to my story, collision happened with a vegetable-delivery-to-vegetable-shops truck. Most such truck drivers/owners are likely to be associated with some Vanigar Sangam or some such, which, in turn, is likely to be affiliated with some political party. No surprises there. But in Dravidan land, what are the odds that such a driver is affiliated not with any of the Munnetra Kazhagams, not with the Congress, not even with the Communists, but the BJP! My eyes obviously lit up when I got to know of this, but immediately realized that apart from hobnobbing with a few powers-that-be and some wannabes associated with the BJP, on tyutter, there was little (if at all) "influence" I could use, if confronted with the BJP card from the other party.
  • Mistake was on the truck driver's side and damages to my vehicle were reasonably high, while almost zilch for the truck. I didnt realize then that claiming insurance for *my* vehicle using the *truck's insurance* would be such a lengthy, uncertain, difficult procedure, so was content with getting the insurance details from the truck driver. The police, after ascertaining the mistake to be on the truck driver's side, said that even if I did manage to claim damages from the other party's insurance, I'd still have to shell out money from my pocket for depreciation and other charges. Accordingly, they said I should get something from the other party for the expenses I'd have to pay from my pocket. However, kind-old-me was very reluctant to do that, seeing that the other party was not-so-well-off and all that. After much telling-off by the parents and the police, I had to accept the meagre compensation that the other party gave.
  • Fast-forward to the showroom - reality hits me like a ton of bricks.
    1. Claiming insurance from another party's insurance for your vehicle's damages is an inordinately lengthy process that has no guarantee of getting you just compensation, even if you are in the right, even if the police has issued a certificate stating the same. It involves multiple trips to the court by you as well as the other party, and the process has an average completion time of anywhere between 6 months to a year.
    2. I have to go with claiming damages from my own insurance company. Turns out I'll have to shell out at least double the compensation given by the driver, outside of what the insurance covers. After returning home, could distinctly overhear parents discussing "Minimal replacements vechunde ivlo aagardhu, Indha azhai'la indha uttama-putran'ukku kaasu vera vaanga vendaamaam. Unga pulla indha maadhiri paavam ellam paathaan'na velangiduvaan."
There went my rather eventful 2013 Christmas. Merry Christmas everyone!

blog comments powered by Disqus