From: Eric Wong <bofh@yhbt.net>
To: unicorn-public@yhbt.net
Subject: Re: [PATCH] epollexclusive: avoid Ruby object allocation for buffer
Date: Wed, 1 Mar 2023 23:12:05 +0000 [thread overview]
Message-ID: <20230301231205.M669849@dcvr> (raw)
In-Reply-To: <20230215075813.1732969-1-bofh@yhbt.net>
Eric Wong <bofh@yhbt.net> wrote:
> Leaving a dangling Ruby object around is suboptimal since it
> adds to GC pressure.
>
> `__attribute__((__cleanup__(foo)))' is an old gcc extension to
> provide automatic cleanup functionality by running a pre-declared
> function at the end of scope.
Unfortunately, this can't be usable due to exceptions.
Even if we avoid throwing exceptions ourselves; Thread#raise can
be called by a Rack app which spawns a background thread
> n = (long)rb_thread_call_without_gvl(do_wait, &epw, RUBY_UBF_IO, NULL);
Thread#raise can hit rb_thread_call_wihtout_gvl
> - if (n < 0) {
> - if (errno != EINTR) rb_sys_fail("epoll_wait");
> - n = 0;
> - }
> + if (n < 0 && errno != EINTR) rb_sys_fail("epoll_wait");
> /* Linux delivers events in order received */
> for (i = 0; i < n; i++) {
> struct epoll_event *ev = &epw.events[i];
> @@ -109,7 +113,6 @@ get_readers(VALUE epio, VALUE ready, VALUE readers, VALUE timeout_msec)
> if (RTEST(obj))
> rb_ary_push(ready, obj);
> }
While the `for' loop can be moved ahead of the rb_sys_fail call
and limited in scope, Thread#raise can't be predicted.
I suppose rb_ensure works, but that's a PITA.
next prev parent reply other threads:[~2023-03-01 23:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 7:58 [PATCH] epollexclusive: avoid Ruby object allocation for buffer Eric Wong
2023-03-01 23:12 ` Eric Wong [this message]
2023-03-22 12:53 ` Jean Boussier
2023-03-28 12:24 ` [PATCH] epollexclusive: use maxevents=1 for epoll_wait Eric Wong
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-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://yhbt.net/unicorn/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230301231205.M669849@dcvr \
--to=bofh@yhbt.net \
--cc=unicorn-public@yhbt.net \
/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.
Code repositories for project(s) associated with this public inbox
http://yhbt.net/unicorn.git/
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).