text icon indicating copy to clipboard operation
text copied to clipboard

Massive performance problem with external storage SMB folders

Open Howaner opened this issue 9 months ago • 1 comments

Describe the bug I have a Nextcloud instance that is extremely slow when opening an SMB share folder with 100 subfolders. It takes about 10 seconds to open. I used xdebug profiler to find out what was causing the performance issues and came across the text plugin. After I removed text plugin, the directory opens in 50ms instead of 10s.

What happens?

  1. User is opening a samba directory with a lot of subdirectories in nextcloud webinterface
  2. DAV is calling propFind() for all subdirectories
  3. Nextcloud is serving the data for the subdirectories via index and does not make SMB calls for every subdirectory
  4. Text plugin is implementing the propFind() event in WorkspacePlugin.php and executes WorkspaceService::GetFile()
  5. WorkspaceService::GetFile() checks three times if an readme file in this folder exists
  6. This line in WorkspaceService.php is executed: $exists = $folder->getStorage()->getCache()->get($folder->getInternalPath() . '/' . $filename);
  7. External storage plugin checks for the existence of that file via Samba calls. This is slow.
  8. That operation is executed for every subdirectory (100 in this example) multiplied by 3 readme checks => 300 slow SMB calls are made. This takes seconds.

How to mitigate this problem? The propFind() event can be disabled by executing the following command in the nextcloud instance. This brings massive performance improvements when using SMB shares. php occ config:app:set text workspace_available --value=0

How to easy reproduce? 2. Install text and external storage addon and connect an SMB share 3. Open some SMB folder with a few subdirectories and check timings 4. Disable text plugin 5. Open the samba SMB folder again and compare the timings

Expected behavior It must be prevented from making so many Samba calls. Perhaps the index can be used to find out whether the README file exists instead of having to ask the Samba server?

Server details:

  • Nextcloud version: 30.0.8
  • PHP Version: 8.2
  • Apps: files_external and text

Howaner avatar Apr 14 '25 20:04 Howaner

Just found this issue because my newer Nextcloud AIO Instance is somewhat slow compared to my "old" pre-AIO Instance (no SMB share though), and indeed, this Mitigation made it almost as fast as the original Instance. Or at least the UI isn't as slow to react anymore. It has less impact on smaller nested Folder Structures.

AlexHuebi avatar Apr 18 '25 00:04 AlexHuebi