You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Debugging some slow CP requests in a client project we found that whenever an Asset Field is rendered within a template, and the 'temp' directory for assets is set to a volume, Craft will try to recreate the directory structure for the temp path on every page load.
This was causing significant slowdowns for this particular project because the temp directory was set to a remote S3 FS and it had multiple path parts resulting in several sequential API calls to the remote storage to create directories, each taking a non negligible amount of time.
This is a particularly pronounced issue because most remote object storage platforms don't even need the directories to be created. Maybe it's worth allowing filesystems to define whether they need directories to be pre-created? Then object-key stores can opt out and save a load of API calls.
Steps to reproduce
Use a remote object storage volume
Set the temp upload path to use this volume
Add an asset field to a control panel page
Pages will now load slowly
Expected behavior
Humm, I guess it'd be nice if Craft didn't try to recreate the directories during field render, but instead during the actual upload which would use the temp directory. Alternatively allow remote filesystems to opt-out of directory pre-creation (maybe this is something flysystem should be doing?)
Craft CMS version
4.0.4
PHP version
8.0
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered:
What happened?
Description
Debugging some slow CP requests in a client project we found that whenever an Asset Field is rendered within a template, and the 'temp' directory for assets is set to a volume, Craft will try to recreate the directory structure for the temp path on every page load.
This was causing significant slowdowns for this particular project because the temp directory was set to a remote S3 FS and it had multiple path parts resulting in several sequential API calls to the remote storage to create directories, each taking a non negligible amount of time.
I profiled and tracked it down to this line:
cms/src/services/Assets.php
Line 799 in 264e1aa
Being called from:
cms/src/services/Assets.php
Line 922 in 264e1aa
This is a particularly pronounced issue because most remote object storage platforms don't even need the directories to be created. Maybe it's worth allowing filesystems to define whether they need directories to be pre-created? Then object-key stores can opt out and save a load of API calls.
Steps to reproduce
Expected behavior
Humm, I guess it'd be nice if Craft didn't try to recreate the directories during field render, but instead during the actual upload which would use the temp directory. Alternatively allow remote filesystems to opt-out of directory pre-creation (maybe this is something flysystem should be doing?)
Craft CMS version
4.0.4
PHP version
8.0
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: