about summary refs log tree commit homepage
DateCommit message (Collapse)
2013-09-30Rakefile: kill raa_update task
RAA is dead
2013-09-26init: avoid redefinition warning for _GNU_SOURCE
This is already defined for most (if not all) Rubies when ruby.h is included.
2013-09-26avoid RARRAY_PTR usage for Linux-only bits
RARRAY_PTR incurs extra overhead on the Ruby 2.1.0 and Rubinius GC implementations, so avoid it. None of these are believed to be performance-critical enough to benefit from RARRAY_PTR in older Rubies, either.
2013-09-26test_epoll: minor compatibility fix for Ruby 2.1.0
Ruby 2.1.0 raises a subclass of Errno::EINPROGRESS, which fails the exact matching of assert_raises. This does not affect any known real code.
2013-09-24Support for broken system without clock_gettime.
Fallback mechanism was copied from clogger: http://clogger.rubyforge.org/ This would also make sleepy_penguin compiles on Mac OS X, which is lacking clock_gettime. All tests passed for me. [ew: fixed indentation Note: this project does not and will never officially support non-Free OSes, but there are likely other systems without clock_gettime but has kqueue (perhaps via libkqueue).] Signed-off-by: Eric Wong <normalperson@yhbt.net>
2013-07-16sleepy_penguin 3.2.0 - minor bug fixes, preliminary kqueue support v3.2.0
epoll support and thread-safety improvements. The dangerous Epoll::IO interface is now an option for those who want to share an epoll descriptor across fork and maintain their own IO object references to avoid extra overhead. Use the regular (high-level) Epoll interface unless you're willing to shoot yourself in the face. There is also preliminary Kqueue support (which should work under libkqueue on Linux). Similar to our epoll interface (and unlike most event libraries/frameworks) our kqueue interface also supports one-shot notifications and _embraces_ multi-threaded use. Note: unlike epoll, kqueue has close-on-fork behavior, so kqueue descriptors are not (ever) inheritable across fork. Added EPOLLWAKEUP constant (Linux 3.5 + glibc 2.17 required) to allow descriptors to prevent system suspend while active (this requires the CAP_BLOCK_SUSPEND privilege). Inotify and Epoll interfaces now use thread-local buffers for thread-safety and improved concurrency without GVL. Errno::EINTR is no longer propagated into Ruby-land, for consistency with existing Ruby IO APIs.
2013-07-03pkg: include generated version header in distribution
Oops, the lack of this header prevented gems from being built + installed properly.
2013-05-15test_epoll_io: ensure subclassing Epoll::IO works
A subclass may want to set CLOEXEC by default.
2013-05-03auto-generate SLEEPY_PENGUIN_VERSION constant
This allows the Ruby-visible constant to always be up-to-date with the release.
2013-05-03README: update with latest features
We support kqueue and Rubinius. Nowadays, we also export the potentially dangerous low-level APIs for epoll and kqueue.
2013-05-03test_kqueue_io: additional test for IO-likeness
We need to ensure Kqueue::IO remains IO-like
2013-05-03kqueue: remove timeout handling for nevents==0
The underlying kevent() itself already bypasses the timeout if nevents==0 (so it is impossible to emulate a sleep function with kevent()).
2013-05-03doc: flesh out kqueue-related documentation
Hopefully this will lead to less confusion among new users.
2013-05-02do not propagate Errno::EINTR into Ruby
To be consistent with I/O wrappers in Ruby, Ruby-land should never see EINTR from kevent or epoll_wait. We will just return zero events if our timeout expired soon after we got signaled.
2013-04-30test_epoll: workaround race condition in test_close
Wait longer before killing the epoll_wait thread, as we may not have entered epoll_wait inside that thread before we send Thread#kill to it. This caused intermittent IOError as the thread delected the Epoll::IO object was already closed, before the snapshot (to prevent GC) could be made.
2013-04-30epoll: clear FD marks snapshot before returning
This allows the heap to reclaim memory sooner (than waiting for GC), lowering memory usage and perhaps speeding up future allocations.
2013-04-30test_epoll: increase delay between signal spamming
Frequently sending signals can lead to high memory usage and slowdowns on some Ruby + malloc implementations.
2013-04-30test_epoll: join thread before return from test
We want to avoid closing the descriptor while the thread is running.
2013-04-29kqueue: workaround lack of RSTRUCT* macros on Rubinius
Rubinius will not support RSTRUCT* macros, so converting the structs to arrays is the least intrusive way to go about our code. ref: https://github.com/rubinius/rubinius/issues/494
2013-04-29kqueue/io: fix MRI 1.8 support code for event retrieval
First off, the timeout is not handled properly when timing out, resulting in an infinite loop. Secondly, arguments were not passed to the yielded block correctly. Finally, the return value of kevent was not returned correctly to the caller.
2013-04-29test_kqueue: only test if IO#autoclose= exists
The high-level kqueue class is not usable without IO#autoclose
2013-04-29test_kqueue_io: join thread in test when done using
Due to strange scheduling, the ensure clause could fire while the thread was still inside wr.syswrite even though the main thread received the event and exited the method.
2013-04-29test_epoll: workaround MRI 1.8 threading bug
Threads do not seem safe to start inside signal handlers on Matz Ruby 1.8
2013-04-29kqueue: set zero timeout if not retrieving events
Having a timeout does not make sense if not retrieving events, so avoid potentially triggering bugs or strange behavior between different kqueue implementations.
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.