Skip to content

concurrent-ruby Fixed Thread Pool memory leak #3558

Open
@brauliobo

Description

@brauliobo

When running an update on a large dataset I'm seeing a big and steady memory leak with TruffleRuby. The code is proprietary but in essence it is based on a FixedThreadPool from concurrent-ruby:

def ds_waning_peach limit: 1_000, offset: nil
  ds = self.limit limit
  page = ds.all
  pool_run do |pool|
    begin 
      page.each{ |r| pool.post{ yield r } }
      sleep 1 while pool.queue_length > pool.max_length * 2
    end while (page = ds.offset(pool.queue_length).all).present?
  end
end

The above code runs on a large Sequel dataset with a PostgreSQL database.

TruffleRuby Native: steady and quite fast memory increase (40gb after 1h of CPU usage)
image

TruffuleRuby JVM: slower but steady memory increase (25gb after 1h of CPU usage)
image

In the screenshot above Ruby 3.1.2 compiled with jemalloc (pid 1006066) is also running with memory usage stabilized at around 1.2gb

So the same code is run with the 3 rubies, also with the same Gemfile.lock.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions