All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Garzik <jeff@garzik.org>
To: Project Hail <hail-devel@vger.kernel.org>
Subject: multi-threaded chunkd, design and code
Date: Sat, 07 Nov 2009 01:05:39 -0500	[thread overview]
Message-ID: <4AF50E33.4030709@garzik.org> (raw)


A multi-threaded version of chunkd has been checked into the 
repository[1], on a branch aptly named "thread."

The design:
- uses GLib's thread pools[2]
- for each poll(2)
	for each active fd
		push fd to worker thread via thread pool
- worker thread
	handle one unit of activity (tcp_cli_event func call)
	wake up main thread, to requeue fd for further polling
	return to thread pool, to seek more work

Concurrent performance (multiple TCP streams) is definitely improved, 
but single stream suffers a bit, probably due to excessive wakeups.

Both single-thread and MT performance can definitely be improved with 
epoll, but I wanted to get the working-across-all-platforms poll(2) code 
solid first.

One possible alternative model is to leave chunkd single-threaded, yet 
use aio_read() and aio_write() for file I/O.  That would eliminate the 
current bottleneck common to single-threaded designs:  the serialization 
of file input (READs) requested by multiple parallel TCP clients.

If you have multiple TCP clients issuing multiple reads at the same time 
-- a common case -- multiple threads are the only way to submit I/Os to 
the kernel in parallel, thereby permitting the kernel elevator and 
hardware (SCSI/ATA) elevator opportunity to optimize for seek performance.

In most applications, reads are synchronous, which in the current 
single-threaded chunkd becomes a visible performance wart.

Regardless...  I do not currently plan on pushing the "thread" branch 
onto git upstream until I explore which epoll-based design is best (ST 
or MT), and perhaps tune this poll(2) design a bit more.

Feedback and contributions always welcome, of course...

	Jeff


[1] git://git.kernel.org/pub/scm/daemon/distsrv/chunkd.git
[2] http://library.gnome.org/devel/glib/stable/glib-Thread-Pools.html


                 reply	other threads:[~2009-11-07  6:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4AF50E33.4030709@garzik.org \
    --to=jeff@garzik.org \
    --cc=hail-devel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.