{"id":17062,"date":"2017-01-30T14:56:53","date_gmt":"2017-01-30T19:56:53","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=17062"},"modified":"2017-01-30T14:56:53","modified_gmt":"2017-01-30T19:56:53","slug":"riptide-webkits-retreating-wavefront-concurrent-garbage-collector","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2017\/01\/30\/riptide-webkits-retreating-wavefront-concurrent-garbage-collector\/","title":{"rendered":"Riptide: WebKit&rsquo;s Retreating Wavefront Concurrent Garbage Collector"},"content":{"rendered":"<p><a href=\"https:\/\/webkit.org\/blog\/7122\/introducing-riptide-webkits-retreating-wavefront-concurrent-garbage-collector\/\">Filip Pizlo<\/a>:<\/p>\n<blockquote cite=\"https:\/\/webkit.org\/blog\/7122\/introducing-riptide-webkits-retreating-wavefront-concurrent-garbage-collector\/\">\n<p>As of <a href=\"https:\/\/trac.webkit.org\/changeset\/209594\">r209827<\/a>, 64-bit ARM and x86 WebKit ports use a new garbage collector called <em>Riptide<\/em>. Riptide reduces worst-case pause times by allowing the app to run concurrently to the collector. This can make a big difference for responsiveness since garbage collection can easily take 10 ms or more, even on fast hardware. Riptide improves WebKit&rsquo;s performance on the <a href=\"http:\/\/browserbench.org\/JetStream\/in-depth.html\">JetStream\/splay-latency<\/a> test by 5x, which leads to a 5% improvement on JetStream. Riptide also improves our <a href=\"https:\/\/developers.google.com\/octane\/\">Octane<\/a> performance.<\/p>\n<p>[&#8230;]<\/p>\n<p>WebKit uses a <em>simple segregated storage<\/em> heap structure. The DOM, the Objective-C API, the type inference runtime, and the compilers all introduce <em>custom marking constraints<\/em>, which the GC executes to <a href=\"https:\/\/en.wikipedia.org\/wiki\/Data-flow_analysis#An_iterative_algorithm\">fixpoint<\/a>. Marking is done in <em>parallel<\/em> to maximize throughput. Generational collection is important, so WebKit implements it using <em>sticky mark bits<\/em>. The collector uses <em>conservative stack scanning<\/em> to ease integration with the rest of WebKit.<\/p>\n<p>[&#8230;]<\/p>\n<p>Draining in parallel means having to synchronize marking. Our marking algorithm uses a lock-free CAS (atomic compare-and-swap instruction) loop to set mark bits.<\/p>\n<p>[&#8230;]<\/p>\n<p>Our collector does not move objects. Instead, it uses the mark bit to also track generation. Quite simply, we don&rsquo;t clear any mark bits at the start of an eden collection. The marking algorithm will already ignore objects that have their mark bits set. This is called <a href=\"http:\/\/dl.acm.org\/citation.cfm?id=96735\"><em>sticky mark bit<\/em> generational garbage collection<\/a>.<\/p>\n<p>[&#8230;]<\/p>\n<p>Riptide is able to <em>stop the world<\/em> for certain tricky operations like stack scanning and DOM constraint solving.<\/p>\n<p>Riptide uses a <em>retreating wavefront<\/em> write barrier to manage races between marking and object mutation. Using retreating wavefront allows us to avoid any impedance mismatch between generational and concurrent collector optimizations.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Filip Pizlo: As of r209827, 64-bit ARM and x86 WebKit ports use a new garbage collector called Riptide. Riptide reduces worst-case pause times by allowing the app to run concurrently to the collector. This can make a big difference for responsiveness since garbage collection can easily take 10 ms or more, even on fast hardware. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[800,288,31,346,30,74,138,71,328],"class_list":["post-17062","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-concurrency","tag-garbargecollection","tag-ios","tag-javascript","tag-mac","tag-opensource","tag-optimization","tag-programming","tag-webkit"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17062","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=17062"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17062\/revisions"}],"predecessor-version":[{"id":17063,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17062\/revisions\/17063"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=17062"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=17062"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=17062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}