
What I learnt this month: February 2025
Most of Feb had gone into interview prep. I am on the lookout for a new job. Interested in hiring me ? Please reach out to me.
Continuing on Algorithms for massive data sets:
- Got the intuition of HyperLogLog (probably will write a post on it later this year)
- Skipped the chapters on Sampling and 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 the underlying probability theory well. After hitting my 30s, I feel that I could go back to the 20s or earlier and learn one area of Mathematics really well, it would probably be Probability Theory and some elementary discrete mathematics. Probability theory is one of the few areas of Math that seem pretty universal in Computer Science, from softmax layers in Neural Networks to designing pseudo random generators and testing them.
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 the random number generators are tested The testing goes as follows: if you are uniformly sampling from a range 0-n, then you can generate, say 1000 samples and then measure the statistical properties of the generated distrubtion, such as mean, variance etc and compare the properties to that of the actual distribution. Statistical tests like Chi-Qquare Goodness of fit test and Kolmogorov Smirnov Tests are used for this purpose.
During that time, I was reading the papers on how Random Number generators are tested and one of the papers that came up was from Prof. Pierre L’ Ecuyer from 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. He has written many papers on implementing better, faster and more rigorous random number generators than anyone else https://scholar.google.com/scholar?start=40&q=Pierre+L%27+Ecuyer&hl=en&as_sdt=0,5
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
-
Beg,plead,cajole or beat myself into starting work on the
nsync
in Rust project. -
TODO: Learn how hooks like useState’s are implemented and figure out How react works
Interesting blog posts and sites
- MESI protocol visualizer : https://www.scss.tcd.ie/Jeremy.Jones/vivio/caches/MESIHelp.htm
- 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)
- ABA problem in Rust how to solve https://minikin.me/blog/solving-the-aba-problem-in-rust-tagged-pointers
- Are you interested in designing lenes ? Read this article !