Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horrible performance on Draft files. #67

Closed
theTigerDuck opened this issue May 7, 2024 · 2 comments
Closed

Horrible performance on Draft files. #67

theTigerDuck opened this issue May 7, 2024 · 2 comments

Comments

@theTigerDuck
Copy link

Even using jgivoni\Flysystem\Cache\CacheAdapter for every draft file gets at least 20 times called "doesObjectExistV2" plus more for its variants. I got rid of the Hashfolder by doing this:

---
Name: assetsflysystemfix
After:
  - "#assetsflysystem"
---
SilverStripe\Core\Injector\Injector:
  # Define protected resolution strategy
  SilverStripe\Assets\FilenameParsing\FileResolutionStrategy.protected:
    class: SilverStripe\Assets\FilenameParsing\FileIDHelperResolutionStrategy
    properties:
      DefaultFileIDHelper: '%$SilverStripe\Assets\FilenameParsing\NaturalFileIDHelper'
      ResolutionFileIDHelpers:
        - '%$SilverStripe\Assets\FilenameParsing\NaturalFileIDHelper'
      VersionedStage: Stage

otherwise it's even more calls of "doesObjectExistV2" because it fist looks for the file without the hash.

@wilr
Copy link
Member

wilr commented Jun 11, 2024

HI @theTigerDuck can you test this PR and see if you get better performance? #70

@wilr wilr closed this as completed Jun 11, 2024
@theTigerDuck
Copy link
Author

Hi @wilr,

thanks for the grat work. Unfortunately I hadn't time to test this. Now that it's merged I installed it and there are still some issues.

First of all PublicCDNAdapter does not get used. Instead of:

---
Name: silverstripes3-cdn-custom
Only:
  envvarset: AWS_PUBLIC_CDN_PREFIX
After:
  - '#silverstripes3-cdn'
---
SilverStripe\Core\Injector\Injector:
  SilverStripe\S3\Adapter\PublicAdapter:
    class: SilverStripe\S3\Adapter\PublicCDNAdapter
    constructor:
      s3Client: '%$Aws\S3\S3Client'
      bucket: '`AWS_BUCKET_NAME`'
      prefix: '`AWS_PUBLIC_BUCKET_PREFIX`'
      visibility: null
      mimeTypeDetector: null
      cdnPrefix: '`AWS_PUBLIC_CDN_PREFIX`'
      options: []
      cdnAssetsDir: '`AWS_PUBLIC_BUCKET_PREFIX`'

I had to change it to:

---
Name: silverstripes3-cdn-custom
Only:
  envvarset: AWS_PUBLIC_CDN_PREFIX
After:
  - "#assetsflysystem"
  - "#silverstripes3-flysystem"
  - "#silverstripes3-cdn"
---
SilverStripe\Core\Injector\Injector:
  SilverStripe\Assets\Flysystem\PublicAdapter:
    class: SilverStripe\S3\Adapter\PublicCDNAdapter
    constructor:
      s3Client: '%$Aws\S3\S3Client'
      bucket: "`AWS_BUCKET_NAME`"
      prefix: "`AWS_PUBLIC_BUCKET_PREFIX`"
      visibility: null
      mimeTypeDetector: null
      cdnPrefix: "`AWS_PUBLIC_CDN_PREFIX`"
      options: []
      cdnAssetsDir: "`AWS_PUBLIC_BUCKET_PREFIX`"

Whenever I puplish a file. It gives me "File could not be found.". Physically it's there in the public folder. But in the AssetAdmin it's not until I call ?flush=all manually.

Because of privious performance issius I had a file extension, that autopublishes everything on upload.
public function onAfterUpload(){
$this->getOwner()->publishSingle();
}
this leads to errors un upload because for some reason readFiles is called on the protected folder afer file is allready located in public. It's probably the same reason why I get "File could not be found."

Do you have any suggestions?
I would love to here from you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants