<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jonathan E. Magen on Medium]]></title>
        <description><![CDATA[Stories by Jonathan E. Magen on Medium]]></description>
        <link>https://medium.com/@yonkeltron?source=rss-e7d09ed179c0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ShLna_zL_-IWVqGI.png</url>
            <title>Stories by Jonathan E. Magen on Medium</title>
            <link>https://medium.com/@yonkeltron?source=rss-e7d09ed179c0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 04:15:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yonkeltron/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Distributed systems for the blockchain skeptic]]></title>
            <link>https://medium.com/@yonkeltron/distributed-systems-for-the-blockchain-skeptic-8e5a5069c150?source=rss-e7d09ed179c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e5a5069c150</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Jonathan E. Magen]]></dc:creator>
            <pubDate>Thu, 01 Feb 2018 14:31:05 GMT</pubDate>
            <atom:updated>2018-02-01T14:31:05.758Z</atom:updated>
            <content:encoded><![CDATA[<p>It is the age of blockchain excitement: a time when finance bros will ask if you’re “into crypto” but have no idea what you mean when you ask their opinion on the slower-than-it-should-have-been rise of <a href="https://cr.yp.to/chacha.html">ChaCha20</a>. You might see someone planning to use an encrypted distributed ledger and wonder if there was a simpler way to solve the problem. Usually, there is.</p><p>Blockchain technologies suffer from a variety of shortcomings. For example, real-world blockchains are slow. Like, really slow, with Bitcoin <a href="https://blockchain.info/charts/median-confirmation-time">commit times measured in tens of minutes</a> while researchers stress that it could <a href="https://coincenter.org/entry/how-long-does-it-take-for-a-bitcoin-transaction-to-be-confirmed">actually take much longer</a>. Blockchain technologies also add a good amount of overhead to simple operations in order to preserve anonymity and protect data privacy. Perhaps these reasons, and others, are why it’s been <a href="https://hackernoon.com/ten-years-in-nobody-has-come-up-with-a-use-case-for-blockchain-ee98c180100">10 years and no one’s come up with real uses for blockchain technologies</a>. Except for fake money and illegal transactions, of course.</p><p>Somehow, amidst all the hype, people seem to have forgotten the realities of a 50-year long discussion around software decentralization and distributed systems. To help folks skeptical about the blockchain learn about the context, theory, practice, and progress of distributed computing, please peruse the following. It’s a narrated list of informative resources which should help to orient people just diving into this sort of thing.</p><p>Welcome. We’re happy to have you.</p><h3>Context and theory</h3><p>To start our journey, consider digesting Caitie McCaffery’s talk about <a href="https://speakerdeck.com/caitiem20/a-brief-history-of-distributed-programming-rpc">a brief history of distributed programming: RPC</a> for an introduction to the cool stuff the community has been working on for ages. Things like <a href="https://en.wikipedia.org/wiki/Byzantine_fault_tolerance">Byzantine fault tolerance</a>, <a href="https://s3.amazonaws.com/academia.edu.documents/33921822/fallacies.pdf?AWSAccessKeyId=AKIAIWOWYYGZ2Y53UL3A&amp;Expires=1517446707&amp;Signature=PdI4i%2BvgIHytfZ3aMjSAA%2FLqk34%3D&amp;response-content-disposition=inline%3B%20filename%3DFallacies.pdf">the 8 fallacies of distributed computing explained</a> and <a href="https://fenix.tecnico.ulisboa.pt/downloadFile/845043405442708/10.e-CAP-3.pdf">this article</a> which introduces the CAP theorem. Next, you might read <a href="http://www.citemaster.net/get/10b50274-7bc5-11e5-8aa1-00163e009cc7/p558-lamport.pdf">Lamport’s paper on logical clocks</a> to learn about synchronization from an OG, and don’t forget the classic <a href="https://github.com/papers-we-love/papers-we-love/blob/master/distributed_systems/a-note-on-distributed-computing.pdf">note on distributed computing</a>.</p><p>Folks interested in <a href="https://en.wikipedia.org/wiki/Consensus_(computer_science)">consensus</a> might fancy approaches to maintaining it such as <a href="https://en.wikipedia.org/wiki/Paxos_(computer_science)">Paxos</a>. For those who find that inscrutable, find comfort in the understandable alternative of <a href="https://en.wikipedia.org/wiki/Raft_(computer_science)">Raft</a> whose original paper is <a href="https://www.usenix.org/system/files/conference/atc14/atc14-paper-ongaro.pdf">here</a>. You might also want to learn about cool techniques such as <a href="https://en.wikipedia.org/wiki/Two-phase_commit_protocol">two-phase commit</a>, as well as why <a href="http://www.enterpriseintegrationpatterns.com/ramblings/18_starbucks.html">Starbucks doesn’t use it</a>.</p><p>My favorite book on distributed computing is the one written by Tannenbaum and van Steen, entitled <a href="http://a.co/2NZz76d">Distributed Systems</a>, as it covers a wide breadth of topics from p2p network architectures to replication. However, folks in a hurry will love <a href="http://book.mixu.net/distsys/single-page.html">Distributed Systems for Fun and Profit</a> by Mixu.</p><h3>Practice</h3><p>Perhaps the most concise guide to distributed systems in practice might be <a href="https://www.somethingsimilar.com/2013/01/14/notes-on-distributed-systems-for-young-bloods/">Notes on distributed systems for young bloods</a> by Jeff Hodges. You could then follow up with <a href="http://a.co/iMMwmHn">Database Reliability Engineering</a> by Lane Campbell and Charity Majors, which is actually a brilliant manual on software reliability, operations, and hard-won wisdom for the networked environment. Also, it’s true that <a href="https://www.usenix.org/system/files/conference/osdi14/osdi14-paper-yuan.pdf">simple testing can prevent most critical failures</a> so you might want to look at <a href="http://jepsen.io/">Jepsen</a> and all it has to offer.</p><h3>Alternatives to blockchain</h3><p>We see lots of advancement in consensus and coordination which don’t rely on the blockchain. For example, take Caitie McCaffrey on <a href="https://www.youtube.com/watch?v=0UTOLRTwOX0">distributed sagas</a>, a novel method developed for microservice coordination. Projects like the <a href="https://ipfs.io/">Interplanetary Filesystem (IPFS)</a> and the <a href="https://datproject.org/">Dat protocol</a> have really made me think about what it means to distribute control and data amongst different participants of a system. You might consider diving into <a href="https://en.wikipedia.org/wiki/Distributed_hash_table">distributed hash tables</a> like <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.125.663&amp;rep=rep1&amp;type=pdf">Chord</a>, <a href="http://www.ic.unicamp.br/~bit/ensino/mo809_1s13/papers/P2P/Kademlia-%20A%20Peer-to-Peer%20Information%20System%20Based%20on%20the%20XOR%20Metric%20.pdf">Kademlia</a>, and <a href="https://link.springer.com/content/pdf/10.1007/3-540-45518-3_18.pdf">Pastry</a>, which can contribute to many distributed information-sharing problems and provide a simpler alternative to blockchain among cooperating peers. Those folks who are skeptical of any overhead and bottlenecks which come part and parcel with blockchain might want to look at the lofty goals of the <a href="http://ceptr.org/">Ceptr</a> project.</p><h3>Conclusion</h3><p>My point is that, while the blockchain <em>is</em> pretty cool, it doesn’t represent the end-all-be-all fairy tale future of distributed computing. For those who are legitimately interested in this sort of thing, I hope that this article provides a starting point for learning more. For everyone else, there’s <a href="http://ponzicoin.co/">PonziCoin</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e5a5069c150" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Explaining garbage collection algorithms by keeping your fridge tidy]]></title>
            <link>https://medium.com/@yonkeltron/explaining-garbage-collection-algorithms-by-keeping-your-fridge-tidy-2636012cfeee?source=rss-e7d09ed179c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/2636012cfeee</guid>
            <dc:creator><![CDATA[Jonathan E. Magen]]></dc:creator>
            <pubDate>Thu, 02 Oct 2014 18:55:21 GMT</pubDate>
            <atom:updated>2014-10-02T18:55:21.037Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn some commonly-used GC algorithms, work to manage your leftovers.</h4><p>In every place I’ve lived, I’ve had the same main responsibility: cleaning out the fridge. This life calling began around middle school and my skills developed in parallel with my ability to assemble a meal consisting only of leftover takeout and the last dregs from condiment jars. By the time I’d made it to college and begun advancing my study of computer science, this ability to conjure sustenance from unlikely combinations made the multi-day marathon stays in the laboratory sustainable (if less tasty). Plus, my living spaces were always pleasantly free of the refrigerator science experiment odors which plagued neighboring dorm kitchens, something which my roommates appreciated. Sure, the process of cleaning things out often got contentious — as mocked by George Carlin’s now famous skit, <a href="https://www.youtube.com/watch?v=pg3viTvOzhI">The Ice Box Man</a> — but, on the macro level, it was mostly me just eating leftovers.</p><p>However, like all science geeks fascinated with how the world works, I eventually asked myself the question of “can I do this more efficiently?” and was pleased to find the answer: a resounding yes. In fact, cleaning out fridges provides an excellent metaphor for explaining the family of programming’s automatic memory management tools known as garbage collection.</p><h3>What is garbage collection?</h3><p>Unexplored by many who consider automatic memory management the purview of compiler implementors and language designers, garbage collection is the process by which a program’s unused memory gets automatically reclaimed. This can happen via either the environment (like the JVM) or by the language itself (like in Lisp). In contrast to programs written in languages like C and C++ — whose source code can often resemble a battleground of malloc, free, new and delete calls — garbage collected languages free programmers from such mundane chores as the allocation and reclamation of memory segments.</p><p>Just like a cook putting a dish in the refrigerator, programmers regularly stash values in data structures of various types. If you want to hold on to information during program execution, you need memory in which to store it. Once the program has a block of memory, the organization of data in the block itself — whether stored in a hash table, array, tree or some programmer-defined type — is immaterial. If managing memory manually, the program author takes responsibility for returning blocks of memory to the system when no longer needed. Failure to do so leads to <a href="https://en.wikipedia.org/wiki/Memory_leak">memory leaks</a>, situations wherein a program keeps gobbling up memory without giving any back. Programs which leak memory in this fashion run the very real risk of consuming all available memory and getting killed, usually with an <a href="https://en.wikipedia.org/wiki/Out_of_memory">Out Of Memory (OOM)</a> error. Compare this with garbage collected memory wherein the collector will try to identify those regions of memory which the program will no longer use and return them to the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dx14FE394-rnxbiva-HQuA.jpeg" /></figure><h3>Kitchen as computer, refrigerator as memory</h3><p>Following in computer science’s longstanding tradition of imperfect metaphors (<a href="http://blog.plover.com/prog/burritos.html">a monad is like a burrito!</a>), let us introduce the idea that, at a high enough level, both kitchens and computer share many operational semantics. A computer has an operating system kernel while a kitchen has a chef. A computer possesses hardware components (CPU, memory, hard disk, network interface) for computational tasks while a kitchen boasts a variety of appliances (stove, oven, freezer, blender) used for food preparation. As you might guess, we will draw a parallel between a cook’s usage of a refrigerator for food storage and a program’s usage of memory regions for storing data.</p><h3>Tracing garbage collection</h3><p>Tracing garbage collection strategies underly such a broad category of algorithms that many refer to tracing and garbage collection interchangeably. In it’s purest form, tracing garbage collection refers to contiguous blocks of memory as <em>objects</em> and involves very few steps:</p><ol><li>The collector traverses the memory graph by following all references.</li><li>For any object in memory visited by the traversal, the collector deems it to be reachable and therefore <em>live</em>.</li><li>Any object in memory not visited by the traversal must not have any references pointing to it so the collector considers it unreachable and <em>dead</em>.</li><li>The collector <em>condemns</em> dead objects and their space become eligible for reclamation.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*L521IdwuQq8oO2vGT_Jm5Q.png" /></figure><p>Typically, tracing garbage collection runs periodically in collection cycles. Depending on the underlying collector implementation, different phases of work may happen on different collection cycles but, in the naive implementation, the collector would identify dead objects and reclaim them in the same cycle.</p><p>Imagine going through every shelf in your fridge and, for every thing you find, you scream out “Hey! Does anyone want this?”. If someone hollers back “Yeah, I’ll eat that with my lunch tomorrow!”, then you can reasonably assume that that orange (or whatever) should stay and it’s continued presence merits the use of real estate. Otherwise, you throw it out and make space in your fridge.</p><p>You realize this approach causes you to continually unpack and repack everything so you decide maybe you can break things up into stages rather than doing everything at once.</p><h4>Mark and sweep</h4><p>In 1960, John McCarthy, the father of Lisp and progenitor of garbage collection, broke up collection cycles into two parts: the mark phase and the sweep phase. The mark phase consists solely of using tracing to determine object reachability, leaving behind an actual mark (often just a toggled bit) on every visited (live) object. Then, during the sweep phase, every unmarked (dead) object gets reclaimed. Since traversing reference trees and toggling bits during the mark phase incurs significantly less cost than actually freeing memory, a collector could opt to delay sweeping until convenient.</p><p>This equates to you simply reaching around and putting a sticker on everything someone wants. Later, when the kitchen is quiet, you can throw out stuff without a sticker.</p><p>Having gotten hoarse from all the yelling back and forth to figure out who wants the day-old takeout, you decide to farm out work to others.</p><h4>Reference counting</h4><p>A reference counting garbage collector keeps a dedicated count of references to an object, incrementing and decrementing the count as references are established and forgotten. When the counter reaches zero, the collector declares the object dead (condemned) and ripe for reclamation. This requires the added step of managing the reference count as part of initializing or destroying a reference which can cause problems. For example, if a given object gets passed around with great frequency, this could result in performance overhead as the counter changes often. In a multi-threaded program, multiple threads continually trying to modify the same counter could require counter synchronization, increasing program complexity and introducing the possibility of lock contention. Not to mention the problems of needing to maintain counters somewhere (itself using more memory) and the possibility of needing to increment counters beyond the size allocated for them.</p><p>Back in your kitchen, you finally got fed up and bought all of your housemates their own sheet of stickers, telling them that if they want to hold on to something for a future meal, they should leave a sticker on it. When they no longer want something, they peel off the sticker and you throw out every stickerless item. Unfortunately, the discussion about who wants what leads to a realization that everyone can pool resources and share food to save money. This leads to a constant flurry of activity and bumped elbows at mealtime as everyone jockeys for a chance to move their stickers around. Might make them a little nuts and slow down snack retrieval but it sure means less work for you!</p><h3>Generational garbage collectors</h3><p>Another type of garbage collection algorithm, called generational collection, relies on a principle called the <em>generational hypothesis.</em> This hypothesis relies on the idea that the longer an object stays alive, the more likely it is to survive going forward. Consider the case of buffers used to store data during processing. Such objects get used and then discarded in relatively short order whereas longer-lived objects, like database connections, might stay around for the entire duration of a program’s execution! Taking advantage of this principle, a generational collector could reduce the overhead during scanning phases (whether tracing or something fancier) by focusing more on newer objects.</p><p>Imagine a collector which puts objects into two categories, the Young and the Old, called <em>generations</em>. The first few collection cycles might look something like this:</p><ol><li>Scan all objects and condemn the dead ones.</li><li>Reclaim all dead objects.</li><li>All objects which have been around for awhile get <em>promoted</em> to the Old generation.</li><li>For the next few cycles, the collector ignores the Old generation and focuses on the Young generation.</li><li>Every <em>n</em> cycles or so, perform a complete scan.</li></ol><p>If the characteristics of your program uphold the generational hypothesis, then a generational garbage collector could improve your GC performance greatly. Many collectors will create a few different generations, each scanned less frequently than the one preceding it.</p><p>In your fridge, you could certainly rearrange your food periodically to move older food to a different shelf but, in my home, this happens naturally! It has been my observation that condiments tend to rank among the longest-lived items. Most folks I know store condiments on the door. Items which routinely die young, like leftover pizza and half-eaten containers of Indian takeout, usually end up on the bottom shelf and disappear within a day. Vegetables and fruit go into their special drawers but get eaten up within the week. That bottle of sriracha, though, has been on the door for awhile and will continue it’s blissfully-spicy existence for quite some time.</p><p>Now, this doesn’t always work out perfectly and sometimes objects will end up getting promoted to an older generation by mistake. Think about <em>that one bowl of rice</em> which gets stuck on a shelf and pushed so far back that you forget about it until it turns into a science experiment. Consider, for example, a generational collector with three generations, somewhat similar to the JVM (<a href="http://docs.oracle.com/javase/7/docs/technotes/guides/management/jconsole.html">which happens to have two extra</a> non-heap generations used for internal matters). We’ll use the same nomenclature here, in case you want to read up further, of the Eden, Survivor and Tenured generations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*kArDkwKQDTfBjIbmh4lAVQ.png" /></figure><p>Sure, that one bowl of rice will <em>eventually</em> get discovered and thrown out, but in the meantime, it takes up space much longer than it should.</p><h3>Why stop the world?</h3><p>If you stuck with our chosen metaphor, you may have noticed that all scenarios discussed so far require physically standing in front of the fridge, thus making it impractical or inconvenient for others to access it at the same time. This very problem has led computer scientists to classify such blocking garbage collection strategies as <em>stop the world algorithms</em> since they require the main program itself to halt while garbage collection takes place. Often, the garbage collection process will consume more CPU than the regular execution itself, leading to undesirable resource hogging by the program. The specifics differ from implementation to implementation but, since reference counting allows for immediate reclamation if so desired, many OS kernels use reference counting for internal bookkeeping. Some modern garbage collectors, like <a href="http://www.oracle.com/technetwork/java/javase/tech/g1-intro-jsp-135488.html">the JVM</a>’s new <a href="http://www.infoq.com/articles/G1-One-Garbage-Collector-To-Rule-Them-All">G1 collector</a>, rely on a strategy called partitioning wherein the collector will suspend access to a limited portion of memory which could prevent the program itself from halting entirely.</p><h3>Conclusion</h3><p>I may never know why I was born with the gift of cooler cleanliness, but I will likely spend the rest of my life in fate’s chosen household role. It may further remain unclear why more people don’t have an appreciation or interest in learning about garbage collection algorithms. Afterall, it’s as easy as cleaning out your fridge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*E0kKVV7SESA6GAgjy02r2g.jpeg" /></figure><h4>Learning more</h4><p>Aside from the obligatory link to the <a href="https://en.wikipedia.org/wiki/Memory_management">Memory management article at The Wikipedia</a>, if this topic interests you, I highly recommend the resources at <a href="http://www.memorymanagement.org/">MemoryManagement.org</a> which provides great material regarding the differences between types of memory management as well as an exceptional <a href="http://www.memorymanagement.org/glossary/index.html">glossary</a>. For the die hards, there’s always <a href="http://amzn.com/1420082795">The Garbage Collection Book by Jones, Hosking and Moss</a>, which I fully intend to read as soon as they release an e-reader edition. Moreover, from the oldie-but-goodie department, the c2 wiki has some<a href="http://c2.com/cgi/wiki?GarbageCollection"> exceptional material on garbage collection</a>, complete with comments from veteran developers on the low-level details. Finally, Paul R. Wilson from the University of Texas has written <a href="http://www.maths.lse.ac.uk/Courses/MA407/gcsurvey.pdf">a very accessible paper [PDF]</a> providing an introduction to various GC topics.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2636012cfeee" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>