Project

General

Profile

Actions

Feature #15438

open

Threads can't switch faster than TIME_QUANTUM_(NSEC|USEC|MSEC)

Added by sylvain.joyeux (Sylvain Joyeux) over 5 years ago. Updated 7 months ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:90624]
Tags:

Description

Thread#priority can be set to negative values, which when looking at the code is meant to reduce the time allocated to the thread. However, as far as I could understand in the codebase, the quantum of time is definitely hard-coded to 100ms (TIME_QUANTUM_...). This means that the "lower allocated time" would only work for threads that would often yield one way or the other (sleep, blocking calls, ...)

My projects would definitely benefit from a faster switching period. I was wondering how best to implement this ability ?

I thought of the following:

  1. globally using an environment variable
  2. globally using an API
  3. trying to adapt dynamically, using the highest needed period
  4. lowering the period when a priority lower than 0 is set, leaving it at the lower period.

Obviously (3) would seem to be the best, but I'm not sure I would be able to get it right in a decent amount of time. (4) seem to be a good trade-off between simplicity and performance (nothing changes if you never use priorities lower than 0, and if you were you basically get what you wanted).

What do you think ?


Files

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0