<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Gc on Shai Asher</title><link>https://slow-is-smooth.io/tags/gc/</link><description>Recent content in Gc on Shai Asher</description><generator>Hugo</generator><language>en-gb</language><lastBuildDate>Sun, 07 Mar 2021 09:00:00 +0200</lastBuildDate><atom:link href="https://slow-is-smooth.io/tags/gc/index.xml" rel="self" type="application/rss+xml"/><item><title>One Program, Seven Runtimes</title><link>https://slow-is-smooth.io/blog/one-program-seven-runtimes/</link><pubDate>Sun, 07 Mar 2021 09:00:00 +0200</pubDate><guid>https://slow-is-smooth.io/blog/one-program-seven-runtimes/</guid><description>&lt;p&gt;In the last part of this series on Go&amp;rsquo;s stack and heap, eight versions of one program build the same&#10;data: a table of a million entries, a binary tree of two&#10;million nodes, and 65 million short-lived nodes that are built and thrown away. In Go 1.16 a goroutine&#10;that sleeps for a millisecond at a time wakes up to 18 ms late while that happens; in Java with ZGC, 1.2&#10;ms; in CPython, 0.7 seconds, because Python&amp;rsquo;s cycle collector stops everything to look at three million&#10;objects, 86 times. When the work is done and everything is dropped, Go 1.16 hands back 260 MB within&#10;half a minute, and the same program built with Go 1.15 never does as far as &lt;code&gt;top&lt;/code&gt; and RSS can tell,&#10;although its runtime released the memory just as promptly.&lt;/p&gt;</description></item><item><title>Stopping a Goroutine Anywhere</title><link>https://slow-is-smooth.io/blog/stopping-a-goroutine-anywhere/</link><pubDate>Sun, 22 Mar 2020 09:00:00 +0200</pubDate><guid>https://slow-is-smooth.io/blog/stopping-a-goroutine-anywhere/</guid><description>&lt;p&gt;A Go 1.13 program starts a goroutine that runs a tight arithmetic loop for about a second, a loop that&#10;calls no functions. Then another goroutine asks for a garbage collection. The collection waits 1.1&#10;seconds before it can begin, and so does everything else in the program that needs the world stopped.&#10;On one processor it is worse: a goroutine that sleeps for 10 milliseconds wakes up 1.15 seconds later.&#10;The loop is doing nothing wrong. It simply never reaches a point where the runtime is able to ask it to&#10;stop. Go 1.14, released last month, changes that: the same collection now starts within a millisecond,&#10;because the runtime has learned to interrupt a goroutine at almost any instruction, by sending its&#10;thread a signal.&lt;/p&gt;</description></item><item><title>A Collector That Never Moves a Thing</title><link>https://slow-is-smooth.io/blog/a-collector-that-never-moves-a-thing/</link><pubDate>Sun, 13 Jan 2019 09:00:00 +0200</pubDate><guid>https://slow-is-smooth.io/blog/a-collector-that-never-moves-a-thing/</guid><description>&lt;p&gt;Make 3.2 gigabytes of short-lived garbage in a Go program, and its garbage collector spends 52&#10;milliseconds of CPU cleaning up after it. Or 3,054 milliseconds. The garbage is identical in both&#10;runs. The difference is what else the program is holding: half a gigabyte of plain numbers costs the&#10;collector almost nothing, and half a gigabyte of objects that hold pointers costs it sixty times as&#10;much. Java&amp;rsquo;s collectors spend a few milliseconds on the same garbage, whichever it is, and .NET gets&#10;through all of it in a quarter of a second. Go&amp;rsquo;s collector does not mind how much garbage there is. It minds what is still alive, and it&#10;looks at all of it, every cycle.&lt;/p&gt;</description></item></channel></rss>