What are your problems?


I had an interesting coffee conversation with someone a couple of days ago. We started talking about general interests, work, life, philosophies, struggles, etc.

As most conversations proceed, we took turns talking about “our stories”. At the end though, the person told me that their brother has muscular dystrophy (https://www.cdc.gov/ncbddd/musculardystrophy/). This can happen when someone inherits a faulty gene from one or both parents.

The person went on to tell me that their parents already know that their son is probably never going to find a partner because of their condition, never will be able to lead a “normal” life, and that, when they compare this problem with some of the other ones that they have, everything else feels small and insignificant.

This story has stuck with me since then. Not that I didn’t already know similar stories but sometimes you need a reminder. A reminder to be SO THANKFUL for all the things that I have. A reminder that I am privileged. A reminder that I have an amazing family. A reminder that I have some really good friends. A reminder that I have more than I need. A reminder that I need to stop worrying about small things because guess what? Everything is small until you face the real, big challenges of life.

Are you “intelligent”?


tl;drA lot of us need to stop generalizing “intelligence” as a factor of only being good at science and/or analytical problem solving.


There are multiple theories around what is “intelligence” and who is considered an “intelligent” person. The word “intelligent” can be replaced by other words like “smart”, “intellectual”, “sharp”, “canny” etc. but that doesn’t change the point I am trying to make here. Growing up in India, I have seen people looking up to people who are good at Mathematics, for example, but not so much if you excel at arts. And while this prejudice might be more prevalent in some countries than others, it undoubtedly exists across the world.

In 1983, Howard E Gardner, a professor at the Harvard Graduate School of Education wrote a book called “Frames of Mind: The Theory of Multiple Intelligences” [1]. While his work is still argued by some psychologists and academicians as is the case with most theories, it is still regarded as one of the pioneer works done in the field of differentiating human intelligence.

Below are the 8 types of human intelligence as defined by Howard in his book that I have paraphrased and intentionally kept concise. But if you are interested in learning more about it, grab his latest book and give it a go!


1. Visual-Spatial intelligence – are you good at putting puzzles together? Can you interpret charts and graphs well? Do you enjoy drawing and painting?

2. Bodily-Kinesthetic intelligence – are you skilled at dancing or sports? Do you remember things by doing rather than seeing or hearing? Do you like to create things with your hands?

3. Linguistic-Verbal intelligence – do you like writing stories? Can you memorize stuff easily? Are you good at debating and/or giving persuasive speeches?

4. Musical intelligence – do you like to play musical instruments or enjoy singing? Can you remember songs and melodies without much effort? Are you able to recognize musical patterns and notes easily?

5. Naturalistic intelligence – do you like being near nature camping or hiking? Are you interested in learning about other species? Do you find it easy to find patterns and relationships to nature?

6. Interpersonal intelligence – can you communicate well both verbally and in writing? Are you good at assessing emotions/motivations/intentions of people around you? Can you see situations from different perspectives?

7. Intrapersonal intelligence – are you good at self reflecting and being aware of your own emotional state and feelings? Do you enjoy exploring relationships with others? Are you good at analyzing theories and ideas?

8. Logical-Mathematical intelligence – are you good with numbers? Can you recognize patterns easily? Do you enjoy thinking about abstract ideas?


One can be considered “intelligent” in multiple fields and you might have a higher chance of being “successful” at something that comes more naturally to you, both professionally and personally. And I would even go to the extent of saying that, in my opinion, being aware of different kinds of intelligence can also help build more meaningful relationships with people around you.

Enough knowledge sharing for now and congrats if you made it this far in the post. And cheers to being more “intelligent” 🙂

[1]Gardner, Howard E. Frames of mind: The theory of multiple intelligences. Hachette Uk, 2011.

Amazing people do exist!


I had an awesome experience with one hell of an amazing person last night that I feel needs to be shared so here it is.

Me and a group of friends decided to visit Goldmyer Hot Springs yesterday. If you don’t know where that is, you can read more about it here – LINK. It was supposed to be an overnight camping trip. The only caveat being that it is almost a nightmare to reach there during this time especially when the last 12 miles of the road is unpaved with about 16 inches of fresh and old snow.

We decided to rent a big ass powerful AWD Jeep that had snow tires and bought most (“most” is an important thing to note here) of the supplies advised by the Goldmyer volunteers that included carrying an axe and a snow shovel.

The trip seemed to be going alright for the first 6-7 miles. There was about 12-16 inches of snow on the unpaved road that barely could accommodate a single car going forward although it was supposed to be a two way road. We encountered a few fallen tree branches and were driving at around 10 mph but it was going alright until we encountered a big fallen tree that couldn’t be jumped. We started using the axe we had to cut through it but after spending several hours on it and barely making any progress, we decided to give up on the axe.

One of us came up with the idea of making a snow ramp around the fallen tree so that it would look like a big speed breaker and the car would just go over it. BAD IDEA. Don’t do this if you ever get stuck in a situation like that. We spent several hours accumulating the snow and trying several times to make our car go over it but failed. On the last attempt of doing that though, the car got stuck on top of the fallen tree in a way that the front two tires were on the other side of the tree while the axle of the tire was stuck on the top of the fallen tree.

We tried everything that we could to get unstuck including going in reverse and forward but nothing worked. The tires didn’t have any traction since the car’s front axle was stuck on top of the tree. At this time, it was getting dark since the sun sets around 5PM. And did I tell you that it also started snowing? It was cold as hell and all of us were almost freezing. That’s when it hit us that we needed help!

Luckily, my phone had a network (Verizon is the best in the US!) so I started calling towing companies. I think I called about 10 towing companies and 9 of them turned us down because of the snowy conditions and how remotely we were located. The one towing company that decided to come help us out also took a u-turn when they encountered lots of snow on the road. Bad luck!

At this point, around 9PM, we realized that we might be spending the night in the car or setting up tents on the road. Then I saw a car coming behind and OMG, were we excited? We all thought that Ron from the towing company had somehow managed to come through.

We got out of the car and I said, “Hey Ron!” He didn’t answer. He came to us and saw that we were stuck. He went back to his car and got a chainsaw and started cutting through the tree. He had all the proper tools and seemed like he knew what he was doing. At one point he told all of us, “Just stay 10 feet away from me while I am using my chainsaw. I don’t want any accidents”. So we all were sitting in the car and he was just working on cutting through the tree. Once he was done with that, he started working on the part of the tree that was under the car on which the car axle was stuck. But this was the tricky part because there was no easy way to access it since there was so much snow under the car (remember we were trying to make a snow ramp?). He was literally lying on the ground covered with snow trying to somehow access the tree under the car. My friends and I were helping him by clearing as much snow as we could and picking up the logs of wood that he was cutting. He broke his chain once in the process because it touched metal. This guy was thoroughly covered under snow and wood dust and didn’t complain even once!

After spending about 3-4 hours working with us, we finally were able to get the car unstuck when he used his own car to pull us out after cutting through the tree on which the car’s axle was stuck. He then also helped us reverse the car for about a mile since there was no way for us to make a u-turn till we reached one of the turns. We all profusely thanked him and I told him that it is so amazing to have met a person like him today who helped us selflessly without asking for anything in return. We ended up giving him whatever cash we had although he hadn’t asked for it and I also took his information so that we could send him a check and a thank you note later.

The guy who helped us goes by the name of Bill Davis and is 79 years old. He retired from the Seattle Mountain Rescue team and lives in North Bend. Go Bill! You are AWESOME and one of the most wonderful people I have ever met!

One of the things that Bill said before leaving us on the main highway was, “When in doubt, don’t take the risk.” All of us will remember that 🙂

We finally reached home around 3AM.

Where is Faiz?


Hey guys! It has almost been a year since I last updated this website. I guess I got busy with stuff but I wanted to provide a quick professional update.

In August 2020, I moved from Santa Clara, CA to Seattle, WA. I decided to leave NetApp and join Facebook as a production engineer. It was a conscious decision to leave California because I wanted to explore a new place and also meet new people in the process. The world is huge and there are so many things to checkout and experience! It was a bit tricky though because I moved in the middle of the COVID pandemic and therefore, it was harder to meet new people and make friends. But I think I did a decent job on that in spite of COVID.

Since moving to Seattle, I got to hike a bunch, go camping, and even go to Alaska to see the lights! Although, TBH, the lights were a bit of a disappointment. Maybe I’ll create a separate post on that. Anyway, I finally got to live in a high-rise building with a good view in downtown Seattle. I like my new apartment.

Working for Facebook has been nice so far. Although, I do sometimes feel that the work-life balance can be improved. Maybe that is also something in my control but I am currently not doing a good job on that. Something to work on! Because of COVID, I haven’t yet been able to go to the office and only working remotely. I am not particularly a big fan of work from home but it is what it is for now and hopefully the offices open soon.

Anyway, till my next post, you all take care and stay safe!

Sexism, misogyny, and prejudice against women


This post is going to be a relatively long reflection against all the sexism, misogyny, and male supremacy prevalent in our society today.
A wife stays back at home while her husband goes to work to earn a living for the house. The husband works at the office while the wife stays back making and keeping the house up and running. She is happy doing that.

Another scenario is that a wife and her husband both go to the office. The wife gets pregnant and discontinues her work while her husband continues his usual office routine. The wife would remain out of the office for several months and in many cases, by her own will, never going back to work again.

In both the above scenarios, the wife can be happy doing that. And there is absolutely nothing wrong in that either. But, for a moment, picture the opposite scenario. The wife gives birth to a child and the husband goes on an extended paternity leave feeding the child from the bottle full of mother’s breast milk. The husband in this situation should be equally willing and happy as the wife would have been staying back in the house taking care of the baby, no?
The parents are worried for their daughter who is already 30 and not married. They fear she might not get any suitable matches.

The parents are tiny-miny worried about their son who is 30 and not married. But they are okay with that, at least for a few more years. They don’t yet fear that their son might not get any suitable matches.
The husband once in a blue moon hits his wife. And he profusely apologizes after that. He is truly and deeply sorry for his actions. He knows that he made a mistake. The wife forgives him only to find herself in a situation a few years later when the episode gets repeated. She swallows her anger and “forgives” her husband after he profusely and sincerely apologizes, yet again. She doesn’t want to break her marriage. She is concerned about her daughter, her family, and what the society would think of them.
A husband forces himself on the wife assuming that it is his right to do so being her husband. The woman wants to resist but doesn’t because in her head, this is possibly normal.
A wife cooks all the food while the husband sits in the drawing room talking to the guests and keeping them entertained. The wife doesn’t find anything wrong in it since she saw her mother doing the exact same thing. She doesn’t resist this setup and has not a shred of doubt in her head that this is normal.
A wife picks up all the utensils after she and her husband are done eating dinner. She saw her mother, aunties, and her grandmother doing the same. And, of course, they can’t all possibly be wrong. She accepts this and continues picking up and cleaning the utensils every night after dinner.
The parents have a son and a daughter. The son wants to go abroad for further education. The parents are happy and they will try their best to afford that education for their son. A few years later their daughter wants to do the same. This time the parents hesitate a bit. They do want to support their daughter as well but they are not as confident about it. “She’ll turn 30 by the time she is done with her education. She might also get over qualified to be able to find a suitable groom later. ” is what they might ponder upon amongst other things.
There are so many other examples that I can write in this already lengthy post. There is nothing that most of us reading this don’t already know in their conscious or subconscious mind. It is sexist if you give any kind of preferential treatment to your son as against your daughter. It is wrong to expect your wife to do all the household chores while you “earn a living” for the house. It is wrong to expect your wife to give up on her career while you go on to achieve “big things” professionally banking on your wife to support you throughout and be content with your professional success when in fact she might have wanted to do all those things for herself as well. It is sexist if you don’t help clean up the dining table after you are done eating food. It is a crime if you think that your wife is your property with whom you can “make love” to anytime you want. It is sexist if you assume that all women are bad drivers. It is a crime if you pay your male employee more than your female employee for the same position. It is wrong if you boast about not knowing how to cook food but expect your wife to be a great cook. These are just a few cases in point that are simply unacceptable but our society more often than not accepts without questions. And if you do question, you risk being considered a social outcast.

This patriarchy is not just limited to India (although, I’ll argue that it is more pervasive in India). And if you consider domestic violence as well, you can find several examples in the so-called socially developed western and European nations. Shakira, Madonna, Rihanna, Marilyn Monroe, Halle Berry and so many others were victims of domestic violence. And while I am not arguing that it is only the women who suffer in all such cases because there are examples of men being mentally and physically abused as well, the stats show that women are the overwhelming majority who are at the receiving end of such extremities of domestic violence.

I believe that in most cases all the subconscious biases start developing from an early age. The society that you grow up in, observing how women and men get treated leaves a deep impression in your mind. That said, I do also believe that as one grows up, they can change their thought process and alter their subconscious by reading more, keeping an open and flexible mind, and just applying more common sense (which I understand is hard for some people). There is an Indian movie called “Thappad” where a woman files for a divorce when her husband “just slaps” her at a party. In the moment of that one slap she realizes all the things that were not right in her married life and how blindly and happily she was ignoring that. I am not going to spoil the movie for anyone. The movie is streaming on Amazon Prime and I would urge everyone to watch it. I don’t think that there is anything shown in the movie that we do not already know but it might serve as a good reminder to both the women and the men about what they ignore as being normal when, in fact, the real normal couldn’t be far from it.

If you are here I am glad that you read the entire post. I will end this with a quote from an American actor, John Wayne. He said, and I quote:

“Women have the right to work wherever they want, as long as they have the dinner ready when you get home.”

That, my friend, is the crux of the problem we are still facing today and unless everyone doesn’t take a stand in their own personal lives, acknowledge the prejudice and the wrongs against the women, and make a sincere effort to fix it, nothing will change.

quote by Alix Kates Shulman

Figure 1. A quote by Alix Kates Shulman

Source: https://www.azquotes.com/quote/1175444

Why complain?


“……Nothing is never gonna be perfect. There is always gonna be a problem……Moral of the story is why complain? I kept doing what I kept doing and I got better at what I kept doing and I beat you all. Complaining isn’t really gonna get you nowhere but where you are now……”

-Ronnie Coleman

Part 1: Understanding Crypto Currencies and Blockchain for Newbies (5-7 minute read)


Note: This is only part 1 of the series “Understanding crypto currencies and blockchain for newbies”. I intend to make a part 2 as well where I’ll dive into the details of crypto currencies and what is blockchain. But before I do that I felt it was necessary to do a recap on what currency or money really means. Without clearly understanding how currency works, it might not make sense why crypto currencies exist or how do they work and what advantages and disadvantages do they hold.

Below is a 5-7 minute read. I have intentionally kept it brief but if you want more details on something, please refer to the references section at the end of the article or just leave a comment and I’ll try to answer as best as I can.

Let us now dive into part 1 of this series.

Before any form of currency existed, people used to exchange goods or services for other goods or services they needed. For example, assume that person A has plenty of rice while person B has plenty of fish. Person A is ready to let go of 2 kilograms of rice in exchange for 1 kilogram of fish from person B. This way of exchanging goods or services is also called a bartering system.

bartering system

Figure 1. Bartering system

Source: https://historyplex.com/barter-services-history-of-barter-system

The bartering system has its own disadvantages[1] – there is a need for people to be willing to buy the product that you want to sell. If I want to exchange fish for rice, first I need to be able to find someone who has rice and wants fish. Another major problem of the barter system is the difficulty in storing and transporting the goods to exchange. For all these and several other reasons, it was important to have some form of a common currency that could solve these problems.

According to sources[2] [3], the earliest known form of currency can be dated back to almost 5,000 years. It was called “The Mesopotamian shekel”, which, in physical form, consisted of how heavy a precious metal like gold or silver weighed. Similar forms of coinage were discovered in Europe, Asia, Africa, and other parts of the world suggesting that coinage system was indeed considered as a medium of commodity money to buy goods and services. These kind of currencies are called Representative Money that are backed by a physical commodity like gold. An example of Representative Money was the US dollar until 1971 when President Nixon decided to abandon the gold standard[4] according to which 1 ounce of gold was then worth US $35. Representative Money is not affected by inflation and the governments could only print enough money for the amount of gold they had in reserve.

Representative Money has its own disadvantages that are beyond the scope of this article. Fiat Money[5] is what replaced Representative Money and all the countries in the world now use Fiat Money. Fiat Money does not hold any value by itself. Instead, it holds value since the government of a country puts a value to it and backs it up. This also means that Fiat Money is susceptible to inflation and might lose its value in case of an unstable government or if the economy of a country collapses.

An interesting question that I used to think about is this – why can’t the government just print as much money as it wants in exchange for goods or just to give it to the poor people? The answer isn’t straightforward but in simplistic terms, a government can and should print only so much money as it needs. If there is more than needed money printed then the cost of all the goods and services will also go up, which effectively means that the value of the currency would go down. The demand and supply need to be in balance otherwise the over supply of currency can lead to hyperinflation – something that happened to Zimbabwe in 2007 that ultimately made them change their currency to the US dollar[6].

fiat currency

Figure 2. Fiat Money only has value because the governments assign a value to it

Source: https://www.investopedia.com/articles/investing/092413/how-currency-works.asp

Another interesting question is who controls this Fiat Money and decides how much to print? In the USA, it is the responsibility of the Federal Reserve to take care of it. Similar organizations in other countries like the RBI in India decide how much currency to print and regulate its flow. This is based on lots of factors like the interest rates, fiscal deficits, exports, etc. that are beyond the scope of this article.

So, next time you hold a $100 bill, think about what you really own. What is the actual value of the piece of paper that you have in your hand and what can you buy with it today vs. 10 years from now? Some food for thought 🙂


  1. de MIRAMON, J., 1983. Advantages and Disadvantages of Countertrade. J. Comp. Bus. & Cap. Market L., 5, p.347.
  2. Chapurukha Kusimba, smithsonian.com 2017. “Making Cents of Currency’s Ancient Rise”. https://www.smithsonianmag.com/history/making-cents-currencys-ancient-rise-180963776/. [Online; accessed 11-Nov-2019].
  3. worldhistory.biz, 2015. “Mesopotamian Money and Weights”. https://www.worldhistory.biz/ancient-history/71590-mesopotamian-money-and-weights.html. [Online; accessed 11-Nov-2019].
  4. history.com, 2019. “FDR takes United States off gold standard”. https://www.history.com/this-day-in-history/fdr-takes-united-states-off-gold-standard. [Online; accessed 11-Nov-2019].
  5. Jason Hall 2017. “Fiat Currency: What It Is and Why It’s Better Than a Gold Standard”. https://www.fool.com/investing/general/2015/12/06/fiat-currency-what-it-is-and-why-its-better-than-a.aspx. [Online; accessed 11-Nov-2019].
  6. Tejvan Pettinger 2017. “Hyper Inflation in Zimbabwe”. https://www.economicshelp.org/blog/390/inflation/hyper-inflation-in-zimbabwe/. [Online; accessed 11-Nov-2019].

H1B denial and stuff


Hey guys!

Been a relatively long time since my last post. I have been a bit busy – moved to a new city and a new team at NetApp. Why did I do that? I had to since USCIS denied my H1B visa for my last role at NetApp. Why did they do that? My theory is that it’s mostly random. Two people at my company with the exact same job profile and the exact same lawyers – one person gets their H1B approved while the other person gets their H1B denied. You can probably guess that I am the person whose H1B got denied in the above story. My thoughts around all this is that USCIS doesn’t really follow any strict set criteria for approving or denying H1Bs. A lot depends on who the officer is processing your application. This is not ideal but I got no say in this! Anyway, I got my H1B approved this time with my new job profile.

I was going to join MongoDB when I got my H1B denial but later decided to stay back at NetApp. That was mostly because of my wonderful ex manger Jeff, who was super helpful and understanding and found me an equally good position within NetApp. Now I work on a data migration tool called XCP – think of it as rsync on steroids. I live in Santa Clara and my office is not too far either.

But the worst part of living in the bay area is the rent you end up paying! My rent shot up by almost 2.5x compared to what I was paying in NC. So, that kind of sucks but otherwise, I am still exploring the bay area and it isn’t too bad 🙂

More later! I am at a coffee house writing this post and just drank some really good coffee!

p.s. Anyone got questions around H1B denials and stuff, I am your man!

Gym routine


Hello people!

So I was following a gym routine for some time that I would like to share. I wouldn’t say it’s for beginners but if you have been working out for a while and want to change it up, this is a decent routine. It assumes that you workout 4 days a week and the routine alternates between 1 week of building endurance and 1 week of heavy lifting.

Without further ado, below is the routine that also mentions the source it was taken from. But please remember, being fit is roughly about 70% what you eat and 30% how much you workout.

Good luck!

What is depression?


Q: I see it happening all around us that as we grow older, depression becomes a natural emotion within all of us, and takes a toll on human beings. How do we adjust to this situation which is inevitable and happening all the time?

Sadhguru: Once you declare that depression is a natural process, there is no way out. When you were a child, being joyful was natural to you, not being depressed. So do not declare that depression is natural. Depression means you are unable to maintain the exuberance of life in you. It happens even in your body. If you are depressed, even the physical body flops. Life within you is not exuberant – it has just gone down and lost its exuberance because you are not doing the right thing with it. You are imposing too much outside nonsense upon the inside. You have not done anything to keep your life energies high.

The Source of Depression

Depression is a kind of agony. If you have become agony and not ecstasy, it is because a large part of your life energy is happening compulsively, not consciously. It is happening as a reaction to external situations. Once you are happening compulsively, becoming depressed is very normal, because external situations are never hundred percent in your control. There are so many things happening in the world; if you compulsively react, getting lost and becoming miserable is natural. The more exposed you are to life, the more miserable you will become.

Depression means you are unable to maintain the exuberance of life in you.

When people are unable to handle life outside, they try to curtail their life and withdraw. But even that goes out of control, doesn’t it? There is one part of you which is constantly seeking expansion – you want to constantly increase the boundaries and areas of your activity. There is another part of you which is getting depressed every time something does not go the way you think it should go. Getting depressed is subject to the non-fulfillment of your expectations.

If the stock market gets depressed today, so many people will get depressed. Many of them may never have even touched that money, but every day they were watching the graphs rising and their mood was in ascendancy. Now they see the graph falling, so their mood is falling. It is just that what they expected to happen, did not happen.

Fixing the Inside

People can cause depression in their mood in so many ways. If you take away what they think is precious, they become depressed. The tragedy with a lot of people, especially in affluent societies, is that they have everything and yet they have nothing. Depression means somewhere, a certain hopelessness has set in. If you go to some very poor village in India, they are really impoverished, but you will see joyful faces because they have hope – it is going to be better tomorrow. In affluent societies that hope is gone. Depression has set in because everything that can be used externally has been fixed. There is food, there is housing, there is clothing, there is everything, but still there is something wrong. They just do not know what.

A poor man may think, “Tomorrow, if I get a new pair of footwear, everything will be fine.” If he gets a new pair of footwear, he will walk like a king with great joy on his face because he has hope; the outside is not yet fixed. In affluent societies, the outside is fixed, but the inside is not fixed, so there is hopelessness and depression.

As we work on the outside, we must also fix the inside. Then the world would be beautiful. What we call as a spiritual process is just this – not just fixing the objective aspect of your life but taking care of the subjectivity of who you are. If that is not taken care of, you will have everything, and you will have nothing.

Source: https://isha.sadhguru.org/us/en/wisdom/article/solution-for-depression-from-inside-out

Mental strength


Many people out there forget how important mental strength is. If you don’t believe you can do something then you won’t…simple as that. If you can visualize yourself being successful and gain confidence through training and hard work…you will succeed!

-Brian Shaw

LRU Cache


I had heard a lot about this interview question from people but honestly, I never studied it in school. Maybe I skipped one of those classes that talk about it 🙂

LRU stands for least recently used (add cache to that, it becomes LRU cache. But LRU could be of anything like LRU disk, LRU threads, etc.). When an interviewer asks you this design question (I consider it as a design question), they are not expecting you to explain how caching works and what cache is but are in fact looking for an algorithmic solution to the LRU problem.

So what do we mean by LRU? Suppose you have two cats of ages 1 and 2 and you are asked to let go of the one that’s older – you let go of the second cat. What did we do here? We compared the ages of the two cats and only kept the one that was younger. Something similar happens with LRU design questions. We want to keep X (could be cache, drives, threads, etc.) but when we run out of capacity, we have to let got of something and this something is decided based on what was not used in recent times.

fstab file

Fig 1. High-level LRU working
Source: http://katrinaeg.com/lru-cache.html

How do we maintain the least recently used items? One way is to maintain something like a hashmap of ages and based on what is oldest, we remove it. But what would be the time complexity of this solution? We will have to traverse the entire map to find the oldest age and thus, it would take O(n) time. See HERE for this solution.

Can we do better? Turns out we can if we maintain a doubly linked list (DLL). The oldest item would always remain at the back of the list while the youngest at the front. In this way, we can delete an item in O(1) time. Whenever we access an element from the list, we push it to the front since it then becomes the most recently used item.

A doubly linked list solution in C++ should ideally not use pointers if you are using STL. But if you still want to write your own doubly linked list, HERE is a solution. But if you want to use STL, take a look at THIS.

To surmise, LRU implementation is a popular interview question and not that hard to grasp the concept of it. Give yourself a few hours and see if you fully understand what LRU demands and ways of designing it.

Feel free to leave comments if you have any questions.

Hadoop on containers


I have started working on a project to make Hadoop/Spark run effectively in a containerized environment. And while microservices like a web server are well suited to run in a container (being stateless), running any big data technology like Hadoop/Spark/Kafka can be a challenge thanks to their need of being stateful (opposite of what containers provide). There are some workarounds available and I have written a one-page report that takes no more than 2-3 minutes to read providing a brief, high-level overview. If you have any questions, please leave a comment and I’ll try to address them.

Monitors: An Operating System Structuring Concept


While re-visiting to recall the differences between Semaphores and Monitors, I came across one of my OS class homework where I had written a summary on Monitors. So I thought I may as well blog about it.

Paper: Monitors: An Operating System Structuring Concept

Author: C. A. R. Hoare

Date: 1974

What is it about?

  1. One of the major problems in building an operating system is to allow sharing of computer installations among different processes that may make unpredictable demands upon its resources. The paper attempts to address this issue by introducing the concepts of “signal” and “wait”.
  2. Creating resource allocation algorithms for different kinds of resources can be a challenge for a developer. There wasn’t an easy way to construct separate schdeulers for each class of resource. The paper introduces the concept of monitors that attempts to solve this issue.
  3. The paper also talks about the problem where multiple processes are trying to access the same resource and what can be done to prevent this race condition.
  4. The author has built upon the work done in the paper “Proof of correctness of data representations. Acta Informatica” by Hoare.

Some key contributions

  1. The paper talks about monitors – a synchronization structure. A monitor is a class like structure that contains data and functions. One significant property of monitors is that only one program may be executing a monitor procedure at any given point in time.
  2. The paper demonstrates the usefulness of monitors in structuring operating system designs. Monitors provide an effective way to enforce synchronization of processes (like critical sections).
  3. It also introduces the concept of condition variables. The condition variables stop one process to acquire resources being used by another process. It creates a queue of processes waiting in line to acquire the resource.
  4. “Signal” and “wait” operations are also introduced in the paper. Like the name suggests, “signal” means resume the execution of a process waiting in the queue, while “wait” is used to cause a delay in the execution of a process.
  5. How to implement semaphores using monitors is also described in the paper. Monitors are powerful like semaphores but provide a higher level of abstraction by providing data and code encapsulation.
  6. Introduce a new type of variable called “condition” for cases where there may be more than one reason for waiting and they need to be distinguished by both the waiting and the signalling operation.

Experimental methodology

  1. The paper talks about how semaphores can be implemented using monitors and vice-a-versa. They also provide a proof that the monitor condition concepts are not any less powerful than semaphores and that they can be used for all the same purposes.
  2. The paper makes some good suggestions towards the end and one of them is “Never seek to make an optimal decision; merely seek to avoid persistently pessimal decisions.” This observation calls for the need of good scheduling algorithms and the paper presents one.

The above is only a high-level summary and doesn’t contain all the details mentioned in the paper. For a thorough review, please go through the entire paper. If you have any questions, feel free to leave a comment.

Happy reading!



“The sea’s only gifts are harsh blows, and occasionally the chance to feel strong. Now I don’t know much about the sea, but I do know that that’s the way it is here. And I also know how important it is in life not necessarily to be strong but to feel strong. To measure yourself at least once. To find yourself at least once in the most ancient of human conditions. Facing the blind deaf stone alone, with nothing to help you but your hands and your own head.”

~Christopher McCandless

Coin change problem


This question has been asked a lot in interviews and is one of the classical dynamic programming questions.

Problem statement : Given a bunch of coins of various denominations, find out the number of ways they can sum up to a given value. Assume that there’s an infinite number of each coin available.

For example:
Denominations = {1, 2, 3} and Sum = 4. Possible ways = {1, 1, 1, 1}, {1, 2, 1}, {1, 3}, {2, 2}.

Without going into any more details, I am just going to give you the code on how to do that using:

    1. Brute force
    2. Memoization (top-down)
    3. Tabulation (bottom-up)

    LINK to the code.

    If you have any questions, do let me know in the comments section.

    Happy coding!

Kadane’s algorithm


If you have seen interview questions like find the maximum sum in an array using any contiguous sub-arrays in it then you should read further.

We have discussed a few dynamic programming questions on this website. This post talks about yet another one (arguably). Let’s take an example – in the array {-2, -3, 4, -1, -2, 1, 5, -3}, what is the maximum sum that you can obtain by summing up any contiguous elements in it? Well, you can compare each element one by one and build an O(n*n) solution to do that. But can we do better? Let’s see what Mr. Kadane proposed.

For every i, let’s try to calculate the maximum sum possible till that i.

Array = {-2, -3, 4, -1, -2, 1, 5, -3}; i will go from 0 to 7. Let’s keep two variables:
sum_at_i = 0
max_sum = 0

At i = 0;
sum_at_i = sum_at_i + array[i] = -2
Since sum_at_i < 0, we re-initialize:
sum_at_i = 0
max_sum = 0

At i = 1;
sum_at_i = sum_at_i + array[i] = -3
Since sum_at_i < 0, we re-initialize:
sum_at_i = 0
max_sum = 0

At i = 2;
sum_at_i = sum_at_i + array[i] = 4
Since sum_at_i > 0 and sum_at_i > max_sum; we make:
sum_at_i = 4
max_sum = 4

At i = 3;
sum_at_i = sum_at_i + array[i] = 4 – 1 = 3
Since sum_at_i > 0 but sum_at_i < max_sum; we don’t change max_sum:
sum_at_i = 3
max_sum = 4

At i = 4;
sum_at_i = sum_at_i + array[i] = 3 – 2 = 1
Since sum_at_i > 0 but sum_at_i < max_sum; we don’t change max_sum:
sum_at_i = 1
max_sum = 4

At i = 5;
sum_at_i = sum_at_i + array[i] = 1 + 1 = 2
Since sum_at_i > 0 but sum_at_i < max_sum; we don’t change max_sum:
sum_at_i = 2
max_sum = 4

At i = 6;
sum_at_i = sum_at_i + array[i] = 2 + 5 = 7
Since sum_at_i > 0 and sum_at_i > max_sum; we make:
sum_at_i = 7
max_sum = 7

At i = 7;
sum_at_i = sum_at_i + array[i] = 7 – 3 = 4
Since sum_at_i > 0 but sum_at_i < max_sum; we don’t change max_sum:
sum_at_i = 4
max_sum = 7

And there we go! Our answer is 7. (But can you also find the indices of the sub-array?)

You can find the corresponding C++ code for the above algorithm HERE.

Now that you have found the maximum sum, can you also find the minimum sum? Give it a try.


1. GeeksforGeeks 2017. “Largest Sum Contiguous Subarray”. https://www.geeksforgeeks.org/largest-sum-contiguous-subarray/. [Online; accessed 27-March-2018].
2. Kartik Kukreja 2013. “Everything Under The Sun”. https://kartikkukreja.wordpress.com/2013/06/17/kadanes-algorithm/. [Online; accessed 27-March-2018].

How to Control Your Emotions During a Difficult Conversation


Today I read an article on how to maintain your composure and keep calm while being in an argument. With whatever little experience I have, I have seen people lose their cool more often than not, which actually comes back to bite them in their arse later.

Have a read in free time and see if it helps you. I think no matter where you are in your career or personal life, you can learn a few things from the article. It won’t take more than 5-6 minutes to read the entire piece – LINK.

I won’t back down


There are some songs that you instantly connect with, that pump you up, that makes you have goosebumps. But I also think that the effect of a song on any person depends largely on the mood or the circumstance they are in or going through. Anyway, while watching Grey’s Anatomy (I think season 8, last episode), I found one such song.

Ugly Numbers


Ugly is a number whose only prime factors include 2, 3, and 5. 1 is considered to be ugly by convention.

For example, 4 (2×2), 6 (2×3), 20 (2 *2 * 5) are ugly numbers but 7 (1x 7), 28(2x14x7) are not.

A simple way to calculate if a number is ugly or not would be to keep dividing a given number by 2, 3, and 5 and if we get 1 at the end, the number is ugly. Consider 300 for example.

300 – keep dividing by 2 till it can possibly be divisible -> 150, 75
75 – keep diving by 3 till it can possibly be divisible -> 25
25 – keep dividing by 5 till it can possibly be divisible -> 5 -> 1

Since we got 1 at the end, 300 is an ugly number.

So, what’s the time complexity of such an algorithm? It would O(nxn) with O(1) space complexity.

Can we do better? Whenever optimization comes to my head, I think of one of the two things – dynamic programming or graphs. Let’s take another look at this problem.

1. What’s the first ugly number? It’s 1. Alright, good enough.

2. What’s next? It would be one of the three – 1×2, 1×3, 1×5 i.e. (2, 3, 5). What’s the smallest? It’s 2. Thus, 2 is our next ugly number.

3. What’s next? It would be one of the three – 2×2, 1×3, 1×5 i.e. (4, 3, 5). What’s the smallest? It’s 3. Thus, 3 is our next ugly number. Note that we didn’t multiple 2 by 1 but instead we multiplied 2 by 2. This is because we had already used 2 in step 2. Now that we have used 3 in this step, we would do the same if we have to use 3 again in the future.

4. What’s next? Minimum of (2×2, 3×3, 1×5) = 4. Thus, 4 is our next ugly number.

5. We keep repeating the procedure till we get what nth ugly number we are looking for.

HERE is some code that solves it using both brute force and dynamic programming.

If you want to see the time difference between the two, figure 1 shows the time to calculate 1500th ugly number using brute force (more than 36 seconds) vs. dynamic programming (less than 2 seconds).

fstab file

Fig 1. Time to find out the 1500th ugly number using brute force vs. dynamic programming

More on dynamic programming later. If you have any questions, let me know in the comments section.


1. GeeksforGeeks 2017. “Ugly Numbers”. https://www.geeksforgeeks.org/ugly-numbers/. [Online; accessed 12-Feb-2018].
2. jmty0083, LeetCode 2017. “Ugly Number II”. https://leetcode.com/problems/ugly-number-ii/discuss/69364/My-16ms-C++-DP-solution-with-short-explanation. [Online; accessed 12-Feb-2018].

Get HTTPS for free!


There are several non-profit certificate authorities out there now that provide with free SSL/TLS certificates. On of them is Let’s Encrypt. I recently moved from HTTP to HTTPS using THIS that basically uses Let’s Encrypt’s certificate authority to issue free certificates.

You will need to edit your Nginx/Apache configuration files later on and also add a CNAME for the CAA etc. but it’s all worth it! After all, you get FREE HTTPS! 🙂

Stay secure!

Problem of Longest Increasing Subsequence (LIS)


Let’s explain the problem with an example. Assume the array is {10, 22, 9, 33, 21, 50, 41, 60}. In this case, there are several increasing subsequences like:

1. {10, 22, 33, 50, 60}
2. {10, 33, 50, 60}
3. {10, 21, 50, 50}
4. {10, 21, 41, 60}
and so on. The idea is to find the maximum length of the increasing subsequence in the main array.

The problem can be efficiently solved using dynamic programming but let’s first try to solve it using brute force. With brute force, we will make all the possible combinations and find out which one is the longest. Let’s start with the first element in our main array (10) and see how that goes.

Starting with 10, we either include it or we exclude it. Let’s include it first in which case the next element in the LIS has to be bigger than 10. We have 22, which is bigger than 10. We can have two cases here. One, we include 22 in our LIS and proceed further and two, we don’t include 22 and proceed further. Next, for each of the two cases above, we will check again for the next element, which is 9 in this case. Since 9 is smaller than 10, there is just one case here, which is to not include. Next, we have 33 in the main array. Again, we can have two cases here. One, we include 33 and proceed further and two, we exclude 33 from our LIS and proceed further. We keep doing this till we reach the end of the main array. At the end we take the maximum achieved by either including or excluding and return that as the answer. The time complexity of this brute force method will be O(2^n) and space complexity will be O(nxn).

The problem with the brute force method is that often, the same computation is being done more than once. We can solve this problem using dynamic programming (overlapping sub-problems and optimal sub-structure). Let’s see how we do that in THIS video.

HERE is some code that solves it using both brute force and dynamic programming. Note that there is another method using binary search that solves this problem in O(nlog(n)) time complexity and we may cover that in a later post.

To find out how to print the LIS elements as well, refer to THIS piece of code. The idea is similar just a little modification and keeping a tab of vector of vectors.


1. Tushar Roy 2015. “Longest Increasing Subsequence”. https://www.youtube.com/watch?v=CE2b_-XfVDk. [Online; accessed 24-Jan-2018].
2. vinod23, LeetCode 2017. “Longest Increasing Subsequence”. https://leetcode.com/problems/longest-increasing-subsequence/solution/. [Online; accessed 24-Jan-2018].
3. GeeksforGeeks 2017. “Dynamic Programming | Set 3 (Longest Increasing Subsequence)”. https://www.geeksforgeeks.org/longest-increasing-subsequence/. [Online; accessed 24-Jan-2018].

Dynamic Programming – Optimal Sub-structure


In THIS post, we covered the overlapping sub-problems part of dynamic programming. Now we will talk about what do we mean by “optimal sub-structure”?

Assume we have a graph like below. What is the shortest path from node A to node D? It is A->C->D. So, optimal structure property means that if a node (C) lies between the shortest path of two nodes (A and D) then the shortest path between the two nodes (A and D) will be the shortest path between the source node (A) to the intermediary node (C) plus the shortest path from the intermediary node (C) to the destination node (D). Note that if we were to find the longest path between two nodes then this property does not hold true (try drawing out a graph and see for yourself why?)

Shortest path example

Fig 1. Shortest path problem holds optimal sub-structure property of dynamic programming

In the next few posts, we are going to solve a few DP questions to understand our concepts better.


1. GeeksforGeeks 2017. “Dynamic Programming | Set 2 (Optimal Substructure Property)”. https://www.geeksforgeeks.org/dynamic-programming-set-2-optimal-substructure-property/. [Online; accessed 14-Jan-2018].

Persistent block device naming


In the last couple of months or so, I have been playing with building a hadoop cluster and stuff. This also involved dealing with lots of JBODs and configuring them properly, which is pretty straight forward. To make a new disk mounted permanently, you generally add an entry in fstab, all good till now. So, my fstab entry looked something like below. See the HDFS mount points.

fstab file

Fig 1. Entries for the mounted points in the fstab file

The problem started when sometimes I would reboot my servers and some of them won’t come back and stuck at boot time while entering a safemode kind of a thing. Only a root user could then go in and troubleshoot. Most often than not, if I would reboot that server again, it rebooted back just fine. But this was annoying, really, when a bunch of servers won’t come back up every time I rebooted. I decided to do a little research into this.

Storage devices are usually managed by the sd drivers. That’s why you see the naming like sda, sdb, etc for the disks. The letter that comes after “sd” is referred to as a major number and the numeric number that comes after that, (e.g. sda”1″) is referred to as a minor number. Whenever the sd driver detects a device, it assigns an available major number and a minor number to it. What this also means is that when you reboot a server, the sd driver may detect some disk earlier than when it detected it the last time you rebooted that server, and therefore, it can assign it a different major and a minor number this time. Thus, what was sda1 last time may become sdb4 this time and the entries you have in fstab won’t work causing the system to not boot up properly. This can happen because of various reasons mentioned in [1].

For all these reasons, you really shouldn’t use sd names when referring to devices in your fstab file. There are several other ways to map the correct device using:

  1. by-label
  2. by-uuid
  3. by-id and by-path
  4. by-partlabel
  5. by-partuuid
  6. Static device names with Udev

I am not going to discuss all of them here except by-uuid, which is what I ended up using. If you issue an “lsblk -f” on your server, you would be able to see NAME, FSTYPE, LABEL, UUID, MOUNTPOINT. Note down the UUID for the concerned device and add this to your fstab file. It would look something like below.

fstab file

Fig 2. Entries for the mounted points in the fstab file using UUID

Now, reboot your server all you want, the UUIDs for the disks won’t change, ever, and you will have persistent device naming. This at least made me realize how small things like these can help save you so much of time and make sure you are not going crazy when sda1 becomes sdb4 on its own 😀


1. RedHat 2017. “PERSISTENT NAMING”. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/persistent_naming. [Online;accessed 22-Nov-2017].

Dynamic Programming – Intro


I’ll confess – I always had (or maybe still have) issues solving dynamic programming (DP) questions. I mean, it’s just complicated, not as straightforward to understand. And how do we even know that a given question can be solved using dynamic programming?

There are two things to look for in order to understand if a given problem can be solved using dynamic programming.

  1. Are there “overlapping sub-problems”?
  2. Is there a defined structure or a “optimal sub-structure”?

If the above two conditions hold true for any given problem, it can usually be solved using dynamic programming. In this post, I will talk about overlapping sub-problems and the two common approaches to solve such problems. In the next post, I will talk about what is an optimal sub-structure.

Think of how a fibonacci series is calculated using recursion. Let’s take the example of fib(5). In calculating fib(5), we end up calculating fib(3), fib(2), fib(1) more than 1 time. If we were to calculate the fibonacci series of a much bigger number, there would be a lot of redundant calculations. If there was a way to calculate things only once and look them up as needed (look-up of O(1)), we would save a lot of time!

There are two ways to calculate things only once – a) Have a look-up table and build this look-up table on-demand, also called Memoization or top-down approach; or b) Have a look-up table and build this completely before hand, also called Tabulation or bottom-up approach.

HERE is some code that calculates the fibonacci series using recursion, memoization, and tabulation.

The figure below shows the time taken to calculate the same fibonacci number 45 using recursion, memoization, and tabulation. It took 11.32 seconds using recursion whereas only 1.71 seconds and 1.43 seconds using memoization and tabulation respectively. Indeed a great performance improvement!

Time to run fibonacci 45

Fig 1. Time taken to calculate fib(45) using 3 different approaches

RedHat 2017. “PERSISTENT NAMING”. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/persistent_naming. [Online;accessed 22-Nov-2017].

Reference: GeeksforGeeks 2017. “Dynamic Programming | Set 1 (Overlapping Subproblems Property)”. https://www.geeksforgeeks.org/dynamic-programming-set-1/. [Online; accessed 14-Jan-2018].

GoDaddy to Linode and LAMP to LEMP


So, I have been using GoDaddy’s servers to host this website for over two years now but I wanted to move away from it for several reasons. Some of them being lack of ssh access to a shared GoDaddy server, cost, and flexibility.

Specifically talking about the cost and other factors, below are some numbers.

Name Type Cost for 3 months CPUs Memory Network Storage
GoDaddy Economy Linux Hosting $24 1 512MB Unmetered (conditions applied) Unmetered (conditions applied)
Linode Linode 1GB $15 1 1024MB 1 TB 20 GB SSD

It was a no brainer to move to Linode and I was just being lazy to transfer the site but I did it finally. Yay! Also, I wanted to use a different web stack. So, use Nginx instead of Apache and MariaDB instead of MySQL. Honestly, I don’t know much about the advantages of one over the other but I still wanted to give it a try. Using Nginx over Apache did prove to be a bit of a learning curve and I had to manually tweak in some configurations but it wasn’t that bad.

Anyway, if you have any questions about the migration, do leave a comment. Btw, I just realized that I had disabled the comments section, which I am going to re-enable now.

Also, btw, I forgot to post about the fact that I started working for NetApp full-time as a Technical Marketing Engineer. Yeah, that position was new for me too but very briefly, I work on things like Hadoop, Spark, big data problems, etc. Anyway, more on that later.

What am I gonna live for?


I haven’t been doing anything productive I feel for the last so many weeks. This feeling has started to feel more intense of late, especially today. Feels likes I am wasting so much of my time when I could be using that to do things I really want! Anyway, watching Grey’s Anatomy continuously for several hours now, the last song in the last episode of Season 4 just gave me a kick to get off my lazy ass from that couch, listen to the song again, and do something productive! I think I have been missing my music in the last so many months. Good music really helps me I think and push. Anyway, here is the song!

Toilet: Ek Prem Katha


Recently, a friend of mine suggested that we watch this new movie called Toilet: Ek Prem Katha. I do like watching movies on social issues, especially those concerning India, so I agreed. At the end of it, I came out of the movie theater more baffled/irritated than anything else. Was it an entertaining movie with an incredible social message or a hidden propaganda and siding with one of the major political parties in India?

I felt uneasy when Toilet: Ek Prem Katha, a Reliance Company production, started by applauding the Prime Minister and naming him for his “Swachh Bharat Abhiyan”. I admire the initiative of “Swachh Bharat Abhiyan” but specifically naming the current Prime Minister and applauding such schemes as his individual effort seems a bit like buttering to me. It would have been easier to digest had the movie simply stated that it appreciates the steps taken by the government in spreading awareness among the citizens.

The movie started off as a romantic story between Akshay Kumar and Bhumi Pednekar with songs that I found to be too many and unnecessary. During the intermission (thankfully a much needed break for my train of thoughts), I discussed with my friend how Akshay Kumar had recently received a National Award for the movie Rustam. Akshay Kumar is one of the finest actors in Bollywood who has successfully maintained his fan base for decades. However, Rustam, arguably, is not the best piece done by Akshay Kumar, who also happens to be a Canadian citizen. It is true that to win a National Award, the person does not need to be an Indian citizen. But it raises questions when a person who receives the National Award for a sub-par performance in the same year when other hits like Dangal (Aamir Khan) were released is also seen as a big supporter of the ruling government (particularly in 2015 during the controversy of “award-wapsi”). Given the chain of events, I was thinking if it was fishy that Akshay Kumar, a Canadian citizen, awarded a National Award for a sub-par performance, who then is a lead character in a movie that commends and praises the Prime Minister for “his” “Swachh Bharat Abhiyan”?

Unfortunately, the second half of the movie does more to confirm my doubts that this movie is a pro-government propaganda by inserting “good ideas” like “Demonetization” and “6 millions toilets being built in last 3 years”. It must be a pure coincidence that our honorable Prime Minister was elected exactly 3 years ago too! And then of course there is a corruption scandal that is supposed to be addressed, a scam that they again specifically mention happened 4 years ago. Yes, there was a Toilet scam in the previous government and I would criticize that as much as I can but can you connect the dots here? A movie that was supposed to spread awareness among the people to not defecate in the open ends up endorsing the Prime Minister, even for unrelated things to the movie, and ridiculing the previous government? Toilet: Ek Prem Katha clearly abuses the power it holds to connect to millions of people and messes up with a chance to be the movie that stood up for a social cause without any prejudice.

I smell a rat when a company called Viacom-18 (owned 50% by Reliance), led by Mukesh Ambani, one of the wealthiest person in the world and supposedly a close aid to the Prime Minister, produces a movie led by a movie actor who received an award he did not deserve. No surprise that this movie is going to run tax-free in all the states led by the current government. I feel like a stupid, helpless, and gullible Indian when I watch mainstream movies like these that are meant to subtly manipulate us by endorsing some political party. We sure are better than this! Watching the movie reminded me of the quote “If you state a lie often enough it becomes the truth”. Was this movie supposed to create a good image of the government among its citizens? Was it an intentional pro-government propaganda movie produced by Reliance who is trying to maintain a productive relationship with the current government? It is quite irresponsible and a shame that a respected form of art, a mass media would side with one political party and actually try to exploit the audience though such movies.

I hope to be able to praise and give credit where it is due, and I hope that I can rationally criticize where it is needed as well. A bigger hope is to see my country people be smarter than just taking in whatever such movies feed us and start a respectful discussion. No doubt that the current government has done some good work but there are also a lot of areas it could have done much better. It is high time that we first become smart Indian citizens who read a lot, research, discuss, respect one another, and become smart voters rising above the boundaries of religion, region, and castes.

Some random quotes

I am about to rub my white board after a long time but before I do that, here are some of the quotes I like on there.

“The only place success comes before work is in the dictionary.”

Vince Lombardi

“Judge yourself by how hard you train not by how well you perform.”

Don’t know who said it

“Hardwork beats talent when talent fails to work hard.”

Kevin Durant

“When things go well, everyone can pretend to be fantastic.”


“Eventually you get what you want, but you must want it enough.”

Don’t know who said it

“When things go wrong in life that is when it truly shows who you are.”


“The axe forgets what the tree remembers.”

African Proverb

More on the Raspberry Pi cluster – concluding post


Alright, so, I have graduated as of writing this post. I should have completed my last story about Raspberry Pis and how it went in more detail but I have decided to write a little more about it today and conclude.

Cluster of Raspberry Pis

Fig 1. Cluster of Raspberry Pi and Artik boards setup in the lab

So, we were able to setup a cluster of around 10 Raspberry Pis, 9 of which were slaves and one was the master with a public IP. All were connected to a 1G switch and the setup was not as complicated as we thought in the beginning, partly because I had some prior experience setting up a cluster. We ran our algorithms (I/O intensive and CPU intensive) on the cluster using dummy data and recorded the results. Next, we decided to virtualize the Pis and see its effect on performance. Our initial plan was to install KVM and spin up virtual machines. So it turned out, you can not install a hypervisor on a Pi (not supported at the kernel level). Next we explored Dockers and got it to work on a single Pi. This was nice! We started working on getting Docker Swarm up and running, and this turned out to be complicated. Getting Docker containers to talk to each other in a cluster is not trivial and surprisingly, most of the documentation we found was not much helpful. Eventually, we were able to run the same algorithms on the Pis each running a docker instance. We expected the performance to take a significant hit but that was not the case as the numbers we got with and without virtualization were comparable.

The last part of our project included measuring the energy consumed in watts in running the cluster of Pis and what can be done to minimize it. Most of our PCs are tuned to run at the maximum CPU speed. So, for example, a PC with a CPU capable of performing 1,800,000,000 clock cycles per second will always be tuned to run at that speed and this is defined in the kernel. Running at the maximum CPU cycle also means consuming more energy. Btw, this method of varying the power and speed on a computer is called DVFS. A Pi3 model can run at a maximum CPU speed of 1.2 GHz but does not allow setting CPU speeds other than 600 MHz and 1.2 GHz. Hence, we decided to do our testing on the Artik boards (discussed in the previous post). Artik boards have a lower power DVFS control hardware block that allows frequency variation in continuous steps between 500 MHz to 1.3 GHz. We decided to vary this and note the energy consumed using a tool call WattsApp Pro. We ran the Spark code on the Artik cluster at 500 MHz to 1.3 GHz (interval of 100 MHz) and noted the time taken to finish the jobs along with the energy consumed. We found that running the Spark cluster at 1.1 GHz was the saddle point where it consumed least power and ran all the jobs on the Spark cluster in almost the same time as running at the top speed.

Our class paper can be found HERE. If you have any questions about anything in this project, please feel free to email me. I have not gone into the details of the project in this post but happy to answer any specific questions you may have.

Attempt to build a Spark cluster on Raspberry Pi1


We started off building a Spark cluster using 10 Raspberry Pi1 model B+ since that is what was available in the lab at that point. Just to inform, a Pi1 model B+ has 512M of memory, ARMv6 single core, and 700 MHz clock speed. We made one of these Pis as the Spark master and the rest as workers. Spark version v2.1.0-rc1 was used.

The initial tests included simple word count and sorting examples. We expected it to run slow because of memory constraints and that is what happened. Running word count and sorting algorithms on a text file of less than 10 words took like an hour. More complicated algorithms never ran to completion. We decided to halt our testing and order Pi3 models. Along with Pi3 models, we also ordered 5 x Artik10 boards. Each Artik10 board has 2G memory, 8 threads, 1.3GHz, and a ARMv7 Processor rev 3. Compared to this, a Pi3 has 1G memory, 4 threads, 1.2GHz, and a ARMv7 Processor rev 4 (v7l).

I am not diving into more technical, low level details on how we setup a Spark cluster but if you have specific questions, please leave comments. I would gladly help.

Building a Spark Cluster on Raspberry Pi


I have been a bit lazy of late to update this post. I have decided to write a little in a bunch of posts than one super long post since that scares me 🙂

As a part of my Operating Systems class that I took in the fall of 2016 under Dr. Butt, I worked in a team of 5 on a project involving Fog Computing. The exact title of the project was “Effects of Latency, Virtualization, Frequency, and Security on Fog Computing”. So, just a brief introduction about the project in this post. Will add more details in the next one.


Eraser: A Dynamic Data Race Detector for Multithreaded Programs


As a part of my OS class this semester (Fall 2016), we have been reading a bunch of very interesting papers. I wish to blog every paper I read for this class, but I don’t get time :/ Anyway, here is a brief summary of this paper for noobs.

Paper: Eraser: A Dynamic Data Race Detector for Multithreaded Programs

Authors: Stefan Savage, Michael Burrows, Greg Nelson, Patrick Sobalvarro, Thomas Anderson

Date: 1997

What is it about? The basics….

  1. The paper attacks the problem of data race in multithreaded programs.
  2. Debugging multithreaded programs can be difficult. Basic errors in synchronization can produce timing-dependent data races that can take “several weeks” to debug.
  3. Previous work done by Lamport’s ‘happens-before’ relation checks that conflicting memory accesses from different threads are separated by synchronization events.
  4. The work in this paper improves upon the ‘happens-before’ algorithm by simply checking that all shared memory accesses follow a consistent locking discipline.
  5. The paper argues that for many programs, its approach is “simpler, more efficient, and more thorough” at catching races than the ‘happens-before’ algorithm.
  6. This work also improves upon the work done by Hoare (Monitors) in that they don’t protect against data races in programs with dynamically allocated shared variables.

Some key things….

  1. The paper proposes a new algorithm to detect data races called “The Lockset Algorithm”.
  2. “The Lockset Algorithm” enforces a locking discipline that some lock protects every shared variable. This means that any thread holds the lock whenever it accesses the variable.
  3. It improves upon the locking discipline and extends “The Lockset Algorithm” to accommodate initialization, read-shared data, and read-write locks.
  4. Developed a program annotation to allow users to eliminate false reports.
  5. Experimental stuff

    1. Eraser was implemented for the DIGITAL Unix operating system on the Alpha processor using the ATOM binary modification system.
    2. Applications typically slowed down by a factor of 10 to 20 while using Eraser.
    3. While programming some tests that contained common synchronization errors, Eraser detected the data race errors correctly.
    4. Eraser also successfully tackled large multithreaded servers written by researchers at DEC SRC: the HTTP server and indexing engine from AltaVista, the Vesta cache server, and the Petal distributed disk system.
    5. Eraser found undesirable race conditions in three of the four server programs, and in many of the undergraduate homework problems. It also produced false alarms that were suppressed using annotations.
    6. The authors mention, “Eraser’s testing is not very sensitive to the scheduler interleaving.” To prove this, they did two experiments on Ni2 and Vesta.
    7. The above is only a summary, and doesn’t contain all the details mentioned in the paper. For a thorough review, please go through the entire paper. If you have some questions, feel free to email me at fabidi89@vt.edu.

Old days!


Aata hai yaad mujhko guzra hua zamana
Woh baagh ki baharein vo sabka chehchahana

Aazaadiyaan kahan vo apne ghosle ki
Apni khusi se aana apni khushi se jaana

Lagti hai chot dil pe aate hain yaad jis dam
Shabnam ke aansuon par kaliyon ka muskurana

Vo pyaari pyaari soorat vo kaamni si moorat
Aabaad jiske dumse tha mera aashiyaana

Aati nhin sadaein uski mayray qafas mein
Hoti meri rihayi ai kaash mere bas mein

Kya badnaseeb hoon main ghar ko taras rha hoon
Saathi to hain watan mein main qaid mein parda hoon

Aayi bahaar kaliyaan phoolon kee hans rahi hain
Main is andhere ghar mein qismat ko ro rha hoon

Iss qaid ka ilaahi dukhrda kise sunau
Dar hai yahin qafas mein main gham se mar na jaau

Jabse chaman chhoota hai yeh haal ho gya hai
Dil gham ko kha rha hai, gham dil ko kha rha hai

Gaana ise samajh kar khush ho na sunne waale
Dukhe hue dilon ki paryaad se sada hai

Azaad mujhko karde O qaid karne waale
Main be-zubaan hoon qaidi tu chhor kar dua le


I have to die one day


Koi ummed bar nhin aati
Koi soorat nazar nhin aati

Maut ka ek din muaiyyan hai
Neend kyun raat bhar nhin aati

Aage aati thi haal-e-dil pe hasi
Ab kisi baat par nhin aati

Jaanta hoon sawaab-e-taa’at-o-zahad
Par tabiyat idhar nhin aati

Hai kuch aisi hi baat jo chup hoon
Warna kya baat kar nhin aati

Kyu na cheekhun ki yaad karte hain
Meri aawaaz gar nhin aati

Daagh-e-dilgar nazar nhin aata
Bu bhi ai chaargaar nhin aati

Hum wahan hain jahan se humko bhi
Kuch hamari khabar nhin aati

Marte hain aarzoo mein marne ki
Maut aati hai par nhin aati

Kaaba kis muh se jaoge Ghalib
Sharam tumko magar nhin aati

-Mirza Ghalib