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)

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


Attachments

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.

Note You need to log in before you can comment on or make changes to this bug.