public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@bitpay.com>
To: Gavin Andresen <gavinandresen@gmail.com>
Cc: "bitcoin-development@lists.sourceforge.net"
	<bitcoin-development@lists.sourceforge.net>
Subject: Re: [Bitcoin-development] bitcoind stops responding
Date: Fri, 4 Oct 2013 11:05:29 -0400	[thread overview]
Message-ID: <CAJHLa0NP4f9i-fUQfCh_RQCn3zpih9y0mT8kSXeoOk4hT0Twbg@mail.gmail.com> (raw)
In-Reply-To: <CABsx9T2OvOs9ijj8kk4ZdBT5u-2Bb3rYG0AZtk3FFDWi+H_oHw@mail.gmail.com>

On Fri, Oct 4, 2013 at 2:22 AM, Gavin Andresen <gavinandresen@gmail.com> wrote:
> RE: running into the maximum-of-4-keepalive-requests : simple workaround is
> to run with -rpcthreads=11 (or however many keepalive connections you need
> to support).  I agree that the rpc code should be smarter; making the last
> rpc thread ignore keepalive and always disconnecting should be a fairly
> simple patch, and "patches welcome."

It's all still working around a problem unchanged since Satoshi wrote
it:  the HTTP server code paths use blocking I/O.

Amusingly, we do this through an async I/O library, which helps
facilitate SSL, but all our connections and operations are blocking.

That's why RPC was multi-threaded in part:  to work around the ugly
blocking nature of the code.  At least with multiple threads, one
thread will not stall another even if the network stalls (or a
software bug triggers a stall etc.)

Hopefully I can dive into the code and make is truly async I/O.  It
takes some work, and I'm happy if someone else steals the task, but
that's what really needs to be done.

I tried the multi-threaded approach, writing an entire boost::asio
skeleton JSON-RPC HTTP server: https://github.com/jgarzik/rpcsrv
This is working, tested code that uses boost::asio properly.  It's
also quite a bit of LOC, and a bit messy to boot (four LOC per boost
async action and incomprehensible compiler errors in return for proper
async+MT).

A single thread with async I/O is likely sufficient for even heavy
uses of RPC -- since today it all goes through a big lock anyway.

-- 
Jeff Garzik
Senior Software Engineer and open source evangelist
BitPay, Inc.      https://bitpay.com/



  reply	other threads:[~2013-10-04 15:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-30 20:44 [Bitcoin-development] bitcoind stops responding slush
2013-09-30 21:01 ` Warren Togami Jr.
2013-09-30 22:00   ` Fatima Castiglione Maldonado 发
2013-09-30 22:08     ` Gregory Maxwell
2013-10-01  0:05       ` Fatima Castiglione Maldonado 发
2013-10-01  1:26   ` Jeff Garzik
2013-10-01  0:20 ` Chris Double
2013-10-01  1:17 ` Jeff Garzik
2013-10-01  8:58   ` slush
2013-10-04  6:22     ` Gavin Andresen
2013-10-04 15:05       ` Jeff Garzik [this message]
2013-10-01  4:03 ` Olivier Langlois
2013-10-01  7:10   ` Olivier Langlois
2013-10-01 14:17     ` Jeff Garzik
2013-10-02  3:20       ` Olivier Langlois
2013-10-04  3:52         ` Olivier Langlois

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJHLa0NP4f9i-fUQfCh_RQCn3zpih9y0mT8kSXeoOk4hT0Twbg@mail.gmail.com \
    --to=jgarzik@bitpay.com \
    --cc=bitcoin-development@lists.sourceforge.net \
    --cc=gavinandresen@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox