<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[Sladyn’s Substack]]></title><description><![CDATA[My personal Substack]]></description><link>https://sladynnunes.substack.com</link><image><url>https://substackcdn.com/image/fetch/$s_!fNfS!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a2f5a74-3d23-48a2-a315-b36f2172e84a_1200x1200.png</url><title>Sladyn’s Substack</title><link>https://sladynnunes.substack.com</link></image><generator>Substack</generator><lastBuildDate>Sat, 01 Aug 2026 08:58:05 GMT</lastBuildDate><atom:link href="https://sladynnunes.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Sladyn Nunes]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[sladynnunes@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[sladynnunes@substack.com]]></itunes:email><itunes:name><![CDATA[Sladyn Nunes]]></itunes:name></itunes:owner><itunes:author><![CDATA[Sladyn Nunes]]></itunes:author><googleplay:owner><![CDATA[sladynnunes@substack.com]]></googleplay:owner><googleplay:email><![CDATA[sladynnunes@substack.com]]></googleplay:email><googleplay:author><![CDATA[Sladyn Nunes]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Writing an LLM inference loop]]></title><description><![CDATA[lets learn a bit of how Large Language models run an inference loop from scratch]]></description><link>https://sladynnunes.substack.com/p/writing-an-llm-inference-loop</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/writing-an-llm-inference-loop</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Sat, 04 Jul 2026 23:46:01 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fNfS!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a2f5a74-3d23-48a2-a315-b36f2172e84a_1200x1200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When you write a simple prompt in claude or chatgpt i always wondered what happens behind the scenes. For the sake of this article we are not going to be diving into the architecure of how all of this is setup. and the training of the model itslef. <br><br>Lets just dive into the loop that takes the input tokens, runs what we call inference i.e get the output from the input and what the model predicts and then outputs it on the screen. </p><p>Lets the goal of the model here. The model takes the tokens seen so far, runs attention over those context tokens build a representation of the current state, and then outputs logits: one raw score for each token in the vocabulary. Those logits represent how likely each vocabulary token is to be the next token.<br><br>Lets now divide this process into steps that require to produce an output token. </p><ul><li><p><strong>Encode</strong> </p><ul><li><p>Takes in the input text and converts it into token ids using a vocabulary tokneizer</p></li><li><p>For the words that do not have a corresponding token id we have some unknown token ids that can be returned for example &#8220;&lt;unk&gt;&#8221;</p></li><li><p>The output is a dictionary that you can use to convert each token into token ids</p></li></ul></li><li><p><strong>Decode</strong></p><ul><li><p>This is pretty straightforward this step is usually done at the end. This converts the token id back into the word to output. </p></li></ul></li><li><p><strong>Forward Pass</strong></p><ul><li><p>The forward pass takes the token ids seen so far and produces logits</p></li><li><p>Basically you take all the input tokens put them in the array and give it a score based on the logits that the model has prepared. This is the part we assume for the purposes of this article is a black box (Part of the model generating these logits using attention mechansims)</p></li><li><p>In the forward pass you create an array of the predicted words with its respective logits, these logits are raw scores for every possible next token in the vocabulary.</p></li></ul></li><li><p><strong>Softmax and Temperature</strong></p><ul><li><p>Once you have the set of logits they are not a set of probabilites so we need to be able to convert them into probabilities for which you need the softmax function. </p></li><li><p>You can read about softmax here. https://en.wikipedia.org/wiki/Softmax_function</p></li><li><p>These set of probabilities are now easier to reason about and predict the next token against.</p></li><li><p> We have another concept here called as temperatures temperature controls how random the next-token selection is. We apply it by dividing each logit by a value T before softmax.</p><ul><li><p> If T &lt; 1, the distribution becomes sharper. The highest-scoring tokens become even more likely.</p></li><li><p>If T &gt; 1, the distribution becomes flatter. Lower-scoring tokens get more chance,  which can make the output more varied or creative.</p></li></ul></li></ul></li><li><p><strong>Sampling:</strong></p><ul><li><p> Once we have probabilities, we sample the next token. We pick a random number between 0 and 1, then use the cumulative probability ranges to decide which token gets selected.</p></li><li><p>For example, if the probabilities are [0.1, 0.2, 0.7], the ranges are:</p><p>  0.0 to 0.1 -&gt; token 0</p><p>  0.1 to 0.3 -&gt; token 1</p><p>  0.3 to 1.0 -&gt; token 2</p><p>  A token with a larger probability owns a larger part of the 0 to 1 range, so the</p><p>  random number is more likely to land on it.</p></li></ul></li></ul><p>This is the basic loop of inference, i have a small github repo where i will upload the code for this, but this is the gist of it. In the future lets keep building on this base.<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></p>]]></content:encoded></item><item><title><![CDATA[Inference: Prefill and Decode]]></title><description><![CDATA[No conversation about inference can happen without these two important operations, i.e Prefill and Decode.]]></description><link>https://sladynnunes.substack.com/p/inference-prefill-and-decode</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/inference-prefill-and-decode</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Fri, 27 Mar 2026 07:39:19 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!qDZw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c154b2-8949-4911-8c84-cb0fa8ac12a4_1600x893.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>No conversation about inference can happen without these two important operations, i.e Prefill and Decode. If you have not yet read my previous blog on Inference: core loop of an inference engine you should go check it out. It sets up the base for understanding what does a core loop of inference does at it very core.</p><p><strong>Intuition behind needing these operations:</strong> You see in a GPU which is a graphics processing unit, cores are at a premium, the cores are what do the heavy operations inside, read the matrix multiplications i.e the very core operation inside an LLM. Keeping the internal architecture of the LLM for a different discussion i want you to understand that Prefill is an expensive operation it is the operation that uses a lot of the GPU to run the prompt tokens <strong>through the model using the existing weights</strong> to compute the hidden states its attention outputs and most importantly, <strong>keys</strong> and values for the KV cache</p><p>Decode on the other hand is an operation that is sequential because it is generate for every token and hence, its less parallel and usually uses one token at a time and is often more memory-bound rather than compute bound</p><p>There is an important pre-req that i have left out of this discussion is the KV cache, but I feel I would be doing injustice to this entire concept if I explained that earlier. We would need to spend some time understanding the internal workings of a an LLM first</p><p>Why cant they be run concurrently ? For a single request, prefill must happen before decode because decode depends on the prompt&#8217;s computed state and across many requests, inference engines may interleave prefill and decode, but doing so efficiently is hard because the two phases stress the GPU differently and therefore we need to</p><p><strong>Diagram:</strong></p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qDZw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c154b2-8949-4911-8c84-cb0fa8ac12a4_1600x893.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qDZw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c154b2-8949-4911-8c84-cb0fa8ac12a4_1600x893.png 424w, https://substackcdn.com/image/fetch/$s_!qDZw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c154b2-8949-4911-8c84-cb0fa8ac12a4_1600x893.png 848w, https://substackcdn.com/image/fetch/$s_!qDZw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c154b2-8949-4911-8c84-cb0fa8ac12a4_1600x893.png 1272w, https://substackcdn.com/image/fetch/$s_!qDZw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c154b2-8949-4911-8c84-cb0fa8ac12a4_1600x893.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qDZw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c154b2-8949-4911-8c84-cb0fa8ac12a4_1600x893.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/26c154b2-8949-4911-8c84-cb0fa8ac12a4_1600x893.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1924028,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://sladynnunes.substack.com/i/192287176?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c154b2-8949-4911-8c84-cb0fa8ac12a4_1600x893.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qDZw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c154b2-8949-4911-8c84-cb0fa8ac12a4_1600x893.png 424w, https://substackcdn.com/image/fetch/$s_!qDZw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c154b2-8949-4911-8c84-cb0fa8ac12a4_1600x893.png 848w, https://substackcdn.com/image/fetch/$s_!qDZw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c154b2-8949-4911-8c84-cb0fa8ac12a4_1600x893.png 1272w, https://substackcdn.com/image/fetch/$s_!qDZw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26c154b2-8949-4911-8c84-cb0fa8ac12a4_1600x893.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p>]]></content:encoded></item><item><title><![CDATA[Learnings from Mankind's search for meaning]]></title><description><![CDATA[Meaning can turn into hope when everything is lost, is kind of the crux of this book. It does a good job of outlining what it really means to have a purpose, or something to look forward to.]]></description><link>https://sladynnunes.substack.com/p/learnings-from-mankinds-search-for</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/learnings-from-mankinds-search-for</guid><pubDate>Thu, 20 Nov 2025 07:35:27 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fNfS!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a2f5a74-3d23-48a2-a315-b36f2172e84a_1200x1200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I want to take a different approach to writing this, i want to outline what the idea is and then what my takeaway is from that idea. </p><p></p><p><strong>Life has meaning even in extreme situations<br></strong>Victor Frankl dives deep into this idea of how a human can have meaning even in the most dire of situations, and how man can choose how you feel about certain things when life can get really hard. My takeaway from this is no matter how hard things get or whatever your going through, we might not have extreme control or any control at all over it, its really important to have a purpose beyond the situation, like a future goal, a task, or even something that you want to achieve, which might make the situation a bit more tolerable in the current moment. </p><p><br><strong>The collapse of the why</strong> <br>In the book victor introduces us to idea of a &#8220;will to meaning&#8221; which means that most people suffer not from a lack of comfort but from a lack of &#8220;Why&#8221;. When the why collapses people start to feel empty, depressed, and other such feelings. The author calls it &#8220;existential vaccum&#8221;. My takeaway from this idea is to achieve something special you do not need motivation, all you need is a strong why. The answer to the question of what to pursue in life comes from the why. Its a very common reason as to why you see a lot of the people go through a large portion of their lives without any purpose and then reach their late 30s and realize that they do not have a strong why to their. Mid-life crisis  and its very idea has its foundations in the lack of why. </p><p></p><p><strong>Three main ways we find meaning</strong><br>The author says there are three major sources of meaning.</p><ul><li><p>By creating or doing something. </p></li><li><p>By experiencing something or encountering someone</p></li><li><p>By the attitude we take toward unavoidable suffering</p></li></ul><p>Between the three i think the one that speaks to me the most is the creating or doing something. The ability to express my creativity is one of the most thrilling experiences. I am an engineer by profression, so coding and playing around with computers is what i do for a living. Being able to learn, understand an deep dive into concepts is what brings me the most meaning. So thats my takeaway from this idea. </p><p></p><p><strong>Tragic optimism</strong> <br>The last idea that i wanted to touch upon, is no matter what youre going through having an attitude of learning and believeing that its going to be all right is the foundation of the idea of tragic optimism. For example doing something wrong can teach you about not repeating that thing again. Understanding that this present moment of hardships is just a learning opportunity for the future. </p><h5></h5>]]></content:encoded></item><item><title><![CDATA[File Descriptors: Part 2]]></title><description><![CDATA[Lets take a look at the second part of file descriptors which are the various tables involved in a file descriptor]]></description><link>https://sladynnunes.substack.com/p/file-descriptors-part-2</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/file-descriptors-part-2</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Sun, 02 Nov 2025 07:16:55 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!IN1T!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80dffdc1-5b2b-4f49-9a60-8f7ec2dc031e_2492x1474.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Looking at file descriptors and the next part. So a bit of pre-requisites first</p><ul><li><p>Every process has its own task struct. And in that task struct is basically a field which is a pointer to struct called file_struct </p></li><li><p>File descriptor table lives as a filed inside this file_struct as fdtable which is a growing array of struct_file* </p></li><li><p>Dentry (directory entry) is an in-memory record that maps a name inside a directory to an inode.</p><p></p></li></ul><p>So in this blog we are going to be diving deeper into the structures of these tables. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IN1T!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80dffdc1-5b2b-4f49-9a60-8f7ec2dc031e_2492x1474.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IN1T!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80dffdc1-5b2b-4f49-9a60-8f7ec2dc031e_2492x1474.png 424w, https://substackcdn.com/image/fetch/$s_!IN1T!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80dffdc1-5b2b-4f49-9a60-8f7ec2dc031e_2492x1474.png 848w, https://substackcdn.com/image/fetch/$s_!IN1T!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80dffdc1-5b2b-4f49-9a60-8f7ec2dc031e_2492x1474.png 1272w, https://substackcdn.com/image/fetch/$s_!IN1T!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80dffdc1-5b2b-4f49-9a60-8f7ec2dc031e_2492x1474.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IN1T!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80dffdc1-5b2b-4f49-9a60-8f7ec2dc031e_2492x1474.png" width="1456" height="861" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/80dffdc1-5b2b-4f49-9a60-8f7ec2dc031e_2492x1474.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:861,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Relationship between process file descriptors, system-wide open file description table and files&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Relationship between process file descriptors, system-wide open file description table and files" title="Relationship between process file descriptors, system-wide open file description table and files" srcset="https://substackcdn.com/image/fetch/$s_!IN1T!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80dffdc1-5b2b-4f49-9a60-8f7ec2dc031e_2492x1474.png 424w, https://substackcdn.com/image/fetch/$s_!IN1T!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80dffdc1-5b2b-4f49-9a60-8f7ec2dc031e_2492x1474.png 848w, https://substackcdn.com/image/fetch/$s_!IN1T!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80dffdc1-5b2b-4f49-9a60-8f7ec2dc031e_2492x1474.png 1272w, https://substackcdn.com/image/fetch/$s_!IN1T!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80dffdc1-5b2b-4f49-9a60-8f7ec2dc031e_2492x1474.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>So the columns in the file descriptor table are two fold one is the list of file descriptors which as I explained in the previous blog are integers from 0 to per- RLIMIT_NOFILE per process.</p><h4>Open File Description Table  </h4><p>Each entry in the file descriptor table maps to a <code>struct file</code> which is basically an open file description. This points to an entry in the open file descriptor table which is like a table consisting of all of the file entries currently. Internally it is just a collection of all of the open file descriptors that each individual file descriptor of a process points to.<br><code>struct file</code> holds the <strong>offset</strong> (<code>f_pos</code>), <strong>status flags</strong> (<code>f_flags</code>, e.g., <code>O_APPEND</code>, <code>O_NONBLOCK</code>, <code>O_SYNC</code>, <code>O_DIRECT</code>) and <strong>access mode</strong> (<code>f_mode</code>). I will go into what these flags are in part 3 but for now all you need to understand is that each flag has its set of status falgs that its opened with.</p><h4>Inodes</h4><p>Each entry in this open file descriptor table points to the underlying inode inside the file system. Each FD points to a <code>struct file</code>. That <code>struct file</code> has an <code>f_path</code> (mount + dentry). We will deep dive into dentries in another blog, you can look it up or ill put it in the pre-requisites up top. The <strong>dentry</strong> references the <strong>inode</strong>. The inode does <strong>not</strong> store a path; paths are names in dentries  The <strong>inode</strong> holds file <strong>metadata</strong>: permissions, owner, size, timestamps, device/superblock links, etc.</p><p>In the next blog we will dive deep into how dup, dup(2) works on duplicating these file descriptor and how offsets are dealt with as well as wrap up the knowledge we need for these file descriptors. </p>]]></content:encoded></item><item><title><![CDATA[File Descriptors: Part 1]]></title><description><![CDATA[This is an introduction to file descriptors in linux.]]></description><link>https://sladynnunes.substack.com/p/file-descriptors-part-1</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/file-descriptors-part-1</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Sun, 26 Oct 2025 23:43:18 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fNfS!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a2f5a74-3d23-48a2-a315-b36f2172e84a_1200x1200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Lets talk about file descriptors in this blog post. This is an  important topic when talking about linux systems. Literally everything in linux is a file so its important to understand the foundation of a file system which is how files are described.It means <em>many</em> I/O endpoints are exposed as file-like: regular files, pipes, sockets, devices etc. </p><p><strong>What are file descriptors ?</strong> <br>They are positive integers starting from 0 all the way to the maximum file descriptor integer. Imagine a process want to open a file, when it calls the open syscall and it assigns an integer in its file descriptor table. It chooses the lowest possible integer available. Once they do this they now have a way of referencing that file in their file descriptor table</p><p><strong>How many FDs can I open?</strong></p><ul><li><p>Per-process: <code>ulimit -n</code></p></li><li><p>System-wide: <code>/proc/sys/fs/file-max</code>.</p></li></ul><p><strong>Why do we need file descriptors ?</strong> <br>There are multiple ways that a process can interact with a file in linux. Processes can read a file, they can write to a file, they can append to a file. These file descriptors help the system keep track of the files they open close and have access to modify. </p><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!J9dv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b7b4d6-f5f4-4d0d-8a53-3a91df4ab2be_325x218.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!J9dv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b7b4d6-f5f4-4d0d-8a53-3a91df4ab2be_325x218.png 424w, https://substackcdn.com/image/fetch/$s_!J9dv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b7b4d6-f5f4-4d0d-8a53-3a91df4ab2be_325x218.png 848w, https://substackcdn.com/image/fetch/$s_!J9dv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b7b4d6-f5f4-4d0d-8a53-3a91df4ab2be_325x218.png 1272w, https://substackcdn.com/image/fetch/$s_!J9dv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b7b4d6-f5f4-4d0d-8a53-3a91df4ab2be_325x218.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!J9dv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b7b4d6-f5f4-4d0d-8a53-3a91df4ab2be_325x218.png" width="325" height="218" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/02b7b4d6-f5f4-4d0d-8a53-3a91df4ab2be_325x218.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:218,&quot;width&quot;:325,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Cheat Sheet - bash redirections - Seb's IT blog&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Cheat Sheet - bash redirections - Seb's IT blog" title="Cheat Sheet - bash redirections - Seb's IT blog" srcset="https://substackcdn.com/image/fetch/$s_!J9dv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b7b4d6-f5f4-4d0d-8a53-3a91df4ab2be_325x218.png 424w, https://substackcdn.com/image/fetch/$s_!J9dv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b7b4d6-f5f4-4d0d-8a53-3a91df4ab2be_325x218.png 848w, https://substackcdn.com/image/fetch/$s_!J9dv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b7b4d6-f5f4-4d0d-8a53-3a91df4ab2be_325x218.png 1272w, https://substackcdn.com/image/fetch/$s_!J9dv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b7b4d6-f5f4-4d0d-8a53-3a91df4ab2be_325x218.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><p><strong>Standard File descriptors (0,1,2) </strong><br>There are three important file descriptors in a linux file system. 0,1,2 are the FDs for the stdin, stdout and stderr. So basically processes use these numbers to either take input, or write out to the terminal. Sometimes they can point to a file as well, but that means that means there is some shell redirection happening. These three FDs are reserved for output and input</p><p><strong>Next part</strong><br>We will look at how the file descriptor table looks like and how syscalls interact with the file descriptors.</p><p></p><p></p>]]></content:encoded></item><item><title><![CDATA[Project Hail Mary stretched my imagination]]></title><description><![CDATA[Project Hail Mary was a very interesting book in terms of pure imagination.]]></description><link>https://sladynnunes.substack.com/p/project-hail-mary-stretched-my-imagination</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/project-hail-mary-stretched-my-imagination</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Sun, 12 Oct 2025 23:11:39 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fNfS!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a2f5a74-3d23-48a2-a315-b36f2172e84a_1200x1200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Project Hail Mary was a very interesting book in terms of pure imagination. I do not read a lot of books and I  have just started getting into the habit of reading books This book was really fun to read just because I love science-fiction just that I was not prepared for the intense imagination involved during various phases. Or my imagination just sucks. Either way it was really fun. I just wanted to note two things that caught me off guard reading this book.<br><br><strong>Scenes had a lot of vivid descriptions</strong><br>I think imagining the physics involved was really challenging. I had to google images to imagine stuff around the space travel and the concepts around it. I wish the book had some images in it. <br><br><strong>High School Physics</strong><br>It had some maths in it to really appreciate what was going on, with time dilation. It was really fun to go back to the stuff i had studied in high school.  Enjoyed this part of the book </p><p><br>I definitely highly recommend this book to all fiction readers, and definitely cannot wait for the movie. Jazz hands ! </p><p></p>]]></content:encoded></item><item><title><![CDATA[Tracing write syscall on a high level]]></title><description><![CDATA[Ever call f.write() in Python and wonder what actually hits the metal.]]></description><link>https://sladynnunes.substack.com/p/tracing-write-syscall-on-a-high-level</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/tracing-write-syscall-on-a-high-level</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Sun, 12 Oct 2025 22:19:01 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!B0cD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F442b1bc2-f198-49fa-98f0-7bfbde1903e9_1234x1079.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Ever call <code>f.write()</code> in Python and wonder what <em>actually</em> hits the metal. Lets say you are writing a python function which involves writing to a file.  Do you wonder what happens on a kernel level when writing that function. Lets trace a function call as it goes through to the kernel level</p><p><strong>Pre-requisites</strong></p><ul><li><p>User space and kernel space: Linux runs applications in two modes, one is the kernel mode which is the most privileged in terms of permissions and the user mode which is the least privileged. System calls run in kernel mode is something that is an important pre-req to understanding how they trace</p></li><li><p>Traps: There is something called as a trap in a linux kernel. This is kind of like a synchronous CPU exception where we transfer control from the user space to the kernel space. These are different from interrupts are asynchronous and come from hardware</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!B0cD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F442b1bc2-f198-49fa-98f0-7bfbde1903e9_1234x1079.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!B0cD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F442b1bc2-f198-49fa-98f0-7bfbde1903e9_1234x1079.png 424w, https://substackcdn.com/image/fetch/$s_!B0cD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F442b1bc2-f198-49fa-98f0-7bfbde1903e9_1234x1079.png 848w, https://substackcdn.com/image/fetch/$s_!B0cD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F442b1bc2-f198-49fa-98f0-7bfbde1903e9_1234x1079.png 1272w, https://substackcdn.com/image/fetch/$s_!B0cD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F442b1bc2-f198-49fa-98f0-7bfbde1903e9_1234x1079.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!B0cD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F442b1bc2-f198-49fa-98f0-7bfbde1903e9_1234x1079.png" width="1234" height="1079" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/442b1bc2-f198-49fa-98f0-7bfbde1903e9_1234x1079.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1079,&quot;width&quot;:1234,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:91596,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://sladynnunes.substack.com/i/175986476?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F442b1bc2-f198-49fa-98f0-7bfbde1903e9_1234x1079.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!B0cD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F442b1bc2-f198-49fa-98f0-7bfbde1903e9_1234x1079.png 424w, https://substackcdn.com/image/fetch/$s_!B0cD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F442b1bc2-f198-49fa-98f0-7bfbde1903e9_1234x1079.png 848w, https://substackcdn.com/image/fetch/$s_!B0cD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F442b1bc2-f198-49fa-98f0-7bfbde1903e9_1234x1079.png 1272w, https://substackcdn.com/image/fetch/$s_!B0cD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F442b1bc2-f198-49fa-98f0-7bfbde1903e9_1234x1079.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p><strong>Step 1: Transfer from a user space to a kernel space</strong><br>When python makes the write() call it calls in to a libc `write` wrapper which loads the syscalls and the values into registers and then executes the syscall.  This point is the main transfer interface to a kernel level space. </p><p><strong>Step 2: Trapframe and copying of user register</strong><br>On entry, the kernel saves user registers into <code>pt_regs</code> (the trapframe) so it can return or deliver signals later. This is basically a snapshot of the user context. It generates this so that it can restart syscalls if needed, return to the user context if needed, or deliver signals</p><p><strong>Step 3: Execution of the syscall and returns control<br></strong>We now have all the steps in place, the kernel then executes the appropriate syscall after reading from <code>rax</code> and then calls the &#8212;x64_sys_write. This then resolves to vfs_write which is the virtual file system call. Now it needs to copy the buffers and does so with (copy_from_user). With all the values it requires and then writes the buffer at the correct position. Once that is complete it returns control using sysretq and puts the return value back in rax.</p><p><br>Note: This is just a high level trace of the write system call and there is a lot of depth to be covered, but its a great introduction to understanding the execution of a syscall. </p>]]></content:encoded></item><item><title><![CDATA[Master debugging by using print statements the right way]]></title><description><![CDATA[TL;DR]]></description><link>https://sladynnunes.substack.com/p/master-debugging-by-using-print-statements</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/master-debugging-by-using-print-statements</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Thu, 09 Oct 2025 07:29:24 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fNfS!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a2f5a74-3d23-48a2-a315-b36f2172e84a_1200x1200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p> <strong>TL;DR</strong> </p><p>Print statements are the fastest way to <strong>see</strong> what your code is doing.<br>Use a small set of <strong>repeatable print patterns</strong> to expose inputs, branches, loops, recursion depth, and thread order in multithreading examples. </p><p>When i started programming one of the things that helped me majorly was the ability to add print statements anywhere. New programmers get stuck because code feels invisible.  When you start out programming most of the programs you can write will have stuff that you can print out for example, just as a preface i wanted to mention that incase you did not want/or necessarily bog yourself down by learning to use a debugger you could reduce that friction by using print statements. I plan to enunciate this concept with a few use cases. </p><p>Quick print tips that help across all use cases:</p><ul><li><p>add labels so you know what a number/string belongs to: <code>print(&#8221;i:&#8221;, i)</code> not just <code>print(i)</code>.</p></li><li><p>make the prints easy to scan: use short prefixes like <code>[STEP]</code>, <code>[EDGE]</code>, <code>[OK]</code>.</p></li><li><p>show both the value and the type when you&#8217;re confused: <code>print(&#8221;x=&#8221;, x, type(x))</code>.</p></li><li><p>for strings or whitespacey stuff, show the repr: <code>print(repr(s))</code> so you can see hidden chars.</p></li><li><p>when order matters, include a simple counter or timestamp.</p></li></ul><p><br><strong>Use Case #1 Trace values for pattern spotting</strong><br>Write a program to test whether a given string has a palindromic substring<br>You can probably one shot this program using an LLM nowadays, but the goal here is to learn. so as you probably go through the problem one of the ways would be to prints all substrings, look at them visually and then see if you spot patterns. Once you spot a pattern you will probably be able to code it out. Now that code might have bugs, so one of the way you can probably start to debug that is voila Add print statements and figure out why is the edge case not what you expect. </p><p><strong>Use Case # 2: Print recursion depth to make call order click</strong><br>Recursion is a concept that a lot of programmers struggle to get their head around.A simple hack is to put down a print statement in the parent function and the function you plan to recurse over. And add something like print(&#8220;Printing from current function&#8221;). This will give you a picture in your head on the sequence of instructions getting executed. Our brains love to see sequential ordering and having print statements will let you visualize this .</p><ul><li><p><strong>What:</strong> Add <strong>depth markers</strong> and entry/exit prints in recursive functions.</p></li><li><p><strong>Why:</strong> Humans love sequences and depth shows the stack growing and shrinking. With arrows and indents, we can literally  <strong>see</strong> &#8220;go down, come back up,&#8221; which fixes mental models fast.</p></li></ul><p><strong>Use Case #3 Timestamp threads to spot flow of threading</strong><br>When learning programming an important concept that we learn, and just for context, multithreading is when you run a program using multiple threads so that the work that a single thread can do is now being done by multiple threads and the coder can then either consolidate those results or use them individually. The hard part here is sometimes figuring out bugs, and one of the ways to do it is to plug in print statements for what you expect to happen at the end for example. </p><ul><li><p><strong>What:</strong> In multithreading, add <strong>thread name + timestamp</strong> to prints.</p></li><li><p><strong>Why: </strong>Timestamps reveal unexpected order</p></li></ul><p><br>Food for thought</p><ul><li><p>Where did a <strong>print-first approach</strong> save you time when you first started programming. <br><br></p></li></ul>]]></content:encoded></item><item><title><![CDATA[Context Rot: 4 Lessons I’m Applying from Anthropic (Part 1)]]></title><description><![CDATA[TL;DR &#8212; Long contexts make agents dumber and slower.]]></description><link>https://sladynnunes.substack.com/p/context-rot-4-lessons-im-applying</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/context-rot-4-lessons-im-applying</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Thu, 09 Oct 2025 06:38:55 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fNfS!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a2f5a74-3d23-48a2-a315-b36f2172e84a_1200x1200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>TL;DR &#8212; Long contexts make agents dumber and slower. Fix it by compressing to high-signal tokens, ditching brittle rule piles, and using tools as just-in-time memory. </p><p>I read Anthropic&#8217;s post on context rot and turned the ideas into things I can ship. Below are the 4 changes I&#8217;m making to keep agents sharp as context grows</p><p><strong>Compress to high-signal context<br></strong>There is an increasing need to prompt agents with information that is sufficient to do the task. If the context is too long agents suffer from attention span deficiency i.e they lose attention and seem to get confused. So one of the ways to avoid this is to ensure the context given to the agent is short but conveys a lot of meaning.   One important line from the blog is: LLMs are based on the <a href="https://arxiv.org/abs/1706.03762">transformer architecture</a>, which enables every token to <a href="https://huggingface.co/blog/Esmail-AGumaan/attention-is-all-you-need">attend to every other token</a> across the entire context, This results in n&#178; pairwise relationships for n tokens. (Not sure what this means entirely ) . <em>Models have less experience with long sequences</em> and use interpolation to extend</p><p><strong> Ditch brittle rule piles</strong><br>Anthropic suggests avoiding <em>brittle</em> rule piles rather use clear, minimal instructions and <em>canonical examples</em> (few-shot) rather than laundry lists in the context for LLMs. They give example of context windows that try to gain a deterministic output from the agent which leads to further maintenance complexity from the agent. It should be flexible enough to allow the model heuristic behaviour. The blog form anthropic advises users to use markdown headings with their prompts to ensure separation, although LLms are getting more capable eventually. </p><p><strong>Use tools as just-in-time memory</strong><br>As the definition of agents change we have noticed that agents use tools to load context into their working memory. Since tools provide agents with information they need to complete their tasks we notice that tools are moving towards becoming just in time context providers for example load_webpage could load the text of the webpage into context. They say that the field is moving towards a more hybrid approach, where there is a mix of just in time tool providers and a set of instructions at the start. Having to go through a file such as `<strong>agent.md</strong>` that would guide the llm on what tools it has at their disposal and what structures contain important information would allow the agent to avoid dead ends and waste time in exploring the problem space by themselves. </p><p><strong>Learning Takeaways</strong></p><ul><li><p>Compress to high-signal context. </p></li><li><p>Write non-brittle system prompts.</p></li><li><p>Adopt hybrid context: up-front + just-in-time tools.</p></li><li><p>Plan for long-horizon work.</p><p></p></li></ul><p>If you run have tried things that work reply with what you;ve learnt.<br></p><p></p>]]></content:encoded></item><item><title><![CDATA[Reading code is as important as writing it]]></title><description><![CDATA[Actionable steps in reading code.]]></description><link>https://sladynnunes.substack.com/p/reading-code-is-as-important-as-writing</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/reading-code-is-as-important-as-writing</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Mon, 06 Oct 2025 01:02:42 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fNfS!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a2f5a74-3d23-48a2-a315-b36f2172e84a_1200x1200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When you are starting to learn programming, reading code can be an intimidating. You open a file, see dozens of functions, and instantly get lost. But learning to <em>read</em> code well is just as important as writing it. I have a few actionable tips to get started with reading code</p><ul><li><p>Make a mental map of the functions:</p><ul><li><p>When your going through the code always try a high level outline of the file and then build on that towards. Like for example, start at the top of the file and go through the functions clicking on them to go towards the source code</p></li></ul></li><li><p>Run the code through a debugger :</p><ul><li><p>One of the underrated ways to understand a codebase is to run the code that you are reading through a debugger. Attach a breakpoint and the simulate running the code, you will understand the flow of the code extremely well.</p></li></ul></li><li><p>Start from the test cases:</p><ul><li><p>If the project has test cases, that&#8217;s your entry point. Run them and <em>watch what happens</em>.</p><ul><li><p>What objects are being created?</p></li><li><p>Which functions are called first?</p></li><li><p>What files are imported?</p></li></ul></li></ul></li></ul><p>Learning to read code well takes time. You won&#8217;t understand everything the first time and that&#8217;s okay. But if you repeat this process across 3/4 small projects, your brain starts to see code structure naturally.</p>]]></content:encoded></item><item><title><![CDATA[What Actually Happens When you run a goroutine]]></title><description><![CDATA[Lets look at how the go scheduler works.]]></description><link>https://sladynnunes.substack.com/p/what-actually-happens-when-you-run</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/what-actually-happens-when-you-run</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Sun, 05 Oct 2025 22:37:05 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Facj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac58de3-7dbb-4a88-9760-8df905d90758_1745x1075.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Lets look at what happens when we write a go routine in golang and how does the scheduler deal with it. </p><p> Goroutine scheduler: The scheduler&#8217;s job is to distribute ready-to-run goroutines over worker threads.</p><p>When you write go f(), the go compiler and runtime arrange to do the following:</p><ul><li><p>It allocates a small descriptor for the goroutine and a small initial stack</p></li><li><p>Records the entry function f and its arguments in that descriptor</p></li><li><p>Place this new goroutine onto a run queue so it can be scheduled.</p><p></p></li></ul><p>Lets understand what is the schedulers basic model</p><ul><li><p><strong>G</strong> = The goroutine which has the function the stack and the metadata</p></li><li><p><strong>M</strong> = The OS thread that actually runs code on a CPU core</p></li><li><p><strong>P</strong> = The processor that allows an OS thread to run code. It owns queues of go routines.</p></li></ul><h3><br>Diagram</h3><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Facj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac58de3-7dbb-4a88-9760-8df905d90758_1745x1075.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Facj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac58de3-7dbb-4a88-9760-8df905d90758_1745x1075.png 424w, https://substackcdn.com/image/fetch/$s_!Facj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac58de3-7dbb-4a88-9760-8df905d90758_1745x1075.png 848w, https://substackcdn.com/image/fetch/$s_!Facj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac58de3-7dbb-4a88-9760-8df905d90758_1745x1075.png 1272w, https://substackcdn.com/image/fetch/$s_!Facj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac58de3-7dbb-4a88-9760-8df905d90758_1745x1075.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Facj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac58de3-7dbb-4a88-9760-8df905d90758_1745x1075.png" width="1456" height="897" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eac58de3-7dbb-4a88-9760-8df905d90758_1745x1075.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:897,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:94466,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://sladynnunes.substack.com/i/175375675?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac58de3-7dbb-4a88-9760-8df905d90758_1745x1075.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Facj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac58de3-7dbb-4a88-9760-8df905d90758_1745x1075.png 424w, https://substackcdn.com/image/fetch/$s_!Facj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac58de3-7dbb-4a88-9760-8df905d90758_1745x1075.png 848w, https://substackcdn.com/image/fetch/$s_!Facj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac58de3-7dbb-4a88-9760-8df905d90758_1745x1075.png 1272w, https://substackcdn.com/image/fetch/$s_!Facj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac58de3-7dbb-4a88-9760-8df905d90758_1745x1075.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h3>How does your function actually get time ?</h3><ol><li><p><code>go f(x)</code> compiles to a call into the runtime  that:</p><ul><li><p>allocates a <strong>G</strong> with a small stack (growable).</p></li><li><p>records entry <code>f</code> and its args.</p></li><li><p>pushes G onto the <strong>current P&#8217;s local run queue</strong> (or global if needed),</p></li><li><p>may <strong>wake/start an M</strong> if there&#8217;s idle work but no running worker.</p></li></ul></li><li><p>An <strong>M</strong> that owns that <strong>P</strong> runs the scheduler loop:</p><ul><li><p><strong>pop</strong> a runnable <strong>G</strong> from the <strong>P&#8217;s local queue</strong> (or global / steal).</p></li><li><p><strong>switch</strong> to the G&#8217;s stack and call <code>f</code>.</p></li><li><p><strong>preempt/park</strong> on syscalls, channel/blocking, GC safepoints etc.</p></li></ul></li><li><p>If a goroutine blocks (syscall/channel), the <strong>M</strong> may park or hand the <strong>P</strong> to another <strong>M</strong> so the run queues keep draining.</p></li></ol><h4>Historical breadcrumb:</h4><ul><li><p>In older Go sources (e.g., Go 1.1 era), you&#8217;ll see the same idea in functions like <code>startm</code>/<code>wakep</code>: when a G becomes runnable, the runtime tries to ensure a <strong>P</strong> has a running <strong>M</strong> so work doesn&#8217;t idle.</p></li><li><p>If you peek at today&#8217;s <code>runtime/</code> code, search for <code>newproc</code>, <code>schedule</code>, <code>runq</code>, and <code>startm</code> in <code>proc.go</code> names are readable even if details changed.</p></li></ul>]]></content:encoded></item><item><title><![CDATA[Multi-Node Broadcast Challenge: Brute force]]></title><description><![CDATA[Send a broadcast message to all nodes]]></description><link>https://sladynnunes.substack.com/p/multi-node-broadcast-challenge-brute</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/multi-node-broadcast-challenge-brute</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Sun, 28 Sep 2025 21:56:45 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!_plL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe43d457e-e5d2-495d-8a96-ff023090b60a_1272x888.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Lets talk about deduplication of values and broadcast of messages. In the previous blog it was extremely simple, all we had to do was broadcast a message and then receive it, ensuring our handlers worked fine. </p><p><strong>Goal:</strong> deliver every unique message to every node.<br><br>In a multi node broadcast system we need to ensure that a message is broadcasted over an entire system. The first idea that came to my mind was pretty simple, when we get a value that is broadcasted, we gather the nodes in the topology that are neighbors of that node and then send to all the neighbors in the list. Pretty simple right and your right it is. </p><p><strong>Note</strong>: When you send a message to a node it sends back a <em><strong>broadcast_ok </strong></em> message back, this is an important piece of information. <br>I did not check for this message, all i did was fire off and forget, which was a grave mistake on my part. </p><h2><br>Steps</h2><p>a) Receive a broadcast message<br>b) Iterate through the neighbors<br>c) Send broadcast message to all neighbors</p><p>The diagram below makes it simple to visualize. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_plL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe43d457e-e5d2-495d-8a96-ff023090b60a_1272x888.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_plL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe43d457e-e5d2-495d-8a96-ff023090b60a_1272x888.png 424w, https://substackcdn.com/image/fetch/$s_!_plL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe43d457e-e5d2-495d-8a96-ff023090b60a_1272x888.png 848w, https://substackcdn.com/image/fetch/$s_!_plL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe43d457e-e5d2-495d-8a96-ff023090b60a_1272x888.png 1272w, https://substackcdn.com/image/fetch/$s_!_plL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe43d457e-e5d2-495d-8a96-ff023090b60a_1272x888.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_plL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe43d457e-e5d2-495d-8a96-ff023090b60a_1272x888.png" width="1272" height="888" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e43d457e-e5d2-495d-8a96-ff023090b60a_1272x888.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:888,&quot;width&quot;:1272,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:54345,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://sladynnunes.substack.com/i/174789361?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe43d457e-e5d2-495d-8a96-ff023090b60a_1272x888.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_plL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe43d457e-e5d2-495d-8a96-ff023090b60a_1272x888.png 424w, https://substackcdn.com/image/fetch/$s_!_plL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe43d457e-e5d2-495d-8a96-ff023090b60a_1272x888.png 848w, https://substackcdn.com/image/fetch/$s_!_plL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe43d457e-e5d2-495d-8a96-ff023090b60a_1272x888.png 1272w, https://substackcdn.com/image/fetch/$s_!_plL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe43d457e-e5d2-495d-8a96-ff023090b60a_1272x888.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h2>Catch</h2><p>The way the challenge is designed it is totally possible that due to a network partition that a node does not send the broadcast message and in that case since the way we have designed the system, we do a send and forget, which clearly did not work in our chase. So the next challenge is to figure out a retry mechanism or some sort of a worker that will retry messages that are not getting broadcasted.  <br><br><strong>Side Notes</strong></p><ul><li><p>Command: <code>maelstrom test -w broadcast --bin ./your_bin --time-limit 20 --node-count 5 --rate 100</code></p></li><li><p>Expect: <strong>no missing deliveries</strong>, <strong>no duplicates</strong>, stable latency</p></li><li><p>Example passing line: <code>:valid? true :lost 0 :duplicated 0 :unexpected 0</code></p></li></ul><p><strong>Takeaway</strong></p><ul><li><p><strong>Idempotency first</strong> (dedup), then <strong>reliability</strong> (acks+retries), then <strong>healing</strong> (anti-entropy).</p></li></ul>]]></content:encoded></item><item><title><![CDATA[Single node broadcast System]]></title><description><![CDATA[Problem Statement: This is a pretty straightforward approach where there are a bunch of single nodes and all they have to do is when they receive a broadcast message they need to store that in their memory and when they receive a read message they return the list of messages they have seen up until now.]]></description><link>https://sladynnunes.substack.com/p/single-node-broadcast-system</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/single-node-broadcast-system</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Fri, 19 Sep 2025 07:02:30 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!9zOY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43363c02-3b8f-444b-810a-daf0c665336d_1400x717.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Problem Statement:</strong> This is a pretty straightforward approach where there are a bunch of single nodes and all they have to do is when they receive a <strong>broadcast</strong> message they need to store that in their memory  and when they receive a <strong>read</strong> message they return the list of messages they have seen up until now. </p><p>The set of messages are a steady stream and they could be of the order of a thousand messages per second. </p><p></p><h3>Architecture</h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9zOY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43363c02-3b8f-444b-810a-daf0c665336d_1400x717.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9zOY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43363c02-3b8f-444b-810a-daf0c665336d_1400x717.png 424w, https://substackcdn.com/image/fetch/$s_!9zOY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43363c02-3b8f-444b-810a-daf0c665336d_1400x717.png 848w, https://substackcdn.com/image/fetch/$s_!9zOY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43363c02-3b8f-444b-810a-daf0c665336d_1400x717.png 1272w, https://substackcdn.com/image/fetch/$s_!9zOY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43363c02-3b8f-444b-810a-daf0c665336d_1400x717.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9zOY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43363c02-3b8f-444b-810a-daf0c665336d_1400x717.png" width="1400" height="717" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/43363c02-3b8f-444b-810a-daf0c665336d_1400x717.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:717,&quot;width&quot;:1400,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:65389,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://sladynnunes.substack.com/i/173999065?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43363c02-3b8f-444b-810a-daf0c665336d_1400x717.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!9zOY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43363c02-3b8f-444b-810a-daf0c665336d_1400x717.png 424w, https://substackcdn.com/image/fetch/$s_!9zOY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43363c02-3b8f-444b-810a-daf0c665336d_1400x717.png 848w, https://substackcdn.com/image/fetch/$s_!9zOY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43363c02-3b8f-444b-810a-daf0c665336d_1400x717.png 1272w, https://substackcdn.com/image/fetch/$s_!9zOY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43363c02-3b8f-444b-810a-daf0c665336d_1400x717.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h3><strong>Approach</strong></h3><p>All we do is when we receive a broadcast we just store those values in a global list and then return that list when asked for it. Every node also has its <strong>topology</strong> i.e it has information about its neighbors where it can store data for that particular node. </p><h3>Next step: Multi Node Broadcast system:</h3><p>Our node should propagate values it sees from <code>broadcast</code> messages to the other nodes in the cluster. It can use the topology passed to your node in the <code>topology</code> message or you can build your own topology.</p>]]></content:encoded></item><item><title><![CDATA[Generating cluster-wide unique IDs ]]></title><description><![CDATA[Lets look at a rather interesting problem that is pretty common in distributed systems where generating unique IDs in a cluster is not as simple as it sounds.]]></description><link>https://sladynnunes.substack.com/p/generating-cluster-wide-unique-ids</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/generating-cluster-wide-unique-ids</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Sun, 14 Sep 2025 18:38:52 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!7VEy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05d3aeca-6ee2-46c2-971d-07b478456863_1479x708.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Lets look at a rather interesting problem that is pretty common in distributed systems where generating unique IDs in a cluster is not as simple as it sounds. Lets begin by defining the problem statement and then build upon the idea. </p><p><strong>Problem statement: Generate a cluster wide unique id, assume that this unique id is provided by a service. This service is replicated on a cluster of nodes each one being stateless.  During increasing load this service can get called multiple times (10,000 times a second) , increasingly so even at the same time. </strong></p><p>Lets explore some ideas of how we can think of this problem. <br><br><strong>Idea 1: Keeping a global set of ids</strong></p><p>This is sort of the first idea that comes to mind. You can ensure uniqueness by just creating a global set of unique integers. We can use random number generator with a seed to spit out a random number. When your random number generator generates a random id you could go check if it exists and if not just insert it in our global set.Easy peasy. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7VEy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05d3aeca-6ee2-46c2-971d-07b478456863_1479x708.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7VEy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05d3aeca-6ee2-46c2-971d-07b478456863_1479x708.png 424w, https://substackcdn.com/image/fetch/$s_!7VEy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05d3aeca-6ee2-46c2-971d-07b478456863_1479x708.png 848w, https://substackcdn.com/image/fetch/$s_!7VEy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05d3aeca-6ee2-46c2-971d-07b478456863_1479x708.png 1272w, https://substackcdn.com/image/fetch/$s_!7VEy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05d3aeca-6ee2-46c2-971d-07b478456863_1479x708.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7VEy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05d3aeca-6ee2-46c2-971d-07b478456863_1479x708.png" width="1456" height="697" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/05d3aeca-6ee2-46c2-971d-07b478456863_1479x708.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:697,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:55786,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://sladynnunes.substack.com/i/173541787?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05d3aeca-6ee2-46c2-971d-07b478456863_1479x708.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!7VEy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05d3aeca-6ee2-46c2-971d-07b478456863_1479x708.png 424w, https://substackcdn.com/image/fetch/$s_!7VEy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05d3aeca-6ee2-46c2-971d-07b478456863_1479x708.png 848w, https://substackcdn.com/image/fetch/$s_!7VEy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05d3aeca-6ee2-46c2-971d-07b478456863_1479x708.png 1272w, https://substackcdn.com/image/fetch/$s_!7VEy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05d3aeca-6ee2-46c2-971d-07b478456863_1479x708.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p><strong>Caveat:</strong> The caveat here is that two nodes could be called at the same time, causing our global table to accessed at the exact same time, since one of the nodes would determine that the key that it is looking for does not exist. We could ensure atomicity by locking the data structure which could be an alternate solution i could have explored but for the simplicity of this exercise I did not go down that route. But it could be an interesting discussion. </p><p><strong>Approach 2: Using the unix microsecond timestamp<br></strong>This approach came next to my mind. We could pull out a unix microsecond function from any language, that  would allow us to be more globally unique since it would take the current timestamp and then convert it into a unix timestamp in microseconds which is an extremely small unit . Return this timestamp to the caller and voila, we have a unique timestamp. This makes the code cleaner and eliminates the unique set we need to keep. Minor win.. or is it ?  </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!AgOg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc08f1dca-917e-41a3-a41b-581c27325cfe_1212x265.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!AgOg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc08f1dca-917e-41a3-a41b-581c27325cfe_1212x265.png 424w, https://substackcdn.com/image/fetch/$s_!AgOg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc08f1dca-917e-41a3-a41b-581c27325cfe_1212x265.png 848w, https://substackcdn.com/image/fetch/$s_!AgOg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc08f1dca-917e-41a3-a41b-581c27325cfe_1212x265.png 1272w, https://substackcdn.com/image/fetch/$s_!AgOg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc08f1dca-917e-41a3-a41b-581c27325cfe_1212x265.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!AgOg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc08f1dca-917e-41a3-a41b-581c27325cfe_1212x265.png" width="1212" height="265" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c08f1dca-917e-41a3-a41b-581c27325cfe_1212x265.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:265,&quot;width&quot;:1212,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:19104,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://sladynnunes.substack.com/i/173541787?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc08f1dca-917e-41a3-a41b-581c27325cfe_1212x265.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!AgOg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc08f1dca-917e-41a3-a41b-581c27325cfe_1212x265.png 424w, https://substackcdn.com/image/fetch/$s_!AgOg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc08f1dca-917e-41a3-a41b-581c27325cfe_1212x265.png 848w, https://substackcdn.com/image/fetch/$s_!AgOg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc08f1dca-917e-41a3-a41b-581c27325cfe_1212x265.png 1272w, https://substackcdn.com/image/fetch/$s_!AgOg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc08f1dca-917e-41a3-a41b-581c27325cfe_1212x265.png 1456w" sizes="100vw"></picture><div></div></div></a></figure></div><p></p><p><strong>Caveat:</strong> in this approach like the last one it could be possible that the function is called simultaneously at the same microsecond (which is thought is unlikely but just assume we have an extremely popular service), therefore it could generate the exact same value, leading to duplicates. At this point its pretty clear we need to have some sort of combination of approaches. </p><p><strong>Approach 3: Combination of microsecond timestamp and a process counter.</strong></p><p>I needed to do some googling to come up with this one. It was not so obvious to me. This approach involves using a shared atomic counter seq that auto increments and would guarantee uniqueness across processes.  Let take an example. </p><p>Node 1:  Timestamp: 10, Shared counter: 1, Final ID: 101<br>Node 2:  Timestamp: 10, Shared counter: 2 , Final ID: 102</p><p>We can do some mathematical operations like OR and bitshifting to get a unique iD but this one is the most simple. Take the two timestamps, convert them to strings and then concatenate the strings to get the unique id. In concurrent processes or processes with multiple threads this comes handy.</p><p>Note:  </p><blockquote><p>In Go, the statement <code>c := atomic.AddUint64(&amp;seq, 1)</code> uses the <code>sync/atomic</code> package to safely increment a shared 64-bit unsigned integer (<code>seq</code>) and return the new value.</p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OZ15!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ee4f0b6-af6a-42f1-90e5-d56f98c1cd1c_1458x274.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OZ15!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ee4f0b6-af6a-42f1-90e5-d56f98c1cd1c_1458x274.png 424w, https://substackcdn.com/image/fetch/$s_!OZ15!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ee4f0b6-af6a-42f1-90e5-d56f98c1cd1c_1458x274.png 848w, https://substackcdn.com/image/fetch/$s_!OZ15!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ee4f0b6-af6a-42f1-90e5-d56f98c1cd1c_1458x274.png 1272w, https://substackcdn.com/image/fetch/$s_!OZ15!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ee4f0b6-af6a-42f1-90e5-d56f98c1cd1c_1458x274.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OZ15!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ee4f0b6-af6a-42f1-90e5-d56f98c1cd1c_1458x274.png" width="1456" height="274" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8ee4f0b6-af6a-42f1-90e5-d56f98c1cd1c_1458x274.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:274,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:36956,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://sladynnunes.substack.com/i/173541787?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ee4f0b6-af6a-42f1-90e5-d56f98c1cd1c_1458x274.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OZ15!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ee4f0b6-af6a-42f1-90e5-d56f98c1cd1c_1458x274.png 424w, https://substackcdn.com/image/fetch/$s_!OZ15!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ee4f0b6-af6a-42f1-90e5-d56f98c1cd1c_1458x274.png 848w, https://substackcdn.com/image/fetch/$s_!OZ15!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ee4f0b6-af6a-42f1-90e5-d56f98c1cd1c_1458x274.png 1272w, https://substackcdn.com/image/fetch/$s_!OZ15!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ee4f0b6-af6a-42f1-90e5-d56f98c1cd1c_1458x274.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p><p><strong>Additional pointers:</strong></p><ul><li><p>We could have used the node id if our service maintains something like that to ensure uniqueness since the node id would be different for each node. </p></li><li><p>Mathematical operations like OR and bitwise shifting for the last approach are perfectly valid solutions for this problem</p></li><li><p>I have not explored the idea of atomicity of the database for ID generation, perhaps we would be able to guarantee atomicity and consistency but I did not give it much thought. Would love to hear any ideas if you have any. </p></li></ul>]]></content:encoded></item><item><title><![CDATA[Bias for action]]></title><description><![CDATA[Actionable steps that can get you out of the rut of inaction.]]></description><link>https://sladynnunes.substack.com/p/bias-for-action</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/bias-for-action</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Fri, 05 Sep 2025 07:56:58 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fNfS!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a2f5a74-3d23-48a2-a315-b36f2172e84a_1200x1200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The ability to just do things is a rare quality in 2025 especially with all the distractions surrounding us in this digital age of social media addiction. Avoiding the work that you need to do to make it to the next level and substituting it for extremely small dopamine hits at regular intervals is the new normal for a young adult.<br><br>The constant scrolling on instagram or twitter just to be able to ick out that last second of dopamine has got us hooked. I always come back to the quote that states &#8220;if its free then probably you are the consumer&#8221;. </p><p>I found myself in that rut probably after I joined my full time job at the end of 2023. The struggle and hard work during my grad days was replaced by something a bit more mundane and stable at my workplace. I found myself substituting that with a less harder things that satisfied my dopamine hit. Fast forward a couple of months and even reading a wiki that was moderately hard became an absolute nightmare, meaning the things that needed to get done were getting put on the back burner. <br><br>At that point i realized i need to develop a bias for action, or put simply just doing things. I came up with a few points that i will share with you that helped me get out of that rut of inaction</p><ul><li><p>If it takes less than 15 minutes to accomplish something do it now. Things like ordering stuff on amazon, filling out an important document, applying for a drivers license etc. The boring things that we tend to procrastinate come in this list that could get done in small blocks of allocated time. </p></li><li><p>Then I started with things that are the highest priority, things that if not done would have dire consequences over a long period of time. The tasks that got assigned to me at work. Filing taxes, ensuring all the bills etc are paid on time. These are the kind of things that need to get done regardless and require the most amount of time and focus. </p></li><li><p>Then I started taking decisions that would not have long term consequences a bit faster. Not sure what table to order. ChatGPT it, pick the top 2 and go with one, we can return it later if we do not like it. Write that new blog, as if no one is reading, we can refine it later. These activities are those which require some sort of decision making which we either postpone due to lack of knowledge to take that decision or just the sheer number of options. If its the later then read the next bullet point.</p></li><li><p>For the deicions that need more evidence or data poitns, I tend to put it down in my todo list and then come up with a set of points that I need to take that decision and then i go back to point 1 of this post and work my way down until i either end up with the task done or a set of data points that i need to gather and work on.</p></li></ul><p>I hope this blog helped and feel free to leave any comments about the techniques you learnt or use that help you to take action faster. <br><br><br><br><br><br><br></p><p></p><p></p>]]></content:encoded></item><item><title><![CDATA[How to Reach Escape Velocity in a New Team ? ]]></title><description><![CDATA[Joining a new team, escape velocity is the velocity at which you are productive in a new team.]]></description><link>https://sladynnunes.substack.com/p/how-to-reach-escape-velocity-in-a</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/how-to-reach-escape-velocity-in-a</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Mon, 30 Jun 2025 07:49:12 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fNfS!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a2f5a74-3d23-48a2-a315-b36f2172e84a_1200x1200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Who this is for ?</strong></p><p>The primary audience for this is new engineers joining teams in a new company, i would try and keep this tailored for engineers in tech. But I think the major principles or themes can be borrowed and used anywhere.</p><p><strong>Get a name on your first meeting</strong></p><p>On your 1:1 with everyone on your team, after your introductoin with them and general chichatter, just before you thank them for their time, get two names or at least one that you should definitely talk to in order to understand stuff better.</p><p>You then keep going down the list given by everyone. You do not have to go all the way to the bottom, you might end up talking to the whole company.</p><p>Just a 4-5 interations below the first person and you should be good to go.</p><p><strong>Search for todo items in your codebase</strong></p><p>The best way to get familiar with a codebase is to solve small issues or solve problmes that no one has the time to get to. Just open up VSCode and in the "search all" bar type TODO: and you should get a bunch of TODOs that engineers have left. and then you just start solving them. Make some PRs that solve them or ask if you need more context, this will enable you to move fast and gain real skills while building credibility on the team.</p><p><strong>Take a while to sit back and observe</strong></p><p>I know its pretty tempting to join a new team and wanting to make an impact and prove yourself. But you have to remember the team you are joining might have been around for a very long time with team dynamics already set. Don't be afraid to make your voice heard but also ensure to maintain a balancing act to be too pushy about solving things "your" way. Feel free to observe, learn and ask as many questions as you can to know why the thing you are suggesting might not be practical at this point in time.</p>]]></content:encoded></item><item><title><![CDATA[Java Virtual Threads - Part 1 ]]></title><description><![CDATA[This is a small write up on how java virtual threads work.]]></description><link>https://sladynnunes.substack.com/p/java-virtual-threads-part-1</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/java-virtual-threads-part-1</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Thu, 30 Mar 2023 17:52:27 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fNfS!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a2f5a74-3d23-48a2-a315-b36f2172e84a_1200x1200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h4> How threads work in java</h4><p><br>Threads in java are just a wrapper around the actual operating system threads. The JVM requests the operating system to create a thread. Each thread in java has its own components like program counter, call stack etc. There are two types of threads, in the JVM one is the native thread and the java thread. The native thread is the thread that the OS controls to perform various types of operations like controlling internal hardware operations etc. </p><p><strong>Are threads expensive ?</strong> <br>Each thread in Java has its own call stack, which is used to store the state of the thread as it executes. When a thread is created, a new call stack is also created for that thread, and this can consume a significant amount of memory, especially if the stack frames are large</p><p><strong>What is the solution</strong> </p><p>Java 16 came up with the solution of virtual threads. A virtual thread stores the stack memory on the heap instead of the stack, allowing it to allocate more memory. </p><p>Let us see an example on how to create a virtual thread.</p><pre><code>public static void main(String[] args) {
        ExecutorService executorService = Executors.newVirtualThreadExecutor(new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {
                return Thread.ofVirtual().start();
            }
        });

        executorService.submit(() -&gt; {
            System.out.println("Hello from virtual thread!");
        });

        System.out.println("Hello from main thread!");

        executorService.shutdown();
    }</code></pre><p>In this example, we create a new <code>ExecutorService</code> that is configured to use virtual threads. We define a <code>ThreadFactory</code> that creates new virtual threads using the <code>Thread.ofVirtual()</code> method, which returns a new virtual thread that is ready to be started.</p><p>We then submit a new task to the executor service, which will be executed on a virtual thread. The task simply prints a message to the console.</p><p><strong>How virtual threads work internally ?</strong> </p><p>The JVM maintains a pool of platform threads. This is known as the forkJoinPool. This pool contains a pool of around 256 threads which is the maximum limit. It usually depends on the number of cpu cores. When a virtual thread encounters a blocking operation, such as waiting for I/O or a lock, it will block and suspend its execution until the operation completes.</p><p>When this happens, the virtual thread's stack chunk (the portion of the stack that the virtual thread is currently using) is copied back to the heap, which frees up the carrier thread to execute other virtual threads that are ready to run. The carrier thread is the underlying thread that is executing the virtual thread's code, and it is responsible for running multiple virtual threads concurrently.</p><p>Once the blocked virtual thread finishes the blocking operation, the scheduler will schedule it again for execution. This can happen on the same carrier thread or a different one, depending on the scheduling policy of the virtual thread pool.</p><p>In the next part we will take a look at scheduling and how virtual threads are pooled together. </p>]]></content:encoded></item><item><title><![CDATA[Introduction to Pages in Linux]]></title><description><![CDATA[Let us talk about an important topic in linux called as Page Caching.]]></description><link>https://sladynnunes.substack.com/p/introduction-to-pages-in-linux</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/introduction-to-pages-in-linux</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Thu, 02 Mar 2023 09:05:33 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fNfS!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a2f5a74-3d23-48a2-a315-b36f2172e84a_1200x1200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let us talk about an important topic in linux called as Page Caching.</p><p><strong>What is a Page in linux ?</strong> <br>A page is a fixed block of physical memory that the kernel uses to manage various operations. The typical size of a page in linux is around 4KB. It allows for efficient use of physical memory by sharing it among multiple processes and by swapping unused pages to disk when memory becomes scarce.</p><p><strong>How is a page cache and how is read and write to a page cache done?</strong> <br>A page cache is linux&#8217;s way of accessing memory quicker. Generally if a the kernel wants to read a file it first checks if that file has its data in the page cache. If yes it can avoid the expensive operation of reading that data from disk. </p><p><strong>How reads are done to the disk</strong></p><ul><li><p> When a user-space application wants to read data from disks, it asks the kernel for data using special system calls such as <code>read(), pread(), vread(), mmap(), sendfile(), etc.</code></p></li><li><p>Linux kernel, in turn, checks whether the pages are present in Page Cache and immediately returns them to the caller if so. As you can see kernel has made 0 disk operations in this case.</p></li><li><p>If there are no such pages in Page Cache, the kernel must load them from disks. In order to do that, it has to find a place in Page Cache for the requested pages. A memory reclaim process must be performed if there is no free memory (in the caller&#8217;s cgroup or system). </p></li></ul><p><strong>How writes  are done to the disk</strong></p><p>It is the same as how reads are done but the only difference is the writes are not written immediately to disk. What this means is that the pages are just written to and are kept that way until a page flush occurs. The data that is not yet flushed is marked by the kernel as dirty pages. </p><p></p>]]></content:encoded></item><item><title><![CDATA[How Linux System Calls Work]]></title><description><![CDATA[Let us take a deep dive into how system calls are executed by the operating system.]]></description><link>https://sladynnunes.substack.com/p/how-linux-system-calls-work</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/how-linux-system-calls-work</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Tue, 14 Feb 2023 09:45:47 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!MfCR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F757552d0-c93f-4bc8-8226-fd12471478bf_1252x742.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MfCR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F757552d0-c93f-4bc8-8226-fd12471478bf_1252x742.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MfCR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F757552d0-c93f-4bc8-8226-fd12471478bf_1252x742.png 424w, https://substackcdn.com/image/fetch/$s_!MfCR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F757552d0-c93f-4bc8-8226-fd12471478bf_1252x742.png 848w, https://substackcdn.com/image/fetch/$s_!MfCR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F757552d0-c93f-4bc8-8226-fd12471478bf_1252x742.png 1272w, https://substackcdn.com/image/fetch/$s_!MfCR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F757552d0-c93f-4bc8-8226-fd12471478bf_1252x742.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MfCR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F757552d0-c93f-4bc8-8226-fd12471478bf_1252x742.png" width="1252" height="742" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/757552d0-c93f-4bc8-8226-fd12471478bf_1252x742.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:742,&quot;width&quot;:1252,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;linux - Is there a system call service routine in the interrupt vector? -  Stack Overflow&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="linux - Is there a system call service routine in the interrupt vector? -  Stack Overflow" title="linux - Is there a system call service routine in the interrupt vector? -  Stack Overflow" srcset="https://substackcdn.com/image/fetch/$s_!MfCR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F757552d0-c93f-4bc8-8226-fd12471478bf_1252x742.png 424w, https://substackcdn.com/image/fetch/$s_!MfCR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F757552d0-c93f-4bc8-8226-fd12471478bf_1252x742.png 848w, https://substackcdn.com/image/fetch/$s_!MfCR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F757552d0-c93f-4bc8-8226-fd12471478bf_1252x742.png 1272w, https://substackcdn.com/image/fetch/$s_!MfCR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F757552d0-c93f-4bc8-8226-fd12471478bf_1252x742.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p></p><p>The first thing that happens working with system calls is that the process first switches from user mode to kernel mode. When in user mode the OS is executing user level instructions and in order to execute kernel level instructions it would need certain elevated privileges. </p><p><strong>Step 1:</strong>   The system needs to switch to the kernel mode and for that to happen, the wrapper puts the system call into a specific register. We have a sys-call table which identifies the system call by a unique identifier.</p><p><strong>Step 2:</strong>  The system then executes a trap instruction which switches the system from the user mode to the kernel mode and then begins executing the code at location 0x80 of the systems trap vector. </p><p><strong>Step 3:</strong>  Now that the instruction is in memory in response to the trap instruction it makes a system_call() with certain parameters to handle the trap. This handler does certain things</p><ul><li><p>Checks for the validity of the system call</p></li><li><p>Saves register values on the kernel stack (We have two stacks inside an OS one is the kernel stack and one is the user stack) </p></li><li><p>Checks for the arguments in system call, if the memory calls are valid and not out of bounds. </p></li><li><p>After the sys-call has returned it makes the appropriate changes to the registers and then puts the return value back onto the stack, to be returned back to the wrapper.</p></li><li><p>Returns the processor back to the user mode. </p></li></ul><p>Step 4: If the return value of the system call service routine indicated an error, the wrapper function sets the global variable errno using this value. The wrapper function then returns to the caller, providing an integer return value indicating the success or failure of the system call</p>]]></content:encoded></item><item><title><![CDATA[Linux Command Line Fundamentals]]></title><description><![CDATA[Being equipped with the general linux commands in your toolkit is a really good thing as a software engineer.]]></description><link>https://sladynnunes.substack.com/p/linux-command-line-fundamentals</link><guid isPermaLink="false">https://sladynnunes.substack.com/p/linux-command-line-fundamentals</guid><dc:creator><![CDATA[Sladyn Nunes]]></dc:creator><pubDate>Fri, 10 Feb 2023 16:43:33 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fNfS!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a2f5a74-3d23-48a2-a315-b36f2172e84a_1200x1200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Being equipped with the general linux commands in your toolkit is a really good thing as a software engineer. It is a sort of gray area in terms of what you are actually supposed to know and why cant someone google such stuff. Having a good understanding of what commands exist can give you a starting point from where to look. So let us dive straight in. I will keep updating this list as I find commands.</p><ul><li><p>ls: The  ls command can be used to list files.</p><ul><li><p><code>ls -a </code>lists all the hidden files as well</p></li><li><p><code>ls -R</code> recursively lists down all the files in the subdirectories.</p></li><li><p><code>-t</code> option will sort the entries by modification date </p></li></ul></li><li><p>cat: It is used to list the contents of the file.</p><ul><li><p><code>-n :</code> Lists the contents of the file along with the line number.</p></li><li><p><code>cat fileOne fileTwo : </code>Copies contents from file one to file two</p></li></ul></li><li><p>tail: It is used to print the last 10 lines of the file.</p><ul><li><p>It can be used to continuously watch changes to a file</p></li></ul></li><li><p>chmod: It is used to change file permissions in linux</p><ul><li><p> The digits 7, 5, and 4 each individually represent the permissions for the user, group, and others, in that order. Each digit is a combination of the numbers 4, 2, 1, and 0</p></li></ul></li><li><p>grep : It is used to search regex in the file structure</p></li><li><p>ps: It is used to list processes.</p><ul><li><p>ps -A: It is used to list all the running processes.</p></li><li><p>ps -p p_id: It is used to list the process with a given pid</p></li><li><p>aux: It displays a list of information you might need on how the different information reported by various lists of processes. </p></li></ul></li><li><p>top: It is used to monitor the vitals of the system and can give you an overview of how your system is performing. </p></li><li><p>wget: It is used to download files from the internet.</p></li></ul>]]></content:encoded></item></channel></rss>