Case of the mysterious slow down

About 1 month ago my Alienware suddenly slowed down. Like really really bad slow down. To the point where Firefox would take ages to open the landing page.

Now I had attributed this to Firefox itself being slow as was reported elsewhere but something did not feel right. Switching windows (Alt+Tab) to a regular terminal would also be terribly slow. Like ~5secs to just switch. This certainly cannot be just be Firefox tossing it up, can it?

1. Rule things in and rule things out
So I decided to dig. First off “top” indicated ~100% CPU consumption. So something’s consuming all of the 4 cores. It was always Firefox. I tried different websites, including Youtube, WordPress, Reddit. It produced similar results. So I decided to try Chrome and it was darn near similar. Then tried other applications. I deliberate avoided Libreoffice as it might genuinely be a slow application. VLC tends to be low on CPU but reasonably high on GPU consumption. Even VLC had a similar behaviour. What this told me was that the whole system was running dog slow.

2. So is it a CPU problem or something else?
To test this theory I checked if it was just the CPU or if the GPU was also behaving similarly. A quick OpenGL program with a dull CPU usage but high fragment shader usage ruled the GPU out. The CPU was still pegging although not all the cores. So then I checked the disk I/O and it was fairly inexistent. No issue with RAM consumption as it was always <50%.

3. So is it malicious?
Around the same time I was reading about compromised systems. This bothered me as it could mean something really really nasty. I know, I made a leap based on nothing but it was worth ruling out. Thankfully Linux Mint makes this rather simple. My /home is on a separate partition so all it meant was wiping out the /, reinstalling the OS, creating a dummy account, and retesting. Took about 20 mins to do all of this. Nope still slow. So either this was really really deep or I need to stop heading down this path. I decided to stop.

4. Is it hardware?
Power settings could lead to this kind of a behaviour. So would heat protection if it decided to kick in. I checked the cpu governer and forced set it to “performance” mode. Along side I opened up the laptop and cleaned up all the dust because the CPU temperature was hovering at 65C. Not too hot yet, but might as well bring it down. This definitely helped and brought it down to 45C on peak 100% count. I was prepared to open the CPU heat sink up and apply a dab of thermal grease but decided against it as it is better to first verify if the heating issue was from constricted airflow or if it was from thermal flow resistance. Anyway not opening up the heatsink was the right call.

5. Is it still the hardware?
Now that i ruled almost everything else out, I wanted to pay closer attention to the CPU itself. Since neither Firefox nor Chrome are applications that would have serious performance bugs, I wondered if there was something else going on. This is when I started paying closer attention to the cpufreq toolchain.

I paid close attention to the output.
$ cpufreq-info

analyzing CPU 3:
driver: intel_pstate
CPUs which run at the same hardware frequency: 3
CPUs which need to have their frequency coordinated by software: 3
maximum transition latency: 0.97 ms.
hardware limits: 800 MHz – 2.90 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 800 MHz and 2.90 GHz.
The governor “powersave” may decide which speed to use
within this range.
current CPU frequency is 870 MHz.

AT the same time I noticed that the CPU was pegged at 100%.

Here comes the AHA! moment. While the OS correctly recognised the CPU frequency range, it was reporting the current CPU frequency to be 870MHz. Way below what it should be set to given the 100% consumption. That got me thinking. What could this mean? I tried to force set the frequency to 2.90 GHz but it would ignore this. This was the second AHA! moment. So the OS doesn’t seem to have the ability to set the frequency. Now who could do that? The CPU itself, the power settings, the thermal settings or something else? I’ve ruled the CPU being a problem, the power settings, and the thermal settings purely by coincidence during the earlier steps. So what could it be? Maybe something lower than the OS – the BIOS.

6. It is the hardware, but not the way I thought.
So I went into the BIOS, checked he Intel Speed Step and disabled it. Restarted. No change. I then decided to just follow IT Crowd philosophy. I reset to defaults.

7. Eureka!
… AND I got a warning when I started the laptop. What I saw was this message:
But I was using the Alienware adapter. What the hell is it on about? None of the resolutions listed on the page made any sense. No wait.
“The AC adapter is not fully connected to the system.” Huh? Are you essentially saying a loose contact? Wait what?
So I started twisting the cable and restarting to see if it made any difference. And it did! If I held the wire straight out I didn’t see the warning message. So inspired by MacGyver I came up with a way to hold it in place. Also reminded me of the TV antenna vaastu orientation.

You can see how it looks now at the end of the post.

8. And we have a winner!
With the binder clips holding the cable and no warnings in my face, I restarted the system. It worked. It damn worked. Everything was back to the speeds to which I was accustomed. Now granted this whole binder clip setup is a hack. The true problem, quite possibly, is that I have a loose solder joint somewhere.

In Summary.
1. MacGyverism is a way of life
2. Thermal characteristics hurt performance. Spring cleaning is valuable
3. Never ignore warnings. Hardware or Compiler doesn’t matter
4. Not all Eureka moments involve water, a bath tub, and a naked guy running out into the streets




The Car is an Engine

Over the past few weeks I worked on my 2008 Nissan Maxima. While I had changed the spark plugs late in 2015, I never thought about publishing a post on the experience.

I am a Software Engineering Manager and a Programmer. One of the patterns in writing programs is Object Oriented Programming. Almost every book on OOPS starts off with the Car, Vehicle, and Engine analogy. Hence my interest in posting this. Here I am listing a few lessons I learned from fixing my car. Read this keeping Software Engineering in mind and you’ll see a completely different spectrum.

  1. Use the manuals for truth. Use other sources for context. Use a wrench for experience. I rely on the Nissan manual for a Maxima. It contains the absolute truth as seen by the Maxima designers. However, forums like My6thGen have been an unbelievably valuable sources for research. Pictures posted by members have in many cases helped me figure out the orientations. Eric the Car Guy, for me, is the John Carmack of cars. However the best teacher is holding that wrench and getting to work, much like in Programming. This became evident for torque specs, for the angles my fingers could not fit, and the fact that I had to create chimeras out of my limited tools.
  2. Plan, Plan, Prepare, and Execute. Following the manuals and the videos is good but at the end of the day you need the tools, materials, and the parts to get the job done. In many cases I had to order the parts from online stores like Rockauto and Courtesy Parts. That meant shipping and it inturn meant preparing slots of 3-4 hrs over the weekend. This in turn meant I needed to clear weekends off of grocery shopping. It is extremely important to plan the parts, the tools, and fluids into the schedule. Once you have the parts it is time to prepare and this becomes critical. Prepare yourself with the steps that need to be executed before you execute them. Unlike programming an undo or revert generally involves a tow truck and that is painful and expensive. Once we start executing the only way is forward. There is no undo and I cannot stress this enough. This became extremely important when I was replacing the Clockspring/Spiral cable. Since the job involved taking out the air bag on the steering wheel, I had to pay extreme attention to discharging the battery, ensuring I am always electrically grounded, and storing the air bag in a safe place. I ended up researching, planning, and rehearsing for close to 3 days before I even started the job.
  3. Following the earlier point, all the planning in the world won’t prepare you for the surprises. Accept it, and deal with it when they occur. Working on cars, or for that matter software, bring experience. The difference between an newbie (I was) and a pro (I am not yet) is that a pro commits far fewer mistakes than a newbie. A pro will also be able to quickly adjust to surprises that jump at you. One such experience I had was when I was trying to replace the regulator on my driver side window. There was a bolt I had to put back and it was painful to get it into the slot. My fingers wouldn’t reach in, and the socket wouldn’t hold it due to the angle. Worse yet, when the bolt fell into the door assembly it was hard to retrieve it. So the second time the bolt fell into the door chamber I stepped back and had to solve this problem. I tried with a magnet but that wouldn’t work as the door is made of metal. Finally I solved this by using tissue paper. Apparently this is a well known trick, so yeah I reinvented the wheel. It felt good.
  4. Tools. Oh God! Tools. Invest in a good collection. I own a Craftsman set. I then expanded it by buying a few extensions, swivels, spark plug socket, and a few hex bits. The number of times I’ve missed a ratcheting wrench has been fairly limited but I know that when it becomes painful I’ll buy a set. Tools generally make you efficient. As I mentioned in the earlier point, not all tools are manufactured or ready made. Some, like the tissue paper trick, come from experience. Do not be defined by your tools. You can swear by Craftsman or Snap-On but on any given day all they do is turn a bolt only when you use the them.
  5. Contingency plans. Have fun without contingency plans. And then have fun when an event defies you Plan A, Plan B,… Plan Z extended to UTF-8. All the plans you make, including contingency plans, will be shattered. The ones that did not get shattered are the ones you had planned for. Keeping this in mind make sure to think things through. For example when I was changing the CVT fluid, the brand new oil collection pan I bought as Plan A, had its drain hole plugged. Not knowing this I ended up with some fluid on the floor due to the oil overflowing. I had a Plan B and it involved cardboard sheets on the floor. Plan C involved rolls of tissues. What finally happened? The oil was hot and I could not get everything covered in time. Since some of the oil ended up on the floor, I had to find out how to fix the mess. Turns out Kitty litter is an answer. A generous amount of degreaser, and a trip to Walmart to get some Kitty litter fixed the problem. The floor is clean. Had I not made the Plan B and Plan C, I’d have been spending a lot more time cleaning the garage floor.
  6. DIY for best results. I can relate to this as I am a manager. There are too many instances where I was frustrated with the code or the output but at the end of it, if I want something done to my satisfaction I should be ready to do it myself. Else it is a conscious trade-off between priorities. Sometime ago when I was visiting my brother during the Winter, my Maxima had its driver side window just roll down and not roll up. My brother did not have any reasonable tools on hand and didn’t have a garage to work in. So I did the next best thing – took it a mechanic. Two infact. $200 later, I still had a non functioning window. Since I had to drive back I ended up sticking the glass with Gorilla tape and painters tape. The drive back was a nightmare for 10 hrs with the wind howling in my left ear. I can relate to Gollum now. Anyway at the end of it, once I returned home I ordered the parts from Rockauto and fixed it in 1 hr. The correct way. Which loops back to the first point.

I hope this little write up, taken in two contexts, conveys my philosophy in working on cars and in writing code. I’ll conclude this by saying that my brother would rather buy a car someone else can fix easily and is willing to pay the price for it. You know, not everyone wants to be a mechanic and not everyone wants to be a programmer.


Credits/Thanks to:

Lameo from work for being a great teacher

My wife for Kitty litter trick

My Son for making me think through every step by explaining it to him


John Carmack for well you know


I just realised that I’ve been posting more on Twitter than on my blog. Must fix this.

Anyway lately I’ve change the things that pull me. Considering the crazy cold weather here I had decided to make the most of the warm weather and perform some physically taxing activities. Included are taking the kids for a walk and having to chase them.

More than that I started and for the first time in my life actually worked on cars. Yes. Cars. Something that very few folks from Software world would imagine although the first things in OOPS is the car analogy. I can say with reasonable amount of confidence, that the analogy is based on simplifying the problem domain and I do not think the analogy answers questions appropriately anymore.

I purchased a 2008 Maxima and it had significant hail damage. I am not fixing any of the damage. It is a high value car for the simple reason that its powertrain is in a good shape and it is the last of the 6th generation Maximas. The engine VQ35E is pretty much bullet proof and best of all has a timing chain.

Lam, a colleague at work, knows his way around a car. I am quite lucky to have spotted him and he’s mentored me in quite a few aspects around the car. With Youtube for theory and Lam for reviewing my work I managed to work on quite a few pieces including wheel bearing hub, rotors, brake pads, electrical work on the window, inner fender liner and a bunch of other pieces. More importantly I mustered up enough courage to help Rakesh, another colleague, replace his serpentine belt. This means a lot to me and sometime after this Winter I’d like to get going with a proper engine swap or even better an engine rebuild. Hopefully on a Subaru as I love those cars.