Bug 31347 - System.IO.Packaging.Package broken for packages with many files.
Summary: System.IO.Packaging.Package broken for packages with many files.
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WindowsBase (show other bugs)
Version: master
Hardware: PC All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-06-24 07:00 UTC by Lev Lehn
Modified: 2017-02-17 04:58 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 31347 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Lev Lehn 2015-06-24 07:00:20 UTC
This also breaks nuget for packages with lots of files. It takes huge amount of time to install a package with many files.

This happens (usual callstack order, parent at the bottom):

System.IO.MonoIO.Read 
System.IO.MonoIO.Read 
System.IO.FileStream.ReadData 
System.IO.FileStream.RefillBuffer 
System.IO.FileStream.ReadInternal 
System.IO.FileStream.Read 
zipsharp.ZipStream.Read 
zipsharp.ZipStream.ReadFile_Native 
zipsharp.NativeUnzip.unzLocateFile 
zipsharp.NativeUnzip.OpenFile
zipsharp.UnzipArchive.GetStream
zipsharp.UnzipArchive.GetCompressionLevel(file inside package)     <--- this (and everything above) is called for every file in the package. This seems to cause a reread of the whole archive - for every file inside it.
System.IO.Packaging.ZipPackage.LoadParts
System.IO.Packaging.ZipPackage.get_Parts
System.IO.Packaging.ZipPackage.GetPartCore
System.IO.Packaging.Package.GetPart
System.IO.Packaging.Package.PartExists
System.IO.Packaging.Package.LoadRelationships 

Basically UnzipArchive wasn't made for archives with many files.

How to reproduce: 
-create a nupkg with many files
-run this code:
var package = Package.Open("broken.nupkg");
var rels = package.GetRelationshipsByType("anonymous");

I've done this, just clone this repo 
https://github.com/llehn/monoPackageBug

Runs fine under MS .NET
Sits using CPU and IO-reading when used with mono (tried windows, linux/x64 and linux/arm)

Proposed solution: UnzipArchive should read the archive once and obtain information about the files. Not just file names, but compression info too.