<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Stack on Shai Asher</title><link>https://slow-is-smooth.io/tags/stack/</link><description>Recent content in Stack on Shai Asher</description><generator>Hugo</generator><language>en-gb</language><lastBuildDate>Sun, 06 Sep 2020 09:00:00 +0300</lastBuildDate><atom:link href="https://slow-is-smooth.io/tags/stack/index.xml" rel="self" type="application/rss+xml"/><item><title>Go on Windows: Where the Stacks Come From</title><link>https://slow-is-smooth.io/blog/go-on-windows-where-the-stacks-come-from/</link><pubDate>Sun, 06 Sep 2020 09:00:00 +0300</pubDate><guid>https://slow-is-smooth.io/blog/go-on-windows-where-the-stacks-come-from/</guid><description>&lt;p&gt;Run the same Go program on Linux and on Windows and its goroutines are not the same size. On Windows&#10;every goroutine starts with an 8 KB stack, four times what it gets on Linux, because Windows writes the&#10;record of a processor exception onto whatever stack the fault happened on. A gigabyte that a Go program&#10;allocates and never touches costs a full gigabyte of Windows&amp;rsquo; commit charge, and on a machine with 4 GB&#10;of memory the ninth such gigabyte stops the program, where Linux let the same program reach 64 GB on a&#10;31 GB machine. And a C function, called from Go, that runs out of stack leaves, nine times in ten, a&#10;process that prints its crash report and then never exits.&lt;/p&gt;</description></item><item><title>Every Python Call Is a C Call</title><link>https://slow-is-smooth.io/blog/every-python-call-is-a-c-call/</link><pubDate>Sun, 22 Jul 2018 09:00:00 +0300</pubDate><guid>https://slow-is-smooth.io/blog/every-python-call-is-a-c-call/</guid><description>&lt;p&gt;In Python 3.7, a function that calls itself 22,000 times crashes the interpreter outright: no&#10;exception, no traceback, just &lt;code&gt;Segmentation fault&lt;/code&gt; and exit status 139. Python&amp;rsquo;s own recursion limit&#10;stops that from happening, by default, at a depth of 1,000. That limit is not a rule of the language.&#10;It&amp;rsquo;s a guess about the C stack, which CPython uses up at 384 bytes per Python call on this&#10;build. Raise the limit far enough, or reach the C stack through a path the limit never counts, and&#10;the guess runs out.&lt;/p&gt;</description></item><item><title>A Goroutine Starts with Two Kilobytes</title><link>https://slow-is-smooth.io/blog/a-goroutine-starts-with-two-kilobytes/</link><pubDate>Sun, 06 May 2018 09:00:00 +0300</pubDate><guid>https://slow-is-smooth.io/blog/a-goroutine-starts-with-two-kilobytes/</guid><description>&lt;p&gt;A C program that starts ten thousand threads on Linux reserves 80 gigabytes of address space for&#10;their stacks, 8 MB each, before any of them has done anything. A Go program that starts a hundred&#10;thousand goroutines spends about 2 KB of stack on each. Yet any one of those goroutines can recurse&#10;half a gigabyte deep before Go stops it. Both are true because a goroutine&amp;rsquo;s stack does not stay&#10;where it is: when it fills, the runtime allocates a new one twice the size, copies every frame&#10;across, and rewrites every pointer that pointed into the old one.&lt;/p&gt;</description></item></channel></rss>