CopyFile with Zip is horribly slow

Discuss about plugins that don't have a dedicated forum
Post Reply
User avatar
jPV
Posts: 600
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

CopyFile with Zip is horribly slow

Post by jPV »

When I try to extract bigger files with the Zip plugin and CopyFile, extracting gets slower and slower when the extracted file is bigger. The furter it advances, the slower it gets... the first 10 megabytes may get quickly enough that you don't notice it, but then it just slows down and finally crawls to get new bytes extracted.

For example, I have a test archive with a single 260 MB ISO file inside it.

If I unpack it with this way:

Code: Select all

@REQUIRE "zip", {InstallAdapter = True}
zip.OpenArchive(1, "Work:test.zip")
zip.ExtractFile(1, 0, "ram:test.iso")
It takes about 8 seconds... fair enough.

But then if I try to extract it like this:

Code: Select all

@REQUIRE "zip", {InstallAdapter = True}
CopyFile("Work:test.zip", "ram:")
It just takes ages... I waited for 10 MINUTES and it still wasn't extracted even half of the file! I don't know how long it would have taken to wait it to finish.. maybe half hour, maybe whole hour.

For comparison, the XAD plugin extracts it in 13 seconds with the CopyFile function.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: CopyFile with Zip is horribly slow

Post by airsoftsoftwair »

Ironically, I did add some optimizations when I recently fixed the charset issues in the ZIP plugin reported by you so it should be faster now but CopyFile() will always be much slower than using zip.ExtractFile() because of limitations in the plugin API. The ZIP plugin faces pretty much the same restrictions as the XAD plugin here. So what I said about the XAD plugin applies here as well. And there's also a word of warning in the doc.

Nevertheless, CopyFile() performance will be better in the next version but zip.ExtractFile() will always be much faster.

Code: Select all

- New: Added some optimizations to make unpacking faster via the directory adapter installed by zip.hwp
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: CopyFile with Zip is horribly slow

Post by airsoftsoftwair »

Code: Select all

- New [SDK]: Added HWFOPENFLAGS_WONTSEEK flag for FOpen(); Hollywood will set this flag in case it doesn't
  need to seek the file that should be opened; this allows file adapters to use optimized I/O in case the
  file will never be seeked; note that even if HWFOPENFLAGS_WONTSEEK is set, Hollywood can still call
  FSeek() to query the current cursor position or to rewind the file back to 0 so your plugin must be able
  to handle that

Code: Select all

- New: The plugin now makes use of a new Hollywood API to speed up file I/O; this can drastically speed up
  copying bigger files from zip archives using CopyFile() and drastically reduce memory consumption; this
  feature is only available for Hollywood versions newer than 9.1 
Post Reply