Cscott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/176732

Change subject: Limit memory usage during directory cleaning.
......................................................................

Limit memory usage during directory cleaning.

We were doing a bread-first traversal of the directory tree, which resulted
in excessive memory usage while cleaning up the postmortem directory, which
had a directory tree with a very large number of leaves.

Change-Id: Id138b7f183ec7ac2fc5139c72fef6341785761ee
---
M lib/threads/gc.js
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection/OfflineContentGenerator
 refs/changes/32/176732/1

diff --git a/lib/threads/gc.js b/lib/threads/gc.js
index e32e135..4b51b1a 100644
--- a/lib/threads/gc.js
+++ b/lib/threads/gc.js
@@ -198,6 +198,9 @@
                var count = 0, errors = [];
                if (!dir || !lifetime) { return; }
                var clean = function( dir, force ) {
+                       // ensure that we don't blow up our memory usage by 
trying to
+                       // do a bread-first traversal of the directory tree.
+                       var dfsclean = Promise.guard( 1, clean );
                        return readdir( dir ).catch( function( error ) {
                                // directory already removed?
                                errors.push( dir );
@@ -216,7 +219,7 @@
                                        }
                                        if ( stat.isDirectory() ) {
                                                var f = ( force > 0 ) ? force - 
1 : 0;
-                                               return clean( fullpath, f 
).then( function() {
+                                               return dfsclean( fullpath, f 
).then( function() {
                                                        return readdir( 
fullpath ).then( function( files ) {
                                                                if 
(files.length === 0) {
                                                                        return 
rmdir( fullpath ).then(function(){

-- 
To view, visit https://gerrit.wikimedia.org/r/176732
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id138b7f183ec7ac2fc5139c72fef6341785761ee
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Collection/OfflineContentGenerator
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to