From 251080d08fee2b20563c0757701e9a74782db4b5 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Wed, 9 Oct 2019 16:34:09 +0100 Subject: [PATCH] throttle loading of files to 500/s --- .../main/groovy/com/muwire/core/files/PersisterService.groovy | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/main/groovy/com/muwire/core/files/PersisterService.groovy b/core/src/main/groovy/com/muwire/core/files/PersisterService.groovy index ddb2c277..1c275a81 100644 --- a/core/src/main/groovy/com/muwire/core/files/PersisterService.groovy +++ b/core/src/main/groovy/com/muwire/core/files/PersisterService.groovy @@ -49,6 +49,7 @@ class PersisterService extends Service { Thread.currentThread().setPriority(Thread.MIN_PRIORITY) if (location.exists() && location.isFile()) { + int loaded = 0 def slurper = new JsonSlurper() try { location.eachLine { @@ -58,6 +59,9 @@ class PersisterService extends Service { if (event != null) { log.fine("loaded file $event.loadedFile.file") listener.publish event + loaded++ + if (loaded % 50 == 0) + Thread.sleep(10) } } }