[ANN] http.rb 0.9.0 released!

Hi everyone,

http.rb 0.9.0 has been released!

The most notable feature is support for JRuby 9000.

We also removed the caching implementation. If you were using that, let us
know: we may bring it back, but the way it was implemented was causing
issues with JRuby 9000.

···

--
Tony Arcieri

Why use Timeout.timeout instead of IO.select in PerOperation? Just curious.

Dan

···

On Thu, Jul 23, 2015 at 11:06 AM, Tony Arcieri <bascule@gmail.com> wrote:

Hi everyone,

http.rb 0.9.0 has been released!

GitHub - httprb/http: HTTP (The Gem! a.k.a. http.rb) - a fast Ruby HTTP client with a chainable API, streaming support, and timeouts

The most notable feature is support for JRuby 9000.

We also removed the caching implementation. If you were using that, let us
know: we may bring it back, but the way it was implemented was causing
issues with JRuby 9000.

--
Tony Arcieri

It's actually using IO.select on the read and write operations. See:

Yes, timeout.rb is bad. The work to convert the connect calls from
timeout.rb to IO.select was never completed but is relatively trivial. PRs
accepted!

There's also an unmerged PR in to use exceptionless nonblocking I/O:

···

On Thu, Jul 23, 2015 at 5:02 PM, Daniel Berger <djberg96@gmail.com> wrote:

Why use Timeout.timeout instead of IO.select in PerOperation? Just curious.

--
Tony Arcieri

> Why use Timeout.timeout instead of IO.select in PerOperation? Just curious.

It's actually using IO.select on the read and write operations. See:

http/lib/http/timeout/global.rb at main · httprb/http · GitHub

If you can rely on Ruby 2.0+, IO#wait_readable/IO#wait_writable under
MRI are available in the io/wait extension.

On systems with a ppoll syscall (Linux), these methods are immune to
allocating + scanning large bitmaps for high-numbered FDs. As you know,
select/IO.select requires large bitmaps as FD numbers increase, which
hurts performance and memory usage.

MRI 1.9.3 can use IO#wait to the same effect, but there wasn't a
IO#wait_writable.

ruby-core might be able to make IO.select use ppoll transparently under
Linux for bigger IO sets, too, but the APIs in io/wait will always
allocate fewer objects (no empty arrays) for single FDs, though.

Yes, timeout.rb is bad. The work to convert the connect calls from
timeout.rb to IO.select was never completed but is relatively trivial. PRs
accepted!

Timeouts for DNS lookup (via getaddrinfo) is painful :<

Perhaps try resolving as a separate step with resolv.rb (in the stdlib)
which has builtin timeouts. The version in MRI 2.3 will also use
exception-free non-blocking IO methods.

There's also an unmerged PR in to use exceptionless nonblocking I/O:

Enable exceptionless NIO when available by zanker · Pull Request #235 · httprb/http · GitHub

In 2.3, "connect_nonblock(.. exception: false)" will also be a
possibility; as well. But that only covers the connect syscall and not
DNS lookup.

···

Tony Arcieri <bascule@gmail.com> wrote:

On Thu, Jul 23, 2015 at 5:02 PM, Daniel Berger <djberg96@gmail.com> wrote: