{"id":30450,"date":"2020-10-14T16:24:58","date_gmt":"2020-10-14T20:24:58","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=30450"},"modified":"2022-02-04T16:21:36","modified_gmt":"2022-02-04T21:21:36","slug":"faster-xcode-updates","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2020\/10\/14\/faster-xcode-updates\/","title":{"rendered":"Faster Xcode Updates"},"content":{"rendered":"<p><a href=\"https:\/\/blog.kulman.sk\/faster-way-to-download-and-install-xcode\/\">Igor Kulman<\/a> (via <a href=\"https:\/\/twitter.com\/0xced\/status\/1313613337452838917\">C&eacute;dric Luthi<\/a>):<\/p>\n<blockquote cite=\"https:\/\/blog.kulman.sk\/faster-way-to-download-and-install-xcode\/\"><p>Installing Xcode from the Mac App Store might seem like a convenient way to do so but it is too slow and inflexible. You cannot use the Mac App Store to install multiple version of Xcode at the same time if you need them, like when testing with a Xcode beta for an upcoming iOS release. Download from the Mac App Store is incredibly slow and sometimes not even available for days after release (like 11.2.1).<\/p>\n<p>[&#8230;]<\/p>\n<p>Downloading Xcode from the Apple Developer Portal is faster than using the Mac App Store, but it can be made even better. You just need to use the right tools.<\/p>\n<p>[&#8230;]<\/p>\n<p>This script downloads the given Xcode by URL from the Apple Developer Portal, but uses up to 16 separate connections to do so. You will see a significant download speed improvement.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/twostraws\/status\/1316093828575752193\">Paul Hudson<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/twostraws\/status\/1316093828575752193\"><p>Pro tip: if you downloaded Xcode straight from Apple, you can use <code>xip -x Xcode_12.1_GM_seed.xip<\/code> to skip the validation step and save approximately a billion tons of CO&#xB2;.<\/p><\/blockquote>\n\n<p>And don&rsquo;t forget to <a href=\"https:\/\/mjtsai.com\/blog\/2016\/10\/04\/dropboxs-finder-toolbar\/\">turn off Dropbox<\/a>.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2016\/03\/22\/xcode-upgrades-lessons-learned\/\">Xcode Upgrades: Lessons Learned<\/a><\/li>\n<\/ul>\n\n<p id=\"faster-xcode-updates-update-2022-01-17\">Update (2022-01-17): <a href=\"https:\/\/twitter.com\/_saagarjha\/status\/1481356391742771206\">Saagar Jha<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/_saagarjha\/status\/1481356391742771206\">\n<p>Tip: when expanding an Xcode XIP archive, use the command line (xip --expand) rather than Archive Utility. It&rsquo;s at least 25% faster&#x2013;sometimes even twice as fast, depending on the circumstances. They both call into the Bom API, so I profiled both to see why there&rsquo;s a difference.<\/p>\n<p>[&#8230;]<\/p>\n<p>Anyways, the decompression process for a XIP is fairly straightforward: read files out from the XIP&rsquo;s LZMA stream, recompress them with LZFSE if possible, then write them to disk. The compression is handled by AppleFSCompression, and it&rsquo;s more than happy to parallelize the task.<\/p>\n<p>[&#8230;]<\/p>\n<p>Specifically, it&rsquo;s the creation of those half a million files that really hurts overall performance. The &ldquo;driver&rdquo; thread is unable to create files fast enough to keep the worker thread pool busy doing actual work on the CPU, because it&rsquo;s blocked by file operations in the kernel.<\/p>\n<p>[&#8230;]<\/p>\n<p>How expensive is this evaluation? Pretty expensive, it turns out. Filesystem operations might spend up to 30% of their time on CPU just evaluating sandbox policies! And all of these run synchronously on that one thread, so they block everything else from proceeding.<\/p>\n<p>[&#8230;]<\/p>\n<p>Secondly, I found that xip consistently spent less time in Sandbox evaluation. I can&rsquo;t be sure why, but my guess is that it has a simpler profile (it&rsquo;s basically unsandboxed&#8230;) so the policy might be simpler to check. All other things being equal, it&rsquo;s still 25% faster overall.<\/p>\n<\/blockquote>\n\n<p id=\"faster-xcode-updates-update-2022-02-04\">Update (2022-02-04): <a href=\"https:\/\/twitter.com\/kocienda\/status\/1488243080180350976\">Ken Kocienda<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/kocienda\/status\/1488243080180350976\">\n<p>I don&rsquo;t think I have ever successfully downloaded Xcode from the Mac App Store. Just failed again. Simple, convenient, but doesn&rsquo;t work.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Igor Kulman (via C&eacute;dric Luthi): Installing Xcode from the Mac App Store might seem like a convenient way to do so but it is too slow and inflexible. You cannot use the Mac App Store to install multiple version of Xcode at the same time if you need them, like when testing with a Xcode [&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":"2020-10-14T20:25:01Z","apple_news_api_id":"6816f758-a6e4-44df-9c1a-170ab60d2bb0","apple_news_api_modified_at":"2022-02-04T21:21:41Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAg==","apple_news_api_share_url":"https:\/\/apple.news\/AaBb3WKbkRN-cGhcKtg0rsA","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":[47,30,39,1666,138,53,226],"class_list":["post-30450","post","type-post","status-publish","format-standard","hentry","category-technology","tag-dropbox","tag-mac","tag-macappstore","tag-macos-10-15","tag-optimization","tag-sandboxing","tag-xcode"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/30450","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=30450"}],"version-history":[{"count":3,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/30450\/revisions"}],"predecessor-version":[{"id":34925,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/30450\/revisions\/34925"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=30450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=30450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=30450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}