{"id":104252,"date":"2020-09-22T07:00:00","date_gmt":"2020-09-22T14:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=104252"},"modified":"2020-09-22T06:28:08","modified_gmt":"2020-09-22T13:28:08","slug":"20200922-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20200922-00\/?p=104252","title":{"rendered":"Why does the Disk Cleanup tool&#8217;s Windows Update Cleanup take so long and consume so much CPU?"},"content":{"rendered":"<p>If you ask the Disk Cleanup tool to clean up Windows Update files, you may find that it takes a long time and consumes a lot of CPU. What the heck is it doing? How hard can deleting files be?<\/p>\n<p>The Windows Update Cleanup option is doing more than just deleting files. It&#8217;s basically doing two things.<\/p>\n<p>First, it does the equivalent of <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/manufacture\/desktop\/clean-up-the-winsxs-folder\"> <code>dism \/Online \/Cleanup-Image \/StartComponentCleanup<\/code><\/a>. This is a command that goes by the nickname <i>deep clean<\/i>, and it scavenges the component catalog looking for components that are no longer being referenced. Normally, the system automatically does component scavenging on a schedule maintenance task. The automatic scavenging has a policy of waiting 30 days before removing an unreferenced component, and it also has a self-imposed time limit of one hour. But the special command line above bypasses both the 30-day grace period and the 1-hour timeout. Unreferenced components are removed immediately, and the task will run to completion, even if it takes more than an hour.<\/p>\n<p>(I don&#8217;t know if the one hour timeout is actually meaningful in practice. I suspect it&#8217;s there just as a backstop in case the scavenging process goes haywire.)<\/p>\n<p>The other thing that the <i>Windows Update Cleanup<\/i> task does is check with the <code>Wof\u00adShould\u00adCompress\u00adBinaries<\/code> function to see whether the system would benefit from compression of system files. If so, then it takes the operating system files that aren&#8217;t already compressed and compresses them, storing the result in the WofCompressedData alternate data stream, as I described <a title=\"What is WofCompressedData? Does WOF mean that Windows is a dog?\" href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20190618-00\/?p=102597\"> some time ago<\/a>.<\/p>\n<p>The compression algorithm used by the Windows Overlay Filter is higher quality than a real-time compression algorithm, and it&#8217;s designed so that decompression is fast, but compression is expensive. And that&#8217;s the cost: You need to spend a lot of CPU time to do the compression, which is why the <i>Windows Update Cleanup<\/i> is using so much CPU time.<\/p>\n<p>And it&#8217;s doing the expensive data compression because it&#8217;s trying very hard to free up disk space. Because that&#8217;s presumably why you are running the Disk Cleanup tool.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s doing some real work.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-104252","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>It&#8217;s doing some real work.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/104252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=104252"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/104252\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=104252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=104252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=104252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}