v0.39.6 Fixes/tweaks in calculate_dynamic_pool_size

This commit is contained in:
David Sainty 2024-08-17 02:56:46 +10:00
parent e5e6dff339
commit 77930217df

View File

@ -1,7 +1,7 @@
# Federated Computer, Inc. # Federated Computer, Inc.
# David Sainty <saint@federated.computer> 2024 A.D. # David Sainty <saint@federated.computer> 2024 A.D.
# Gossamer Threads to Discourse -- Migration-Import Script # 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 'mysql2'
require 'open-uri' require 'open-uri'
@ -1022,14 +1022,18 @@ class GossamerForumsImporter < ImportScripts::Base
def calculate_dynamic_pool_size def calculate_dynamic_pool_size
# Fetch current CPU load average using Sys::ProcTable.loadavg # 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.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 # Calculate the pool size based on the load average
# Adjust the multiplier and threshold as needed # Adjust the multiplier and threshold as needed
# pool_size = [(Concurrent.processor_count / (load_avg + 0.1)).to_i, 1].max # pool_size = [(Concurrent.processor_count / (load_avg + 0.1)).to_i, 1].max
# Extract the 1-minute load average from the fetched data # 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 # 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}" puts "1-minute Load Average: #{one_minute_load_avg}, CPU Count: #{cpu_count}"