Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wip async abstract backend #10264

Merged
merged 16 commits into from Aug 16, 2016
Merged

Conversation

yuyuyu101
Copy link
Member

No description provided.

@yuyuyu101 yuyuyu101 force-pushed the wip-async-abstract-backend branch 7 times, most recently from 14821a4 to 26c0ff6 Compare July 13, 2016 13:40
@yuyuyu101
Copy link
Member Author

@yuyuyu101 yuyuyu101 force-pushed the wip-async-abstract-backend branch 2 times, most recently from 8d4daf0 to 1b9ef14 Compare July 15, 2016 07:18
@@ -23,6 +23,7 @@ libmsg_la_SOURCES += \
msg/async/Event.cc \
msg/async/net_handler.cc \
msg/async/Stack.cc \
msg/async/PosixStack.cc \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should squash this change with the previous two commits.

@yuyuyu101 yuyuyu101 force-pushed the wip-async-abstract-backend branch 2 times, most recently from be20e88 to ea92bdb Compare July 16, 2016 05:52
@yuyuyu101
Copy link
Member Author

class C_barrier : public EventCallback {
Mutex barrier_lock;
Cond barrier_cond;
atomic_t barrier_count;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to switch to std::atomic<>?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@tchaikov
Copy link
Contributor

i will look at your changes more closely tmr .

@yuyuyu101
Copy link
Member Author

// find worker with least references
// tempting case is returning on references == 0, but in reality
// this will happen so rarely that there's no need for special case.
for (unsigned i = 0; i < num_workers; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use std::min_element(), see https://www.sgi.com/tech/stl/min_element.html.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will modify this logic later, so let me keep this now.

@@ -25,11 +25,10 @@
#undef dout_prefix
#define dout_prefix *_dout << "stack "

void NetworkStack::add_thread(unsigned i)
void NetworkStack::add_thread(unsigned i, std::function<void ()> &thread)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, i think this will be RVO'ed.

@tchaikov
Copy link
Contributor

retest this please svp.

@yuyuyu101
Copy link
Member Author

retest this please

assert(current_best);
++current_best->references;
return current_best;
}

void NetworkStack::stop()
{
simple_spin_lock(&pool_spin);
Spinlock::Locker l(pool_spin);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you squash this change into 9922600?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Stack is a network IO framework which encapsulates all necessary basic network
interface, then it manages threads to work.

Different network backend like posix, dpdk even RDMA need to inherit Stack
class to implement necessary interfaces. So it will make ease for other
network backend to integrated into ceph. Otherwise, each backend need to
implement the whole Messenger logics like reconnect, policy handle, session
maintain...

Signed-off-by: Haomai Wang <haomai@xsky.com>
Add default posix backend support, it should be the full replacement for
the original AsyncMessenger IO logics.

Signed-off-by: Haomai Wang <haomai@xsky.com>
Signed-off-by: Haomai Wang <haomai@xsky.com>
1. replace sd to ConnectedSocket
2. Replace WorkerPool with Stack
3. Use Stack worker

Signed-off-by: Haomai Wang <haomai@xsky.com>
Signed-off-by: Haomai Wang <haomai@xsky.com>
Now only dispatch external event will wakeup event thread(previously
delete_time_event will call wakeup), we only need to use
"external_num_events" to indicate whether we have extra events.

Signed-off-by: Haomai Wang <haomai@xsky.com>
AsyncMessenger will try to loop the bind port range, so it will produce
some addr inuse errors which is not abnormal.

Signed-off-by: Haomai Wang <haomai@xsky.com>
New async msgr runtime need to spawn threads when binding, but ceph-osd will
call daemon() after binding port. So we need to respawn threads if forked.

Then thread spawn delay will increase complexity for this change and it's
really a simple strategy which help less, we disable auto spawn now.

Signed-off-by: Haomai Wang <haomai@xsky.com>
Because daemon() will termniate all existing threads, it will make something go
wrong.

So we want to add hook at CephContext, do something before/after fork.

Signed-off-by: Haomai Wang <haomai@xsky.com>
Signed-off-by: Haomai Wang <haomai@xsky.com>
If daemonlize we need to respawn event threads, it need to allow set_owner again

Signed-off-by: Haomai Wang <haomai@xsky.com>
Signed-off-by: Haomai Wang <haomai@xsky.com>
When the connection is lossy and enter fault, it will dispatch reset event.
If cleanup handler is executed as well as ms_handle_reset call mark_down,
it may exists racing for "cs". cleanup handler will reset "cs" but
_conn_prefix in mark_down will access "cs".

Signed-off-by: Haomai Wang <haomai@xsky.com>
Signed-off-by: Haomai Wang <haomai@xsky.com>
In tests we allow to reset EventCenter instance in the same CephContext,
so it may let global_centers->centers to set the same position multi times.

Signed-off-by: Haomai Wang <haomai@xsky.com>
Otherwise in slow runner, ms_dispatch may not executed when assert

Signed-off-by: Haomai Wang <haomai@xsky.com>
@tchaikov
Copy link
Contributor

lgtm once jenkins is green.

@tchaikov tchaikov self-assigned this Aug 16, 2016
@yuyuyu101
Copy link
Member Author

retest this please

@tchaikov tchaikov merged commit e354918 into ceph:master Aug 16, 2016
@yuyuyu101 yuyuyu101 deleted the wip-async-abstract-backend branch August 17, 2016 01:08
@yuyuyu101
Copy link
Member Author

thanks for reviewing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants