What I learnt this month: February 2025


February was largely spent in interview prep. I am on the lookout for a new job. Interested in hiring me ? Please reach out to me.

Continuing on reading Algorithms for Massive Data Sets:

  1. Got the intuition of HyperLogLog (probably will write a post on it later this year)
  2. Skipped the chapters on Sampling, T and Q-digests. I feel like the book sometimes rushes through the concepts and it is hard for me to grok them as I do not understand Probability Theory well. After having hit the 30s, retrospectively if I could go back to my 20s or earlier and learn one area of Mathematics really well, it would probably be Probability Theory (and discrete mathematics). Probability Theory seems to be pretty universal in Computer Science, from Softmax layers in Neural Networks to designing pseudo random generators and testing them. And speaking of Random Number generators

Random numbers and statistics

Many moons ago, I tried to implement a Mersenne Twister to generate pseudo-random numbers and was trying to figure out how random number generators are tested The testing goes as follows: If you are uniformly sampling from a range 0-n, then you generate, say 1000 samples and then measure the statistical properties of the generated distrubtion: such as the mean, variance etc and compare the properties to that of the actual distribution using Statistical tests like Chi-Square Goodness of Fit test or the Kolmogorov-Smirnov Test.

When I was reading up papers on how Random Number generators are tested, one of the papers that came up was from Prof. Pierre L’ Ecuyer of the University of Montreal, Canda. His Bio turned out to be of one of those mad geniuses that spend an entire lifetime dedicated to one topic: advancing science and engineering as a whole. It was amazing to see a person dedicate more than a decade to the singular pursuit of knowledge in a single topic.

Other projects

Ran out of time on working on my Rust implementation of nsync. Will I get time in March ? Unlikely, most likely will have to schedule this project to Q2

Learning about CSS animations ! They are so cool. Do you know that you can make full animation sequences by using CSS to define keyframes and let CSS do the remaining work ? Here is a good guide

Also, did you notice a pulsing blue bar on the right side of the page, to the left of the scrollbar ? Animated via pure CSS ! CSS animations also run directly on the GPU, taxing your CPU less !

CSS has variables these days !

Understanding the need for Sequential Consistency in Memory Ordering.

Sequential Consistency or SeqCst is a stricter form of Memory Ordering (compared to Acquire / Release Semantics). As I was reading through the Rust Atomics and Locks book I couldn’t really understand when and why I would need SeqCst. However a lucky example on X gave me the impetus to understand it better

Imagine that there are 2 boolean atomic variables X and Y.

Thread A updates X to True and Thread B updates Y to true.

Threads C waits for X to be set and loads Y. If Y is true, then it increments Z

Thread D waits for Y to be set and loads X. If X is true, then it increments Z

The main threads waits for C & D to finish and assert that Z != 0. Could it happen that Z is 0 ?

Turns out, it might be possible !

Since X and Y are written by 2 different threads, there is no guarantee that both C & D see the same order of update for X & Y. The memory reordering rules of processors like ARM could allow Threads C & D to see memory updates for X & Y in different orders. SeqCst operations appear consistent (as in if X is written with ordering SeqCst and Y is written with ordering SeqCst, then all threads will see either X, Y or Y,X, but not both X,Y and Y,X). A detailed investigation will follow in March.

Potential Side Projects to pursue in March

  1. Beg,plead,cajole or beat myself into starting work on the nsync in Rust project.

  2. TODO: Learn how hooks like useState’s are implemented

Interesting blog posts and sites

  1. MESI protocol visualizer : https://www.scss.tcd.ie/Jeremy.Jones/vivio/caches/MESIHelp.htm
  2. API for implementing Real numbers: https://dl.acm.org/doi/pdf/10.1145/3385412.3386037 (this paper was inspired by a super awesome thread on how Google implemented a better calculator App compared to iOS)
  3. ABA problem in Rust how to solve https://minikin.me/blog/solving-the-aba-problem-in-rust-tagged-pointers
  4. Are you interested in designing lenses ? Read this fantastic article !