From 00492c434ea26696ab3c9be5a2b5020fb02f7d32 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 22 Mar 2017 07:19:56 +0000 Subject: sleepy_penguin 3.5.0 Most notably, kevent and epoll_wait wrappers are now nestable, so you can write your own event loops inside somebody elses event loop (not that it's a good idea, but hey, that's reality, sometimes). https://bogomips.org/sleepy_penguin/SleepyPenguin/Kqueue.html#method-i-kevent https://bogomips.org/sleepy_penguin/SleepyPenguin/Epoll.html#method-i-wait For Linux users, there is now copy_file_range(2) support for copying regular files: https://bogomips.org/sleepy_penguin/SleepyPenguin.html#method-c-copy_file_range There is also a new sendfile wrapper which emulates Linux sendfile behavior regardless of platform. It will use the native sendfile(2) syscall on FreeBSD and Linux, at least. https://bogomips.org/sleepy_penguin/SleepyPenguin.html#method-c-linux_sendfile Wrappers for the splice(2) and tee(2) syscalls also exist for Linux users (vmsplice(2) is omitted): https://bogomips.org/sleepy_penguin/SleepyPenguin.html#method-c-splice https://bogomips.org/sleepy_penguin/SleepyPenguin.html#method-c-tee Along with some related constants: https://bogomips.org/sleepy_penguin/SleepyPenguin.html#F_GETPIPE_SZ https://bogomips.org/sleepy_penguin/SleepyPenguin.html#F_SETPIPE_SZ https://bogomips.org/sleepy_penguin/SleepyPenguin.html#F_MORE https://bogomips.org/sleepy_penguin/SleepyPenguin.html#F_MOVE https://bogomips.org/sleepy_penguin/SleepyPenguin.html#F_NONBLOCK In other words, this release merges the useful parts of the old "io_splice" RubyGem: https://bogomips.org/ruby_io_splice/ Linux 4.5+ epoll users also get EPOLLEXCLUSIVE along existing constants: https://bogomips.org/sleepy_penguin/SleepyPenguin/Epoll.html#EXCLUSIVE Ruby 1.8 and 1.9 support are both gone, Ruby 2.0.0+ is required for keyword args, now(*). 31 changes since 3.4.1: README: fix wording: are => is TODO: add memfd item epoll: allow :CLOEXEC instead of the long constant note the epoll/io.rb file is only for Ruby 1.8 support the splice(2) and tee(2) syscalls implement copy_file_range support for Linux 4.5+ doc: various URL updates (https) unify rb_gc() handling for out-of-FD conditions splice: clarification regarding tee() flags pkg.mk: various updates from other projects copy_file_range: use correct syscall numbers on x86/x86-64 new API for splice and tee doc: remove references to IO#pipe_size accessor remove PIPE_BUF constant definition copy_file_range: move wrapper to Ruby for keyword arg handling gemspec: use SPDX-compatible license specifier implement linux_sendfile support portability fixes for systems w/o splice, copy_file_range tests: switch to test-unit free buffer if pthread_setspecific fails allow nestable TLS buffers within the same thread drop unused Ruby 1.8 support code epoll: add newline to Kernel#warn messages for atomicity favor require_relative over require epoll: add EPOLLEXCLUSIVE constant and documentation kqueue: remove IO#autoclose= and 1.8-related checks sp_copy: remove dummy 1.8 code for non-native threaded Ruby build: remove build-time olddoc dependency copy_file_range: add documentation doc: tests and examples for changing pipe size in Linux doc: avoid incorrect links to Epoll::IO --- GIT-VERSION-GEN | 2 +- lib/sleepy_penguin.rb | 2 ++ lib/sleepy_penguin/cfr.rb | 3 +++ lib/sleepy_penguin/epoll.rb | 3 +++ lib/sleepy_penguin/kqueue.rb | 3 +++ lib/sleepy_penguin/splice.rb | 4 ++++ sleepy_penguin.gemspec | 2 +- 7 files changed, 17 insertions(+), 2 deletions(-) diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index ca0e578..96fcc26 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v3.4.1 +DEF_VER=v3.5.0 GVH=ext/sleepy_penguin/git_version.h LF=' diff --git a/lib/sleepy_penguin.rb b/lib/sleepy_penguin.rb index eff92e6..a69c649 100644 --- a/lib/sleepy_penguin.rb +++ b/lib/sleepy_penguin.rb @@ -37,6 +37,8 @@ module SleepyPenguin # # Newer OSes may be more flexible in whether or not +dst+ or +src+ # is a regular file or socket, respectively. + # + # This method was added in sleepy_penguin 3.5.0. def self.linux_sendfile(dst, src, len, offset: nil) __lsf(dst, src, offset, len) end diff --git a/lib/sleepy_penguin/cfr.rb b/lib/sleepy_penguin/cfr.rb index 01cc4a0..845a736 100644 --- a/lib/sleepy_penguin/cfr.rb +++ b/lib/sleepy_penguin/cfr.rb @@ -19,6 +19,9 @@ module SleepyPenguin # # See copy_file_range(2) manpage for full documentation: # http://man7.org/linux/man-pages/man2/copy_file_range.2.html + # + # This method only works in Linux 4.5+ with sleepy_penguin 3.5.0+, + # and may require up-to-date kernel headers for non-x86/x86-64 systems. def self.copy_file_range(io_in, io_out, len, flags = 0, off_in: nil, off_out: nil) __cfr(io_in, off_in, io_out, off_out, len, flags) diff --git a/lib/sleepy_penguin/epoll.rb b/lib/sleepy_penguin/epoll.rb index 4d23968..7d173c8 100644 --- a/lib/sleepy_penguin/epoll.rb +++ b/lib/sleepy_penguin/epoll.rb @@ -52,6 +52,9 @@ class SleepyPenguin::Epoll # single-threaded applications. +maxevents+ defaults to 64 events. # +timeout+ is specified in milliseconds, +nil+ # (the default) meaning it will block and wait indefinitely. + # + # As of sleepy_penguin 3.5.0+, it is possible to nest + # #wait calls within the same thread. def wait(maxevents = 64, timeout = nil) # snapshot the marks so we do can sit this thread on epoll_wait while other # threads may call epoll_ctl. People say RCU is a poor man's GC, but our diff --git a/lib/sleepy_penguin/kqueue.rb b/lib/sleepy_penguin/kqueue.rb index 2620a12..9f55efc 100644 --- a/lib/sleepy_penguin/kqueue.rb +++ b/lib/sleepy_penguin/kqueue.rb @@ -52,6 +52,9 @@ class SleepyPenguin::Kqueue # Ruby GC, otherwise ObjectSpace._id2ref may return invalid objects. # Unlike the low-level Kqueue::IO#kevent, the block given yields only # a single Kevent struct, not a 6-element array. + # + # As of sleepy_penguin 3.5.0+, it is possible to nest #kevent + # calls within the same thread. def kevent(changelist = nil, *args) @mtx.synchronize { __kq_check } if changelist diff --git a/lib/sleepy_penguin/splice.rb b/lib/sleepy_penguin/splice.rb index 5358ed5..821234b 100644 --- a/lib/sleepy_penguin/splice.rb +++ b/lib/sleepy_penguin/splice.rb @@ -53,6 +53,8 @@ module SleepyPenguin # # See manpage for full documentation: # http://man7.org/linux/man-pages/man2/splice.2.html + # + # Support for this exists in sleepy_penguin 3.5.0+ def self.splice(io_in, io_out, len, flags = 0, off_in: nil, off_out: nil, exception: true) flags = __map_splice_flags(flags) @@ -93,6 +95,8 @@ module SleepyPenguin # # See manpage for full documentation: # http://man7.org/linux/man-pages/man2/tee.2.html + # + # Support for this exists in sleepy_penguin 3.5.0+ def self.tee(io_in, io_out, len, flags = 0, exception: true) flags = __map_splice_flags(flags) ret = __tee(io_in, io_out, len, flags) diff --git a/sleepy_penguin.gemspec b/sleepy_penguin.gemspec index f646e3c..17e6d0b 100644 --- a/sleepy_penguin.gemspec +++ b/sleepy_penguin.gemspec @@ -3,7 +3,7 @@ manifest = File.exist?('.manifest') ? Gem::Specification.new do |s| s.name = %q{sleepy_penguin} - s.version = (ENV['VERSION'] || '3.4.1').dup + s.version = (ENV['VERSION'] || '3.5.0').dup s.homepage = 'https://bogomips.org/sleepy_penguin/' s.authors = ['sleepy_penguin hackers'] s.description = File.read('README').split("\n\n")[1] -- cgit v1.2.3-24-ge0c7