ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: Eric Wong via ruby-core <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: Eric Wong <normalperson@yhbt.net>
Subject: [ruby-core:117361] Re: [Ruby master Feature#19057] Hide implementation of `rb_io_t`.
Date: Thu, 28 Mar 2024 08:32:57 +0000	[thread overview]
Message-ID: <20240328083257.M319689@dcvr> (raw)
In-Reply-To: <redmine.journal-107442.20240323214955.3344@ruby-lang.org>

"ioquatix (Samuel Williams) via ruby-core" <ruby-core@ml.ruby-lang.org> wrote:
> Issue #19057 has been updated by ioquatix (Samuel Williams).
> 
> 
> > Why don't you reconsider the "nested public interface" approach?
> 
> My assessment of this approach is that it would require a rewrite of all internal code that accesses `rb_io_t` internals. Rewriting code isn't a problem, but it takes a lot of time and effort that I don't have in abundance right now. Additionally, it's still only a partial solution. One of the issues is accessing the file descriptor directly and the handling of `IO#close` from a different thread/fiber. Using the file descriptor directly can be problematic.

Again, why not the container_of solution I proposed?

It shouldn't be that much for you since the relevant core
internals could be divorced from extensions and significantly
less work for stressed out and overworked downstream maintainers.


Cross-thread IO#close or close(2) is a PITA to deal with
portably if another thread is using that FD in any way.
This applies to pure C projects, too, not just Ruby ones.
Either:

1) ensure only one thread operates on a given FD and closes it;
   this is typical for stream FDs.

2) get all threads to abandon the FD before closing it.
   I do this for thread-shared packetized FDs which are
   analogous to Queue (O_DIRECT pipe, SOCK_SEQPACKET,
   listen sockets, kqueue/epoll FDs, etc...).

Atomics + out-of-band (pthread_kill) signaling work for both
cases.  I've also used sentinel values in-band for packetized
FDs (analogous to pushing `:stop' messages into a thread-shared
Queue, like forcing a connect() in one thread to get blocking
accept() to wake up; or adding an (eventfd||pipe) into a
(kqueue||epoll) from another thread (it's 100% safe to
EPOLL_CTL_ADD||EV_ADD from different threads and I've been
abusing this safety for well over a decade)

> > Ruby lost numerous users due to a never-ending stream of incompatibilities introduced every year.
> 
> Compatibility and progress are always something to balance out. I think on the whole, Ruby does a pretty decent job at it. Lack of forward progress also causes users to look elsewhere as the language stagnates. So this isn't just. a matter of "preserve compatibility at all costs", as those costs will be the same. The hard part is finding the middle ground of compatibility and progress. Both compatibility at any cost, and progress at any cost, are naive statements.

git and Linux kernel do a pretty good job at maintaining
compatibility while adding new features.  OTOH some of the
incompatibility proposals for Perl 5 have made me look into
writing more C...
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

  reply	other threads:[~2024-03-28  8:33 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-15  1:54 [ruby-core:110300] [Ruby master Bug#19057] Hide implementation of `rb_io_t` ioquatix (Samuel Williams)
2022-10-15  2:12 ` [ruby-core:110301] " ioquatix (Samuel Williams)
2022-10-15 11:02 ` [ruby-core:110309] " Eregon (Benoit Daloze)
2022-10-17  7:07 ` [ruby-core:110348] " ioquatix (Samuel Williams)
2023-05-27  8:49 ` [ruby-core:113678] [Ruby master Feature#19057] " kjtsanaktsidis (KJ Tsanaktsidis) via ruby-core
2023-05-27  9:58 ` [ruby-core:113680] " Eregon (Benoit Daloze) via ruby-core
2023-05-27 10:12 ` [ruby-core:113681] " ioquatix (Samuel Williams) via ruby-core
2023-05-28  2:19 ` [ruby-core:113689] " ianks (Ian Ker-Seymer) via ruby-core
2023-05-29  9:15 ` [ruby-core:113696] " Eregon (Benoit Daloze) via ruby-core
2023-05-30  1:04 ` [ruby-core:113698] " ioquatix (Samuel Williams) via ruby-core
2023-06-01  0:52 ` [ruby-core:113723] " ioquatix (Samuel Williams) via ruby-core
2023-06-01  9:56 ` [ruby-core:113728] " Eregon (Benoit Daloze) via ruby-core
2023-06-01 11:11 ` [ruby-core:113731] " ioquatix (Samuel Williams) via ruby-core
2023-06-08  2:39 ` [ruby-core:113802] " ioquatix (Samuel Williams) via ruby-core
2023-06-09  8:14 ` [ruby-core:113844] " byroot (Jean Boussier) via ruby-core
2023-06-09  8:33 ` [ruby-core:113845] " ioquatix (Samuel Williams) via ruby-core
2023-06-23 10:36 ` [ruby-core:114014] " kamil-gwozdz via ruby-core
2023-07-07  0:41 ` [ruby-core:114104] " k0kubun (Takashi Kokubun) via ruby-core
2023-07-07  2:04 ` [ruby-core:114106] " nobu (Nobuyoshi Nakada) via ruby-core
2023-07-26 22:23 ` [ruby-core:114298] " k0kubun (Takashi Kokubun) via ruby-core
2023-08-24 13:41 ` [ruby-core:114491] " ioquatix (Samuel Williams) via ruby-core
2023-08-25  1:07 ` [ruby-core:114521] " naruse (Yui NARUSE) via ruby-core
2023-08-25  1:43 ` [ruby-core:114522] " ioquatix (Samuel Williams) via ruby-core
2023-09-05  9:24 ` [ruby-core:114627] " byroot (Jean Boussier) via ruby-core
2024-01-14  3:20 ` [ruby-core:116197] " ioquatix (Samuel Williams) via ruby-core
2024-01-14  3:30 ` [ruby-core:116198] " ioquatix (Samuel Williams) via ruby-core
2024-01-15  3:23   ` [ruby-core:116211] " Eric Wong via ruby-core
2024-01-15  5:49 ` [ruby-core:116213] " ioquatix (Samuel Williams) via ruby-core
2024-01-23 12:56   ` [ruby-core:116377] " Eric Wong via ruby-core
2024-01-23 13:44 ` [ruby-core:116379] " Eregon (Benoit Daloze) via ruby-core
2024-01-24  1:03   ` [ruby-core:116389] " Eric Wong via ruby-core
2024-03-18  1:58 ` [ruby-core:117204] " mame (Yusuke Endoh) via ruby-core
2024-03-18  5:22 ` [ruby-core:117206] " ioquatix (Samuel Williams) via ruby-core
2024-03-18  7:43 ` [ruby-core:117207] " byroot (Jean Boussier) via ruby-core
2024-03-18  8:03 ` [ruby-core:117208] " ioquatix (Samuel Williams) via ruby-core
2024-03-19  2:35 ` [ruby-core:117220] " mame (Yusuke Endoh) via ruby-core
2024-03-23 18:23   ` [ruby-core:117298] " Eric Wong via ruby-core
2024-03-19  3:07 ` [ruby-core:117224] " matz (Yukihiro Matsumoto) via ruby-core
2024-03-19  9:33 ` [ruby-core:117226] " ioquatix (Samuel Williams) via ruby-core
2024-03-19 10:56 ` [ruby-core:117228] " ioquatix (Samuel Williams) via ruby-core
2024-03-19 11:44 ` [ruby-core:117229] " Eregon (Benoit Daloze) via ruby-core
2024-03-19 12:33 ` [ruby-core:117230] " ioquatix (Samuel Williams) via ruby-core
2024-03-20 13:02 ` [ruby-core:117262] " mame (Yusuke Endoh) via ruby-core
2024-03-20 18:40 ` [ruby-core:117267] " Eregon (Benoit Daloze) via ruby-core
2024-03-22  2:28 ` [ruby-core:117289] " ioquatix (Samuel Williams) via ruby-core
2024-03-22  3:55 ` [ruby-core:117290] " k0kubun (Takashi Kokubun) via ruby-core
2024-03-23 21:49 ` [ruby-core:117300] " ioquatix (Samuel Williams) via ruby-core
2024-03-28  8:32   ` Eric Wong via ruby-core [this message]
2024-03-24  4:45 ` [ruby-core:117301] " mame (Yusuke Endoh) via ruby-core
2024-03-25  8:28 ` [ruby-core:117310] " byroot (Jean Boussier) via ruby-core

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=20240328083257.M319689@dcvr \
    --to=ruby-core@ruby-lang.org \
    --cc=normalperson@yhbt.net \
    --cc=ruby-core@ml.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).