{"id":42886,"date":"2024-04-19T16:09:04","date_gmt":"2024-04-19T20:09:04","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=42886"},"modified":"2024-04-19T16:09:04","modified_gmt":"2024-04-19T20:09:04","slug":"optimizing-webkit-safari-for-speedometer-3-0","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2024\/04\/19\/optimizing-webkit-safari-for-speedometer-3-0\/","title":{"rendered":"Optimizing WebKit &#038; Safari for Speedometer 3.0"},"content":{"rendered":"<p><a href=\"https:\/\/webkit.org\/blog\/15249\/optimizing-webkit-safari-for-speedometer-3-0\/\">Alan Baradlay et al.<\/a>:<\/p>\n<blockquote cite=\"https:\/\/webkit.org\/blog\/15249\/optimizing-webkit-safari-for-speedometer-3-0\/\">\n<p>We <a href=\"https:\/\/commits.webkit.org\/267481@main\">made our fast JSON stringifier work for unicode characters<\/a>. We also analyzed profile data carefully and made <code>JSON.parse<\/code> <a href=\"https:\/\/commits.webkit.org\/274348@main\">faster<\/a> <a href=\"https:\/\/commits.webkit.org\/267507@main\">than<\/a> <a href=\"https:\/\/commits.webkit.org\/266010@main\">ever<\/a>.<\/p>\n<p>[&#8230;]<\/p>\n<p>We took the release of the new Speedometer 3.0 benchmark as an opportunity to <a href=\"https:\/\/commits.webkit.org\/272208@main\">adjust inlining heuristics<\/a> based on data collected in modern Apple silicon Macs with the latest JavaScriptCore.<\/p>\n<p>[&#8230;]<\/p>\n<p>Prior to the opportunistic task scheduler, incremental sweeping in JavaScriptCore was automatically triggered by a periodically scheduled 100 ms timer. This had the effect of occasionally triggering incremental sweeping during asynchronous timing intervals, but also wasn&rsquo;t aggressive enough to prevent on-demand sweeping in the middle of script execution. Now that JavaScriptCore is knowledgable about when to opportunistically schedule tasks, it can instead perform the majority of incremental sweeping in between rendering updates while there aren&rsquo;t imminently scheduled timers. The process of sweeping is also granular to each marked block, which allows us to halt opportunistic sweeping early if we&rsquo;re about to exceed the deadline for the next estimated rendering update.<\/p>\n<p>[&#8230;]<\/p>\n<p>Previously, we required a synchronous IPC call from the Web Process to the GPU process to determine which of the existing buffers had been released by CoreAnimation and was suitable to use for the next frame. We <a href=\"https:\/\/commits.webkit.org\/271747@main\">optimized this<\/a> by having the GPUP just select (or allocate) an appropriate buffer, and direct all incoming drawing commands to the right destination without requiring any response. We also changed the delivery of any newly allocated <a href=\"https:\/\/commits.webkit.org\/273323@main\">IOSurface handles to go via a background helper thread<\/a>, rather than blocking the Web Process&rsquo;s main thread.<\/p>\n<p>[&#8230;]<\/p>\n<p>With all these optimizations and dozens more, we were able to improve the overall Speedometer 3.0 score by ~60% between Safari 17.0 and Safari 17.4.<\/p>\n<\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2017\/06\/30\/writing-a-really-really-fast-json-parser\/\">Writing a Really, Really Fast JSON Parser<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Alan Baradlay et al.: We made our fast JSON stringifier work for unicode characters. We also analyzed profile data carefully and made JSON.parse faster than ever. [&#8230;] We took the release of the new Speedometer 3.0 benchmark as an opportunity to adjust inlining heuristics based on data collected in modern Apple silicon Macs with the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2024-04-19T20:09:08Z","apple_news_api_id":"e4b6ad5b-28c8-44bb-9bc2-cdb67353f2fd","apple_news_api_modified_at":"2024-04-19T20:09:08Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/A5LatWyjIRLubws22c1Py_Q","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":[2],"tags":[338,288,31,2321,346,507,817,30,2385,138,270,71,103,328],"class_list":["post-42886","post","type-post","status-publish","format-standard","hentry","category-technology","tag-css","tag-garbargecollection","tag-ios","tag-ios-17","tag-javascript","tag-json","tag-just-in-time-compilation-jit","tag-mac","tag-macos-14-sonoma","tag-optimization","tag-parser","tag-programming","tag-safari","tag-webkit"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/42886","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=42886"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/42886\/revisions"}],"predecessor-version":[{"id":42887,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/42886\/revisions\/42887"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=42886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=42886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=42886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}