From 4b7cef92f51c2d61330c6473a09077e12d71d608 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Tue, 22 Oct 2024 18:55:11 +0200 Subject: [PATCH] feat(provider): adjustable MaxBatchSize limit (#544) (cherry picked from commit 62b8ab7fb1ca811fe72f9a960dd89a62c9a82586) --- provider/reprovider.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/provider/reprovider.go b/provider/reprovider.go index 1f3e1580a..219bacc75 100644 --- a/provider/reprovider.go +++ b/provider/reprovider.go @@ -183,6 +183,17 @@ func DatastorePrefix(k datastore.Key) Option { } } +// MaxBatchSize limit how big each batch is. +// Some content routers like acceleratedDHTClient have sub linear scalling and +// bigger sizes are thus faster per elements however smaller batch sizes can +// limit memory usage spike. +func MaxBatchSize(n uint) Option { + return func(system *reprovider) error { + system.maxReprovideBatchSize = n + return nil + } +} + // ThroughputReport will fire the callback synchronously once at least limit // multihashes have been advertised, it will then wait until a new set of at least // limit multihashes has been advertised.