Project

General

Profile

Actions

Feature #17679

open

Ractor incoming channel can consume unlimited resources

Added by marcotc (Marco Costa) over 3 years ago. Updated about 1 year ago.

Status:
Assigned
Target version:
-
[ruby-core:102777]
Tags:

Description

Background

In the ddtrace gem, we want to move telemetry trace sending to a separate background Ractor. We’re concerned that if something goes wrong/gets delayed in this background Ractor, more and more data will accumulate in the send/receive channel until the Ruby VM crashes because it runs out of memory.

How to reproduce (Ruby version & script)

receiver_ractor = Ractor.new do
  loop do
    message = Ractor.receive
    sleep 1
    puts "Processed #{message}"
  end
end

counter = 0
while true
  counter += 1
  receiver_ractor.send(counter)
end

Expectation and result

The result is that the Ruby VM crashes due to out of memory.
We expect the Ruby VM to not crash.

Suggested solutions

Some ideas on how this can be improved:

  • Having a way for the sender of data to detect if the receiver Ractor is falling behind (approximate size of queue, timestamp of last processed item, or similar?).
  • Having a way to limit the Ractor message receive buffer.

Related issues 1 (1 open0 closed)

Related to Ruby master - Feature #18814: Ractor: add method to query incoming message queue size Assignedko1 (Koichi Sasada)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0