Skip to content

Commit

Permalink
trying to reduce memory footprint 001
Browse files Browse the repository at this point in the history
  • Loading branch information
Ifiht committed Jan 31, 2024
1 parent 57be86b commit b6ff3e5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ gem "telegram-bot-ruby", "~> 1.0"
gem "require_all"
gem "beaneater"
gem "net-ping", "~> 1.7", ">= 1.7.8"
gem "jemalloc"
gem "listen", "~> 2.0"
gem "httpx"
gem "puma"
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ GEM
httpx (0.23.4)
http-2-next (>= 0.4.1)
ice_nine (0.11.2)
jemalloc (1.0.1)
listen (2.10.1)
celluloid (~> 0.16.0)
rb-fsevent (>= 0.9.3)
Expand Down Expand Up @@ -70,6 +71,7 @@ PLATFORMS
DEPENDENCIES
beaneater
httpx
jemalloc
listen (~> 2.0)
net-ping (~> 1.7, >= 1.7.8)
pp
Expand Down
3 changes: 2 additions & 1 deletion src/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def eval_string(str)
#[[[[[[ DEFINE THREADS ]]]]]]
core_threads = []
job_threads = []
a = [] # empty holder array for jobs
semaphore = Mutex.new
bstalk = Beaneater.new("#{beanstalk_host}\:#{beanstalk_port}")
bstalk.tubes.find("core") # also creates the tube
Expand Down Expand Up @@ -76,13 +77,13 @@ def eval_string(str)
core_threads << Thread.new {
loop do
if not job_threads.empty?
a = [] # Initialize empty holder array for jobs
semaphore.synchronize { # Only modify job_threads in semaphore
a = job_threads
job_threads = []
} # Moving the jobs to array 'a' allows us to re-use job_threads
a.each { |thr| thr.join }
end #if
sleep 0.00024
end #loop
}

Expand Down

0 comments on commit b6ff3e5

Please sign in to comment.