Web interface extremely slow in oC 5.x
Expected behaviour
Web interface should not be terribly slow - no more than a few seconds page load time when listing the top level of the '/Shared' directory is not unreasonable
Actual behaviour
Web interface was fine in 4.5.x. Slowness is worst when at the top level of a share and gets better as you go down in the tree. Apparently, owncloud is generating a list of all files and directories under the current path each time (so it takes ages at higher levels of the tree).
This may affect WebDAV too but typically our sync clients when they do complete a sync take 12-20 hours to do so even before the upgrade, so its hard to tell if it made a difference.
We've got over 60k dirs with over 600k files in them. Most are under one account, which is where all the company-wide shares are shared from.
data 66855 Directories containing 634581 files, 214G
data/xxxxxxxxx 3 Directories containing 0 files, 12K
data/xxxxxxxxxxx 64 Directories containing 0 files, 256K
data/xxxxxxx 3488 Directories containing 2 files, 14M
data/xxxxxxx 56366 Directories containing 634532 files, 213G
data/xxxxxx 7 Directories containing 0 files, 28K
data/xxxxxxx 4 Directories containing 0 files, 16K
data/xxxxxxx 5 Directories containing 0 files, 20K
data/xxxxxxx 11 Directories containing 1 files, 68K
data/xxxxxxx 44 Directories containing 0 files, 176K
data/xxxxxxxxx 3 Directories containing 0 files, 12K
data/xxxxxxxxxxxxxx 9 Directories containing 1 files, 60K
data/xxxxxxx 3 Directories containing 0 files, 12K
data/xxxxxx 5 Directories containing 0 files, 20K
data/xxxxxxxxxx 3 Directories containing 0 files, 12K
data/xxxxxxx 32 Directories containing 3 files, 180K
data/xxxxxxxxx 373 Directories containing 10 files, 1.6M
data/admin 11 Directories containing 28 files, 56K
data/xxxxxxx 6371 Directories containing 0 files, 25M
data/xxxxxxx 3 Directories containing 0 files, 12K
data/xxxxxxxxxxx 7 Directories containing 1 files, 52K
data/xxxxxx 42 Directories containing 0 files, 168K
I've done some initial investigation with xdebug, with the worst case scenario (viewing the Shared top level directory in the web interface, so all the folders shared with me are listed). oC seems to scan all files below it judging from the below calls (there's a large number of files in the count above that aren't in these company-wide shares). Here's some of the worst offenders for total self time:
Call entity Defined Calls Cumulative total time Self total time
OC::autoload(...) lib/base.php:80 1491805 88,474,089 uS 84,241,854 uS
\OC\Files\Filesystem::normalizePath(...) lib/files/filesystem.php:568 1491714 157,869,757 uS 45,090,823 uS
\OC\Share::getItems(...) lib/public/share.php:653 21 211,937,577 uS 26,333,808 uS
class_exists(...) 1491722 109,976,073 uS 20,325,080 uS
OC_Share_Backend_Folder->getChildren(...) apps/files_sharing/lib/share/folder.php:24 136 26,011,669 uS 12,488,813 uS
PDOStatementWrapper->fetchRow(...) lib/db.php:1083 1493535 12,327,327 uS 9,753,283 uS
PDOStatement->fetch(...) 1493535 1,151,692 uS 1,151,692 uS
\OC\Share::getItemSharedWithBySource(...) lib/public/share.php:143 17 213,250,503 uS 1,431,313 uS
Steps to reproduce
- Browse to /Shared via the web interface
- Wait for a long time, maybe minutes
- See, it's slow!
Server configuration
Operating system: CentOS 6.4 x86_64
Web server: httpd.x86_64 (apache) 2.2.15-26.el6.centos
Database: MariaDB-server.x86_64 5.5.30-1
PHP version: 5.3.10 x86_64 (built from source)
ownCloud version: 5.0.x (currently 5.0.6, but has occured on 5.0.4+ at least, we didn't try the earlier 5.x builds)
Client configuration
Browser: Firefox, Chrome, Safari, various versions of each
Operating system: OSX, Windows, Ubuntu, CentOS
Logs
Here are some screenshots from the xdebug cachegrind output. I used XCallGraph to view, WinCacheGrind crashed out of memory (~50MB compressed, 3GB file when uncompressed). It took several hours on an 8-core machine for XCallGraph to finish loading the file D:

If you want to look at the cachegrind file from xdebug, clone https://github.com/jonathanvaughn/issuefiles
It's the permission's cache, will refactor that soon. Duplicate of: #2846