All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Durgin <jdurgin@redhat.com>
To: Casey Bodley <cbodley@redhat.com>
Cc: Adam Emerson <aemerson@redhat.com>,
	Gregory Farnum <gfarnum@redhat.com>,
	kefu chai <tchaikov@gmail.com>,
	ceph-devel <ceph-devel@vger.kernel.org>
Subject: Re: seastar and 'tame reactor'
Date: Tue, 30 Jan 2018 14:32:47 -0800	[thread overview]
Message-ID: <5b32056c-c6f7-a1c4-d07a-ae04557b59cf@redhat.com> (raw)
In-Reply-To: <d0f50268-72bb-1196-7ce9-0b9e21808ffb@redhat.com>

[adding ceph-devel]

On 01/30/2018 01:56 PM, Casey Bodley wrote:
> Hey Josh,
> 
> I heard you mention in the call yesterday that you're looking into this 
> part of seastar integration. I was just reading through the relevant 
> code over the weekend, and wanted to compare notes:
> 
> 
> in seastar, all cross-core communication goes through lockfree spsc 
> queues, which are encapsulated by 'class smp_message_queue' in 
> core/reactor.hh. all of these queues (smp::_qs) are allocated on startup 
> in smp::configure(). early in reactor::run() (which is effectively each 
> seastar thread's entrypoint), it registers a smp_poller to poll all of 
> the queues directed at that cpu
> 
> what we need is a way to inject messages into each seastar reactor from 
> arbitrary/external threads. our requirements are very similar to 
> smp_message_queue's, with a few exceptions:
> 
> -each seastar reactor should be the single consumer of a multi-producer 
> queue, and poll on that as well

Yes, this is what I was thinking too, maybe a boost::lockfree::queue

> -the submit() function would return void instead of a future (which 
> removes the need for a lot of other stuff, like the _completions queue, 
> async_work_item::_promise, etc)
> 
> figuring out how to factor this stuff out of smp_message_queue cleanly 
> is the hard part i guess

I was thinking it could start off as a separate implementation, but
hadn't looked too closely at sharing pieces of it.

> in terms of startup, it could be allocated as a static array similar to 
> smp::_qs (except it would be dimensioned by [smp::count] instead of 
> [smp::count][smp::count]). then a new function could be added alongside 
> smp::submit_to() that submits to the given cpu's external queue (and 
> also returns void). this stuff should probably be disabled by default, 
> and only turned on if enabled in configuration

++

> for a super simple unit test, you could spawn an external thread that 
> does something like this:
> 
> std::mutex mutex;
> std::condition_variable cond;
> std::atomic<int> completions = 0;
> // submit a message to each reactor
> for (int i = 0; i < smp::count; i++) {
>    smp::external_submit_to(i, [&] { ++completions; cond.notify_one(); });
> }
> // wait for all completions
> std::unique_lock lock(mutex);
> cond.wait(lock, [&] { return completions == smp::count; });

Yeah, this looks like a nice example.

> Sorry that I've been slow to help with this - keep me posted?

No worries, I've been slow about this too - I've asked Kefu to look at
it this morning, so I'm sure he'll have some more thoughts soon.

Josh

       reply	other threads:[~2018-01-30 22:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <d0f50268-72bb-1196-7ce9-0b9e21808ffb@redhat.com>
2018-01-30 22:32 ` Josh Durgin [this message]
2018-02-07 16:01   ` seastar and 'tame reactor' kefu chai
2018-02-07 17:11     ` Casey Bodley
2018-02-07 19:22       ` Gregory Farnum
2018-02-12 15:45         ` kefu chai
2018-02-12 15:55           ` Matt Benjamin
2018-02-12 15:57             ` Gregory Farnum
2018-02-13 13:35             ` kefu chai
2018-02-13 15:58               ` Casey Bodley
2018-02-12 19:40       ` Allen Samuels
2018-02-13 15:46         ` Casey Bodley
2018-02-13 16:17           ` liuchang0812
2018-02-14  3:16             ` Allen Samuels
2018-02-15 20:04               ` Josh Durgin
2018-02-16 16:23                 ` Allen Samuels

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=5b32056c-c6f7-a1c4-d07a-ae04557b59cf@redhat.com \
    --to=jdurgin@redhat.com \
    --cc=aemerson@redhat.com \
    --cc=cbodley@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=gfarnum@redhat.com \
    --cc=tchaikov@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 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.