Well, our client's bucket has grown to at least 1M files, and drush s3fs-refresh-cache now dies (with PHP memory_limit set to 1G):

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 12132480 bytes) in /Users/mikeryan/Sites/acme/web/core/lib/Drupal/Core/Database/Connection.php on line 403

Maybe we shouldn't hold all the metadata in memory before writing it to the DB? Yeah, let's do the chunking inside the main loop there...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeryan created an issue. See original summary.

mikeryan’s picture

Status: Active » Needs review
FileSize
1.25 KB

Here it is. Running in drush:

Calling hook drush_s3fs_refresh_cache [1.06 sec, 26.74 MB]                                                   [debug]
Returned from hook drush_s3fs_refresh_cache [1062.24 sec, 31.64 MB]                                          [debug]

A bit better than 1G... I ended up with 1,038,283 rows in s3fs_file.

Also, although I neglected to take the timing previously, it felt quite a bit faster this time.

coredumperror’s picture

Awesome, thanks! I'll see about back-porting that to D7 when I get a chance.

I bet it ran faster due to lack of any need to swap RAM to disk.

jansete’s picture

Nice!! I hope review soon for D8!

  • jansete committed c30ecc9 on 8.x-3.x authored by mikeryan
    Issue #2986407 by mikeryan: s3fs-refresh-cache is not scalable
    
jansete’s picture

Version: 8.x-3.x-dev » 7.x-2.x-dev
Status: Needs review » Patch (to be ported)

Now is in dev branch, thanks a lot mikeryan!

@coredumperror I change version of the issue to review Drupal 7 back-port.

Greetings!

sebas5384’s picture

Hi,

this patch worked like a charm! but I wasn't able to find it at first since I was looking for 8.x issues.

@jansete what do you think if we create another issue to port back the patch to 7.x and leave this issue with the right version?

thanks!!

stevenlafl’s picture

I have a very, very, very large S3 bucket. There is probably just a large amount of metadata in the 10K and perhaps the chunk size should be lowered, or at least have it configurable for those cases.

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 4096 bytes) in /var/www/docroot/core/lib/Drupal/Core/Database/Statement.php on line 59

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 4096 bytes) in /var/www/vendor/composer/ClassLoader.php on line 382

stevenlafl’s picture

Version: 7.x-2.x-dev » 8.x-3.x-dev
Status: Patch (to be ported) » Needs review
FileSize
2.19 KB

The part about adding folders with the values() query ignored the fact there may be a very large amount of folders on S3.
I chunked it out into 200/ea for the INSERT query.

stevenlafl’s picture

Version: 8.x-3.x-dev » 8.x-3.0-alpha13

Wrong version, sorry. This is not a dev patch, it is a patch for alpha13 to replace this one.

stevenlafl’s picture

Ignore this one

stevenlafl’s picture

Version: 8.x-3.0-alpha13 » 8.x-3.x-dev
FileSize
3.04 KB
2.07 KB

Both versions are in this one so it's accessible to everyone.
Folder query is limited to 200 per insert. Someone should do some testing to see what is sane there. It could be the 10,000 above it is fine here too.

stevenlafl’s picture

Version: 8.x-3.x-dev » 8.x-3.0-alpha14
FileSize
2.07 KB

Is no one going to look at this?
Alpha 14.

naveenvalecha’s picture

Version: 8.x-3.0-alpha14 » 8.x-3.x-dev

Moving to 8.x-3.x branch.

  • cmlara committed 14cfcb8 on 8.x-3.x authored by stevenlafl
    Issue #2986407 by stevenlafl: s3fs-refresh-cache is not scalable
    
cmlara’s picture

Status: Needs review » Fixed

Committed the @stevenlafl additional enhancement for folders writing.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.