0

I want to increase the number of attempts to open ZIP file and my biggest delay is in IO. I thought to use MemoryMappedFile and I was able to improve performance by 20% only.

My CPU usage is only 20% because I got stuck in the IO.

The first time I used dotnetzip i used it like that

zip1 = ZipFile.Read(filename);

After that I decided to use MemoryMappedFile and i use it like that

using (MemoryMappedFile memoryMapped = MemoryMappedFile.CreateFromFile(filename,     FileMode.Open))
{
    var viewStream = memoryMapped.CreateViewStream();
    zip1 = ZipFile.Read(viewStream);
}

I improved it by 20% but I think it should be much much more. Does anyone have an idea? I use it on no more than 10MB zip file size.

Dany Maor
  • 2,391
  • 2
  • 18
  • 26

1 Answers1

0

You have a single-threaded code.

To make use of your CPU you need to open as many threads as your processor can handle at once, where each thread will work with your MemoryMappedFile.

You can start from here Task Parallelism

Rodion
  • 886
  • 10
  • 24
  • dotnetzip can not work with multi-thread and if I work with several files in parallel it works but I manage to reach speeds twice as high with 8 cores. with single core I do 10000 checks and use 13% cpu and with 8 cores i do 20000 checks and use 100% cpu. something does not make sense to me. – Dany Maor Feb 12 '15 at 08:52
  • Memory reading is too slow comparing to CPU processing and while using .Net you can't load file to CPU memory. 8 cores can be busy with synchronization - junk workload in your case. If you don't want to go down there then just think in number of attempts, not in CPU workload. – Rodion Feb 12 '15 at 20:29