Opened 15 years ago
Closed 15 years ago
#10779 closed enhancement (fixed)
optimised unzip_file()
Reported by: | dd32 | Owned by: | dd32 |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | 2.9 |
Component: | Filesystem API | Keywords: | needs-testing featured |
Focuses: | Cc: |
Description (last modified by )
Patch contains
- Optimised unzip_file() function
- Reduced the number of IO operations required (mainly is_dir())
- Simplifies logic to make reading easier.
---
Also note, I played with extracting a file at a time from the ZIP, and writing to the filesystem directly, While it decreased the memory usage from ~12MB to 3MB for the entire unzip operation, It increased the operation time from 5s to 70s, So i've left it to consume memory in order to speed things up.
Attachments (2)
Change History (18)
#2
@
15 years ago
It might be too late now to put the unzip_file() changes into 2.9. Can we separate out the phpdoc changes?
#3
@
15 years ago
- Description modified (diff)
- Keywords needs-testing added
- Milestone changed from 2.9 to 3.0
- Summary changed from file.php: PHPDoc + optimised unzip_file() to optimised unzip_file()
The phpdoc has gone in with another ticket, I forgot i had submitted it here already.
#4
@
15 years ago
- Status changed from new to accepted
I'm going to refresh this patch, and do furthur testing of the changes in the near future.
#7
@
15 years ago
...What?
Yes, The updated patch will be resubmitted once i retest its working with the latest changes to the codebase.
#9
@
15 years ago
Just did some benchmarks on the code.
First item is an array of the number of times each function is called. Then a total of the calls:
Before: array(6) { ["connect"]=> int(1) ["mkdir"]=> int(83) ["put_contents"]=> int(753) ["exists"]=> int(836) ["chmod"]=> int(836) ["is_dir"]=> int(1754) } Total: 4263 After: array(6) { ["connect"]=> int(1) ["is_dir"]=> int(3) ["mkdir"]=> int(83) ["put_contents"]=> int(753) ["exists"]=> int(836) ["chmod"]=> int(836) } Total: 2512
is_dir() is expensive on FTP systems, and all of those exists() calls can be removed by letting chmod() either suceed, or fail. instead of checking if it'll fail (if it exists) and then letting it either suceed or fail.
#10
@
15 years ago
Oh, that was extracting the WordPress 2.9.1 archive on a system using the Direct method..
#12
@
15 years ago
- Keywords needs-testing added; needs-patch removed
Commited this for now, Will see how it fares for others.
For those wanting to test it, just run a few Plugin installs and upgrades and see how you go.
s/for/foreach on a loop for readability