microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
22.62k stars 1.4k forks source link

Slow zip archive extracting when install zig compiler #3505

Open NogrTL opened 11 months ago

NogrTL commented 11 months ago

Brief description of your issue

While installing zig compiler Extracting archive step takes a lot of time. Reported in #3306 as well.

Steps to reproduce

  1. Run winget install -e --id zig.zig
  2. Wait until complete

Expected behavior

Speed up extraction

Actual behavior

Extracting took ~8 minutes with Winget.

Both major archive programs (7Zip and WinRAR) took around ~30 sec to do the same. Which is huge (x20 times) difference in time!

Environment

Windows Package Manager v1.5.1881
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22621.2070
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.20.1881.0

Winget Directories
-----------------------------------------------------------------------------------------------------------------------
Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Diag…
User Settings                      %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\sett…
Portable Links Directory (User)    %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User)       %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root              C:\Program Files\WinGet\Packages
Portable Package Root (x86)        C:\Program Files (x86)\WinGet\Packages

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale

Admin Setting                             State
--------------------------------------------------
LocalManifestFiles                        Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled

======================================================
Device name NOGRPC
Processor   AMD Ryzen 5 1600 Six-Core Processor               3.17 GHz
Installed RAM   16.0 GB
Storage: Samsung SSD 980 PRO with Heatsink 1TB
MagicAndre1981 commented 11 months ago

Issue is defender which scans the zip

image

Line # | Process | Stack | Count | Weight (in view) (ms) | % Weight -- | -- | -- | -- | -- | -- 1 | winget.exe (14880) |   | 29930 | 29.966,377600 | 5,39 2 |   | [Root] | 28873 | 28.907,194200 | 5,20 3 |   | \|- ntdll.dll!RtlUserThreadStart | 28844 | 28.878,052900 | 5,20 4 |   | \|    kernel32.dll!BaseThreadInitThunk | 28844 | 28.878,052900 | 5,20 5 |   | \|    \|- combase.dll!CRpcThreadCache::RpcWorkerThreadEntry | 27641 | 27.672,781000 | 4,98 6 |   | \|    \|    combase.dll!CRpcThread::WorkerLoop | 27641 | 27.672,781000 | 4,98 7 |   | \|    \|    combase.dll!CDllHost::WorkerThread | 27641 | 27.672,781000 | 4,98 8 |   | \|    \|    combase.dll!CDllHost::STAWorkerLoop | 27641 | 27.672,781000 | 4,98 9 |   | \|    \|    \|- user32.dll!DispatchMessageWorker | 27640 | 27.671,781000 | 4,98 10 |   | \|    \|    \|    user32.dll!UserCallWinProcCheckWow | 27640 | 27.671,781000 | 4,98 11 |   | \|    \|    \|    combase.dll!ThreadWndProc | 27640 | 27.671,781000 | 4,98 12 |   | \|    \|    \|    combase.dll!ComInvokeWithLockAndIPID | 27640 | 27.671,781000 | 4,98 13 |   | \|    \|    \|    combase.dll!ReentrantSTAInvokeInApartment | 27640 | 27.671,781000 | 4,98 14 |   | \|    \|    \|    combase.dll!ServerCall::ContextInvoke | 27640 | 27.671,781000 | 4,98 15 |   | \|    \|    \|    combase.dll!SyncServerCall::StubInvoke | 27640 | 27.671,781000 | 4,98 16 |   | \|    \|    \|    combase.dll!DefaultStubInvoke | 27640 | 27.671,781000 | 4,98 17 |   | \|    \|    \|    combase.dll!ObjectMethodExceptionHandlingAction< > | 27640 | 27.671,781000 | 4,98 18 |   | \|    \|    \|    \|- rpcrt4.dll!CStdStubBuffer_Invoke | 27632 | 27.663,781200 | 4,98 19 |   | \|    \|    \|    \|    combase.dll!CStdStubBuffer_Invoke | 27632 | 27.663,781200 | 4,98 20 |   | \|    \|    \|    \|    rpcrt4.dll!NdrStubCall3 | 27632 | 27.663,781200 | 4,98 21 |   | \|    \|    \|    \|    rpcrt4.dll!Ndr64StubWorker | 27632 | 27.663,781200 | 4,98 22 |   | \|    \|    \|    \|    \|- rpcrt4.dll!Invoke | 27631 | 27.662,786400 | 4,98 23 |   | \|    \|    \|    \|    \|    \|- windows.storage.dll!CFileOperation::PerformOperations | 24919 | 24.950,490000 | 4,49 24 |   | \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CFileOperation::PrepareAndDoOperations | 24918 | 24.949,458000 | 4,49 25 |   | \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CFileOperation::_EnumRootDo | 22047 | 22.078,134500 | 3,97 26 |   | \|    \|    \|    \|    \|    \|    \|    \|    windows.storage.dll!CRecursiveFolderOperation::Do | 22047 | 22.078,134500 | 3,97 27 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::ProcessWorkItem | 22046 | 22.077,134500 | 3,97 28 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::_ProcessChildren | 22040 | 22.071,043100 | 3,97 29 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::ProcessWorkItem | 22038 | 22.069,043100 | 3,97 30 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::_ProcessChildren | 20894 | 20.924,939800 | 3,76 31 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::ProcessWorkItem | 20888 | 20.918,929700 | 3,76 32 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::_ProcessChildren | 20732 | 20.762,846400 | 3,74 33 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::ProcessWorkItem | 20502 | 20.532,491000 | 3,69 34 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::_ProcessChildren | 13666 | 13.688,198500 | 2,46 35 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::ProcessWorkItem | 13584 | 13.606,034700 | 2,45 36 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::_ProcessChildren | 11706 | 11.724,882300 | 2,11 37 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::ProcessWorkItem | 11525 | 11.543,569900 | 2,08 38 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::_ProcessChildren | 6870 | 6.881,567000 | 1,24 39 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::ProcessWorkItem | 6700 | 6.711,137700 | 1,21 40 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::_SetupAndPerformOp | 3750 | 3.754,999500 | 0,68 41 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyWorkItem::_DoOperation | 3728 | 3.732,884200 | 0,67 42 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyOperation::Do | 3273 | 3.278,219900 | 0,59 43 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- windows.storage.dll!CCopyOperation::_CreateDestinationOrCopyItemWithRetry | 3071 | 3.075,968900 | 0,55 44 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- zipfldr.dll!CZipTransfer::CopyItem | 2972 | 2.976,732900 | 0,54 45 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- zipfldr.dll!ExtractZipToFile | 2942 | 2.946,713400 | 0,53 46 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- zipfldr.dll!CArchiveIDList::ExtractFromZipToFile | 2941 | 2.945,712500 | 0,53 47 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- zipfldr.dll!CheckUnZippedFile | 2560 | 2.563,526500 | 0,46 48 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- shdocvw.dll!CAttachmentServices::_SaveHelper | 2536 | 2.539,527800 | 0,46 49 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- shdocvw.dll!CAttachmentServices::_OpAntiVirus | 1492 | 1.492,683600 | 0,27 50 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- shdocvw.dll!_SHExtCoCreateInstanceAndScan | 1476 | 1.476,709100 | 0,27 51 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- MpOAV.dll! | 1466 | 1.466,734400 | 0,26 52 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    MpOAV.dll! | 1466 | 1.466,734400 | 0,26 53 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- MpOAV.dll! | 1160 | 1.160,770000 | 0,21 54 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- MpOAV.dll! | 820 | 820,467000 | 0,15 55 |   | \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|    \|- MpClient.dll! | 465 | 465,342400 | 0,08 zipfldr.dll!**ExtractZipToFile** calls zipfldr.dll!**CheckUnZippedFile** which later calls shdocvw.dll!CAttachmentServices::_**OpAntiVirus** and shdocvw.dll!_SHExt**CoCreateInstanceAndScan** and this calls Defender functions from MpOAV.dll and MpClient.dll
InternalHigh commented 6 months ago

Can you replace usage of zipfldr.dll with a decent implementation?

pedrohgmacedo commented 2 months ago

I'm having this problem. I have windows defender turned off, and it still takes more than 1 minute to extract a file.

gonchik commented 2 weeks ago

Nice shot! Thank you!