From 77930217dfb31317c34e5589f2134e6d5527358b Mon Sep 17 00:00:00 2001 From: saint Date: Sat, 17 Aug 2024 02:56:46 +1000 Subject: [PATCH] v0.39.6 Fixes/tweaks in calculate_dynamic_pool_size --- gossamer_forums.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gossamer_forums.rb b/gossamer_forums.rb index d2e745a..52722a6 100644 --- a/gossamer_forums.rb +++ b/gossamer_forums.rb @@ -1,7 +1,7 @@ # Federated Computer, Inc. # David Sainty 2024 A.D. # Gossamer Threads to Discourse -- Migration-Import Script -# v0.39.5 Add SQLite table for tracking successful post importation; Split out user import into three separate callable methods; require sys/proctable +# v0.39.6 Fixes/tweaks in calculate_dynamic_pool_size require 'mysql2' require 'open-uri' @@ -1022,14 +1022,18 @@ class GossamerForumsImporter < ImportScripts::Base def calculate_dynamic_pool_size # Fetch current CPU load average using Sys::ProcTable.loadavg # load_avg = Sys::ProcTable.loadavg.last # Get the 15-minute load average - load_avg = Sys::ProcTable.loadavg + # load_avg = Sys::ProcTable.loadavg + load_avg = File.read('/proc/loadavg').split # Calculate the pool size based on the load average # Adjust the multiplier and threshold as needed # pool_size = [(Concurrent.processor_count / (load_avg + 0.1)).to_i, 1].max # Extract the 1-minute load average from the fetched data - one_minute_load_avg = load_avg[0] + one_minute_load_avg = load_avg[0].to_f + + # Determine how many logical CPU cores are available on the system + cpu_count = Concurrent.processor_count # Log the current load and CPU information for debugging and monitoring purposes puts "1-minute Load Average: #{one_minute_load_avg}, CPU Count: #{cpu_count}"