From 02dd5c5853c90eeea5e22ac5aa8abe0af06931d6 Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Mon, 12 Feb 2024 16:24:19 +0100 Subject: [PATCH] (converter) Look at properties when deciding pool size Look at whether the property 'system.conserveProperty' is enabled when deciding he default pool size for the converter. If true, a much more conservative default is used, limiting the risk of running out of memory. --- .../java/nu/marginalia/converting/ConverterMain.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/processes/converting-process/src/main/java/nu/marginalia/converting/ConverterMain.java b/code/processes/converting-process/src/main/java/nu/marginalia/converting/ConverterMain.java index f9f108f2..5e87f688 100644 --- a/code/processes/converting-process/src/main/java/nu/marginalia/converting/ConverterMain.java +++ b/code/processes/converting-process/src/main/java/nu/marginalia/converting/ConverterMain.java @@ -120,10 +120,11 @@ public class ConverterMain extends ProcessMainClass { public void convert(CrawlPlan plan) throws Exception { - final int maxPoolSize = - Integer.getInteger("converter.poolSize", - Math.clamp(Runtime.getRuntime().availableProcessors() - 2, 1, 32) - ); + final int defaultPoolSize = Boolean.getBoolean("system.conserveMemory") + ? Math.clamp(Runtime.getRuntime().availableProcessors() / 2, 1, 4) // <-- conserve memory + : Math.clamp(Runtime.getRuntime().availableProcessors() - 2, 1, 32); // <-- a more liberal pool size + + final int maxPoolSize = Integer.getInteger("converter.poolSize", defaultPoolSize); try (BatchingWorkLog batchingWorkLog = new BatchingWorkLogImpl(plan.process.getLogFile()); ConverterWriter converterWriter = new ConverterWriter(batchingWorkLog, plan.process.getDir()))