Opened 16 months ago
Last modified 16 months ago
#19879 new enhancement
Better caching for get_dirsize
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Multisite | Version: | 3.3.1 |
| Severity: | normal | Keywords: | |
| Cc: | batmoo, djpaul@…, wordpress@…, kpayne@… |
Description
In a multisite install, when trying to determine whether a site has exceeded its storage quota, WordPress will scan through a blog's upload directory and sum up the file sizes, by running filesize against each one. With a large number of files, this can significantly slow down the upload process or certain portions of the Dashboard.
get_dirsize has transient caching in place but this is a single cache entry for all folders. It might be better if WordPress has a separate cache entry for each folder and was invalidated based on context so that get_dirsize does not need to be run constantly on older, unchanged directories as frequently.
Change History (6)
- Cc wordpress@… added
comment:4
in reply to:
↑ description
kurtpayne — 16 months ago
- Cc kpayne@… added
- Type changed from defect (bug) to enhancement
My first thought would be to change recurse_dirsize() like so:
} elseif (is_dir($path)) {
$handlesize = recurse_dirsize( $path );
if ($handlesize > 0)
$size += $handlesize;
}
to:
} elseif (is_dir($path)) {
$handlesize = get_dirsize( $path );
if ($handlesize > 0)
$size += $handlesize;
}
This change would check the cache as it's doing the recursive iteration. This is very optimistic, though. Cache misses would result in a database SELECT and UPDATE/INSERT. For most sites, this change would probably slow things down. Further, this could result in a lot of extra rows in the db that wouldn't serve a useful purpose.
comment:5
jamescollins — 16 months ago
See http://mu.trac.wordpress.org/ticket/1175 for the origins of the get_dirsize() caching.

We worked around this bug by making sure that upload_space_check_disabled was set; this resulted in an immediate speed-up.