Multi Threaded File IO

Thu Jan 31 2019


Suppose that you have a large quantity of files that you want your program to ingest. Is it faster to sequentially read each file or, read the files in parallel using multiple threads? Browsing this question online will give varied answers from confused people on discussion threads. Reading resent research papers on multi threaded IO did not quite provide a clear answer my question.

A ton of people argue that multiple threads don’t increase file throughput because at the end of the day a HHD can only read one file at a time. Adding more CPU cores into the mix would actually slow down the file ingest because the HHD would have to take turns between reading fragments of different files. The seek speed of the HHD would heavily degrade the performance.

College Cookbook

Wed Jan 23 2019

I occasionally cooked during High School, however, college was my first real experience cooking on a daily basis. Since I have lived to tell the tail, I want to share some of the recipes that I created/modified which got me through my first two years of college.

Level 1: Cooking in the Dorms

Being stuck in a dorm room you are limited to only being able to use the microwave. Desperate times calls for depraved cooking solutions.

Ramen Pizza

Romen Pizza Final Result
Romen Pizza Final Result

Lazy Loading Youtube Videos

Fri Jan 11 2019


The concept of lazy loading is a design pattern where you only download the required scripts/content when the client needs it rather than when the page is loaded. The most iconic example is the “infinite” feed that social media sites like Instagram use. Rather than dump a ton of content to the client at once, Instagram dynamically loads more content once you reach the end of the page. This allows websites to save bandwidth by only sending the client what they need when they need it.

When a youtube video is embedded into a website, it pulls a ton of scripts which are required to play the video. However, when you embed a youtube video on a blog post, most people are not going to watch that video. Even if the visitor wanted to watch that video, there is no reason why all the scripts should be loaded when you initially land on the page. Rather than embed the video normally, you can instead simply have a the thumbnail of the video with a play button on it. When the client clicks the play button, the youtube scripts are then loaded.

Performance Without Lazy Loading

Before Performance Score
Before Performance Score
Before Table Analysis of embedded youtube videos
Before Table Analysis of embedded youtube videos

Sorting Algorithms

Sat Dec 15 2018

Insertion Sort

Selection sort although not very efficient is often used when the arrays you are sorting are very small. Another benefit of insertion sort is that it is very easy to program. Essentially, this algorithm has a sorted section which slowly grows as it pull in new elements to their sorted position.

Functional Notation

\[ s([]) = []\\ s(x::xs) = i(x, s(xs)) \]

Knapsack Problem

Tue Dec 11 2018

In this post I will go over how you can frame a question in terms of recursion and then slowly massage the question into a dynamic programming question.

Problem Description

The knapsack problem is a famous optimization problem in computer science. Given a set of items, a thief has to determine which items he should steal to maximize his total profits. The thief knows the maximum capacity of his knapsack and the weights and values of all the items.