From c1b54d1aaae5607152a3b94908ccec8d9613ae94 Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Mon, 7 Nov 2022 22:42:29 +0100 Subject: [PATCH 1/3] Simplify deleteFeed --- core.js | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/core.js b/core.js index d8626cbc..a0fa8449 100644 --- a/core.js +++ b/core.js @@ -757,24 +757,15 @@ exports.init = function (sbot, config) { () => { if (!state.has(feedId)) return cb() - self.query( - where(author(feedId)), - asOffsets(), - toCallback((err, offsets) => { + pull( + self.query(where(author(feedId)), asOffsets(), toPullStream()), + pull.asyncMap(log.del), + pull.collect((err) => { // prettier-ignore - if (err) return cb(clarify(err, 'deleteFeed() failed to query jitdb for ' + feedId)) + if (err) return cb(clarify(err, 'deleteFeed() failed for feed ' + feedId)) - push( - push.values(offsets), - push.asyncMap(log.del), - push.collect((err) => { - // prettier-ignore - if (err) return cb(clarify(err, 'deleteFeed() failed for feed ' + feedId)) - - state.delete(feedId) - indexes.base.removeFeedFromLatest(feedId, cb) - }) - ) + state.delete(feedId) + indexes.base.removeFeedFromLatest(feedId, cb) }) ) } From fc669f7109a3c3d82baaf06e68048f4cccc22d75 Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Tue, 8 Nov 2022 10:53:27 +0100 Subject: [PATCH 2/3] Use onEnd instead of collect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: André Staltz --- core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core.js b/core.js index a0fa8449..725c97ef 100644 --- a/core.js +++ b/core.js @@ -760,7 +760,7 @@ exports.init = function (sbot, config) { pull( self.query(where(author(feedId)), asOffsets(), toPullStream()), pull.asyncMap(log.del), - pull.collect((err) => { + pull.onEnd((err) => { // prettier-ignore if (err) return cb(clarify(err, 'deleteFeed() failed for feed ' + feedId)) From 866ccb41e0539eb1d1fc24f3416459d9c826651f Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Tue, 8 Nov 2022 13:58:05 +0100 Subject: [PATCH 3/3] Batch 1000 to speed up deleteFeed --- core.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core.js b/core.js index 725c97ef..1a3997bb 100644 --- a/core.js +++ b/core.js @@ -48,6 +48,7 @@ const { asOffsets, isEncrypted, toCallback, + batch, toPullStream, } = operators @@ -758,7 +759,12 @@ exports.init = function (sbot, config) { if (!state.has(feedId)) return cb() pull( - self.query(where(author(feedId)), asOffsets(), toPullStream()), + self.query( + where(author(feedId)), + asOffsets(), + batch(1000), + toPullStream() + ), pull.asyncMap(log.del), pull.onEnd((err) => { // prettier-ignore