about summary refs log tree commit homepage
DateCommit message (Collapse)
2013-04-29test_timerfd: relax timing-sensitive test
This test failed on overloaded systems (and may still fail) Unfortunately timers are hard to test as system latency must be taken into account.
2013-04-29test_kqueue_io: test for multiple event return
This is not _my_ common use case, but some people may want to fetch multiple events at once.
2013-04-29test_kqueue: join thread after test
It's good to cleanup after ourselves.
2013-04-29fork-safe "to_io" in high-level epoll/kqueue
We need to validate the underlying IO object before using it in a forked child.
2013-04-29test_epoll: avoid sleeping inside a signal handler
It's generally unsafe to sleep inside a signal handler, and seems to cause intermittent test failures.
2013-04-29test: remove Rubinius-specific checks and skips
These skips no longer seem needed. Removed the GC tests since they were unreliable (even on MRI), anyways.
2013-04-29test_epoll: remove assert_nothing_raised
assert_nothing_raised hides backtraces on real errors, so we'll stop doing it, now.
2013-04-29preliminary kqueue support
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)
2013-04-29pkg.mk: allow passing arguments to extconf
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.
2013-04-29allow building without epoll (or inotify) support
We will support kqueue on FreeBSD-based systems.
2013-04-21epoll: enforce maxevents > 0 before memory allocation
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.
2013-04-21favor comparison against 0 for error checking
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.
2013-04-13set close-on-exec by default under Ruby 2.0
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.
2013-04-13extconf: remove pthread checks
We no longer need to use pthread_* functionality.
2013-04-13README: update description
Ruby 2.0 is out and we're compatible. Also, we've always supported EPOLLONESHOT, promote it.
2013-04-13doc: rdoc fixes and cleanups
Our usage of rdoc was incorrect in some places and causing internal methods to become visible.
2013-04-13.wrongdoc: add public/private email addresses
This was forgotten for some reason, no longer.
2013-04-12epoll: cleanup GVL-release code for Ruby 2.0.0
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.
2013-04-12inotify: thread-safe Inotify#take for rbx
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.
2013-04-12inotify: use thread-local internal buffer
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.
2013-04-12license + gem packaging cleanups
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
2013-04-12.gitignore: add .rbx
Rubinius drops this directory on us nowadays
2013-04-12test_epoll_gc: force GC on EMFILE/ENFILE
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.
2013-04-12avoid ENOMEM checking in common code paths
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.
2013-04-12epoll: cache alignment for per-thread structure
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.
2013-04-12epoll: implement thread-safety for mark/flag arrays
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.
2013-04-12split Epoll and Epoll::IO, rewrite Epoll in Ruby
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.
2013-04-12test_epoll: synchronize writes to the pipe array
Concurrent modification of the array is not thread-safe.
2013-04-12test_epoll: fix timing error in test
We need to record the time before the thread is spawned for correct timing
2013-04-03util: comment explaining non-use of FIONBIO
I was about to change this to the FIONBIO here myself before I realized we do not frequently _change_ file flags.
2013-03-01reload FD after rb_io_wait_*able functions
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.
2013-01-24epoll: update documentation for multi-threaded use
We forgot to update this documentation when we released 3.1.0
2013-01-23epoll: use pthread_once properly
pthread_once_t must be static to be effective. This bug only affects apps which load sleepy_penguin multiple times.
2013-01-17epoll: add EPOLLWAKEUP constant
This was added in Linux 3.5 and glibc 2.17
2013-01-17Revert "epoll: avoid EPOLL_CTL_MOD race condition"
This reverts commit 02e5a91b24983d96b342c007661966495ccdb619. This workaround may have unintended side-effects for apps using EPOLL_CTL_DEL.
2013-01-03epoll: avoid EPOLL_CTL_MOD race condition
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.
2012-05-02sleepy_penguin 3.1.0 - minor fixes and features v3.1.0
* 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")
2012-05-02reintroduce SLEEPY_PENGUIN_VERSION constant
We unfortunately need it since we switched to the per-thread epoll_wait structures.
2012-05-02timerfd: remove unusable constants (never released)
timerfd currently (Linux 3.3.x) only supports CLOCK_REALTIME and CLOCK_MONOTONIC, and not every single clock supported by POSIX clocks.
2012-05-02epoll: update comment on free(NULL) usage
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...
2012-03-26teset: epoll used as a queue
This is a testcase I wrote a few months ago
2012-03-22epoll: use per-thread data structure for concurrent Epoll#wait
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
2012-03-22test_epoll: disable expensive test without STRESS
Tests run a lot faster, now, and this isn't functionality we have to worry about often now that I better understand MRI internals.
2012-03-22sleepy_penguin.h: add prototype for rb_thread_io_blocking_region
This function is exposed in the libruby-static archive for Ruby 1.9.3, but there is no publically-declared prototype for it.
2012-03-07epoll: split out ugly green thread code
It's ugly and confusing to look at, so split it out.
2012-02-23test: new testcase for edge-triggered accept
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...
2011-07-26use sleepy.penguin@librelist.org address instead of .com
Neither we nor librelist are commercial projects, so use the TLD preferred for non-profit entities.
2011-07-26disable SignalFD interface
It's a waste of memory to have something that has no chance of working reliably with any existing Ruby runtimes.
2011-07-26rb_update_max_fd() support for epoll
This is the only descriptor we manage ourselves and don't use IO.for_fd with (epoll is quite "special" wrt fork).
2011-06-16fix unused variable warnings
Oops...