ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: sylvain.joyeux@m4x.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:90642] [Ruby trunk Bug#15438] Threads can't switch faster than TIME_QUANTUM_(NSEC|USEC|MSEC)
Date: Thu, 20 Dec 2018 13:24:29 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-75808.20181220132423.ffc747f558040e6e@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15438.20181219234045@ruby-lang.org

Issue #15438 has been updated by sylvain.joyeux (Sylvain Joyeux).

File 0001-dynamically-modify-the-timer-thread-period-to-accoun.patch added

This is the implementation of option (4) on 2.5.3 (since that's what I am using). If it has a chance to be accepted, I will forward-port it to 2.6.

----------------------------------------
Bug #15438: Threads can't switch faster than TIME_QUANTUM_(NSEC|USEC|MSEC)
https://bugs.ruby-lang.org/issues/15438#change-75808

* Author: sylvain.joyeux (Sylvain Joyeux)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
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--------------------------------
0001-dynamically-modify-the-timer-thread-period-to-accoun.patch (3.12 KB)


-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2018-12-20 13:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15438.20181219234045@ruby-lang.org>
2018-12-19 23:40 ` [ruby-core:90624] [Ruby trunk Bug#15438] Threads can't switch faster than TIME_QUANTUM_(NSEC|USEC|MSEC) sylvain.joyeux
2018-12-20 13:24 ` sylvain.joyeux [this message]
2019-01-14 18:49 ` [ruby-core:91087] [Ruby trunk Bug#15438] Threads can't switch faster thanTIME_QUANTUM_(NSEC|USEC|MSEC) sylvain.joyeux
2019-01-14 23:30 ` [ruby-core:91090] [Ruby trunk Bug#15438] Threads can't switch faster than TIME_QUANTUM_(NSEC|USEC|MSEC) nobu
2019-01-15 12:08 ` [ruby-core:91102] " sylvain.joyeux
2019-01-16 19:36 ` [ruby-core:91131] " sylvain.joyeux
2019-01-17  0:18 ` [ruby-core:91135] " nobu
2019-03-11 18:29 ` [ruby-core:91787] " sylvain.joyeux
2019-03-11 19:37 ` [ruby-core:91788] " takashikkbn
2019-03-12 11:55 ` [ruby-core:91789] " sylvain.joyeux
2019-03-13 16:40 ` [ruby-core:91814] " eregontp
2019-03-13 17:05 ` [ruby-core:91815] " sylvain.joyeux
2019-03-13 20:10 ` [ruby-core:91817] " eregontp
2019-03-13 23:22 ` [ruby-core:91821] " sylvain.joyeux
2019-03-14 16:56 ` [ruby-core:91833] " eregontp
2019-03-14 17:25 ` [ruby-core:91835] " sylvain.joyeux
2019-03-23 20:02 ` [ruby-core:91959] " sylvain.joyeux
2019-03-24 17:38 ` [ruby-core:91966] " eregontp
2019-03-25 12:32 ` [ruby-core:91977] " sylvain.joyeux
2019-03-25 20:53 ` [ruby-core:91985] " eregontp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-75808.20181220132423.ffc747f558040e6e@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).