Date | Commit message (Collapse) |
|
This test failed on overloaded systems (and may still fail)
Unfortunately timers are hard to test as system latency
must be taken into account.
|
|
This is not _my_ common use case, but some people may
want to fetch multiple events at once.
|
|
It's good to cleanup after ourselves.
|
|
We need to validate the underlying IO object before using
it in a forked child.
|
|
It's generally unsafe to sleep inside a signal handler, and
seems to cause intermittent test failures.
|
|
These skips no longer seem needed. Removed the GC tests since
they were unreliable (even on MRI), anyways.
|
|
assert_nothing_raised hides backtraces on real errors,
so we'll stop doing it, now.
|
|
This is still a work-in-progress, but allows us to support
using a kqueue descriptor from multiple threads.
(e.g. one thread waiting with kevent, while another thread
modifies the watch list via kevent)
|
|
This allows us to use something like:
make build EXTCONF_ARGS='--with-kqueue-include=/usr/include/kqueue \
--with-kqueue-libs=-lkqueue'
To build with libkqueue.
|
|
We will support kqueue on FreeBSD-based systems.
|
|
This prevents overflow and excessive memory usage/OOM error.
Note: the kernel enforces this and returns EINVAL anyways,
we just do it to prevent OOM here.
|
|
When possible, comparisons against zero require one less load
and uses one less register, so this results in smaller code:
$ ~/linux/scripts/bloat-o-meter before.so after.so
add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-57 (-57)
function old new delta
rm_watch 84 83 -1
rb_sp_set_nonblock 80 79 -1
add_watch 127 126 -1
epwait 692 687 -5
s_new 970 921 -49
This style is favored by major C projects, including glibc.
Note: since file and file descriptor flags may eventually use
more bits of an integer, we continue comparing F_GETFD/F_GETFL
return values against -1 to be future proof.
|
|
Ruby 2.0 creates file descriptors with the close-on-exec flag
specified by default. Unless a user specifies flags explicitly,
assume the default is to set the close-on-exec.
This does not change behavior of Ruby 1.9 and earlier.
|
|
We no longer need to use pthread_* functionality.
|
|
Ruby 2.0 is out and we're compatible. Also, we've always
supported EPOLLONESHOT, promote it.
|
|
Our usage of rdoc was incorrect in some places and causing
internal methods to become visible.
|
|
This was forgotten for some reason, no longer.
|
|
rb_thread_blocking_region is deprecated in Ruby 2.0, but
rb_thread_io_blocking region is not (and superior for I/O). So we will
favor rb_thread_io_blocking_region for now.
While we're at it, reimplement green-thread-safe (Ruby 1.8) epoll_wait
in Ruby instead of C. The extra #ifdefs for 1.8.7 were more prone to
bitrot and Ruby code should be easier to follow for Rubyists who care
about 1.8.
|
|
Rubinius provides a Rubinius.synchronize helper for locking
objects which do not otherwise have locks. We need to
synchronize Inotify#take access to prevent the internal array
from being clobbered.
This avoids unnecessary locking overhead on MRI which maintains
a GVL.
|
|
This gives us thread-safety for the internal buffer. While
we're at it, cache-align this buffer to avoid unnecessary
overhead when read() writes to it.
|
|
require_paths and date are automatically set in modern RubyGems
versions. Since we only use modern RubyGems versions, the
licenses= accessor is also activated.
Since the FSF may change mailing addresses again in the future,
prefer the web address to point to licenses. This change is
acceptable for GNU projects, so it should be for us, too:
http://sourceware.org/bugzilla/show_bug.cgi?id=13673
|
|
Rubinius drops this directory on us nowadays
|
|
This helps avoid test errors on Rubinius where rb_gc() is a noop.
Otherwise, we might as well infinite loop on thread-creation to
trigger GC.
|
|
ENOMEM from syscalls such as inotify_add_watch and epoll_ctl are
from the lack of kernel memory, so even a successful rb_gc() is
unlikely to be able to reap memory taken from those slab caches.
|
|
This probably won't make a huge difference in Ruby, but perhaps
one day the unnecessary dirtying of cache lines will affect
performance (and we'll be ready when that day comes).
While we're at it, remove usage of pthread* functions for
thread-local variables. The __thread construct from GCC (and
also implemented by clang) is much easier-to-use than the
pthread_*specific API.
|
|
Concurrent modification of Arrays is thread-unsafe and must be
protected by a Mutex. eventpoll objects inside the Linux kernel
are similarly protected by a (kernel) mutex, and do not need
additional locking.
However, we lock around epoll_ctl here anyways since we must
modify our userland arrays after we modify the kernel structure.
We must modify userland arrays after the kernel structure to
prevent epoll_wait callers from seeing an unreferenced object.
|
|
Epoll::IO is a dangerous, low-level class which is intended
for users aware of the GC and fork behavior of epoll in the
Linux kernel.
Rewriting the higher-level Epoll in Ruby makes it easier to
maintain, especially since Rubinius has no GVL while running
C extensions.
|
|
Concurrent modification of the array is not thread-safe.
|
|
We need to record the time before the thread is spawned for
correct timing
|
|
I was about to change this to the FIONBIO here myself before
I realized we do not frequently _change_ file flags.
|
|
The file descriptor may be closed while GVL is released,
so we must reload the descriptor before and after calling
rb_io_wait_*able functions.
We reload before calling rb_io_wait_*able because the GVL was
released for the function call (read/write) which triggered
EAGAIN.
We reload after calling rb_io_wait_*able because
rb_io_wait_*able releases the GVL, too.
|
|
We forgot to update this documentation when we released 3.1.0
|
|
pthread_once_t must be static to be effective. This bug only
affects apps which load sleepy_penguin multiple times.
|
|
This was added in Linux 3.5 and glibc 2.17
|
|
This reverts commit 02e5a91b24983d96b342c007661966495ccdb619.
This workaround may have unintended side-effects for apps using
EPOLL_CTL_DEL.
|
|
Until everybody updates to a version of the Linux kernel with
this fix, we need to enable a workaround for older kernels using
EPOLL_CTL_DEL + EPOLL_CTL_ADD to emulate EPOLL_CTL_MOD behavior.
This race condition is fixed in Linux upstream
commit 128dd1759d96ad36c379240f8b9463e8acfd37a1 and included in
Linux v3.8-rc2 and later.
This fix will likely be backported to stable and vendor kernels,
so we'll whitelist them as we learn of them.
|
|
* add TimerFD::CANCEL_ON_SET constant
ref: http://www.man7.org/tlpi/api_changes/
* fix concurrent Epoll#wait on the same epoll fd
* SignalFD interface removed (unworkable with Ruby runtimes)
* use rb_update_max_fd() if available (Ruby 1.9.3)
* reintroduce SLEEPY_PENGUIN_VERSION constant ("3.1.0")
|
|
We unfortunately need it since we switched to the
per-thread epoll_wait structures.
|
|
timerfd currently (Linux 3.3.x) only supports CLOCK_REALTIME and
CLOCK_MONOTONIC, and not every single clock supported by POSIX
clocks.
|
|
It's POSIX, and since epoll is Linux-only and Linux
uses glibc which is pretty up-to-date w.r.t POSIX,
we don't have to worry...
|
|
This is a testcase I wrote a few months ago
|
|
This allows multiple threads to park on Epoll#wait (without
holding onto the GVL). This allows a single, one-shot notification
to wake up a single thread (another notification to a different
IO object would wake up another thread).
This allows using the same multi-threaded, EPOLLONESHOT-based
design as cmogstored:
http://bogomips.org/cmogstored/queues.txt
|
|
Tests run a lot faster, now, and this isn't functionality
we have to worry about often now that I better understand
MRI internals.
|
|
This function is exposed in the libruby-static archive for
Ruby 1.9.3, but there is no publically-declared prototype for it.
|
|
It's ugly and confusing to look at, so split it out.
|
|
Found uncommited in my working directory, I can't remember
when/where I wanted to test this, but we might as well for
documentation purposes...
|
|
Neither we nor librelist are commercial projects, so use
the TLD preferred for non-profit entities.
|
|
It's a waste of memory to have something that has no chance
of working reliably with any existing Ruby runtimes.
|
|
This is the only descriptor we manage ourselves and don't
use IO.for_fd with (epoll is quite "special" wrt fork).
|
|
Oops...
|