Re: [Nfs-ganesha-devel] async dispatch not good

2017-06-20 Thread William Allen Simpson

On 6/19/17 10:47 PM, Matt Benjamin wrote:

From: "William Allen Simpson" 
While I'm thinking about it, why does Ganesha call svc_reg()?  AFAICT,
that's just filling in a tree that is never used anymore.

Can I remove that code in Ganesha?  It's a pain to maintain in ntirpc.


If it's no longer effective, then eventually, sure.  Is it a substantial help 
to your work?


It has some sort of memory access problem, one of these return false
sometimes (but not always) with no error message to tell me why

/* VARIABLES PROTECTED BY svc_lock: s, prev, svc_head */
if (xprt->xp_netid) {
netid = mem_strdup(xprt->xp_netid);
flag = 1;
} else if (nconf) {
netid = mem_strdup(nconf->nc_netid);
flag = 1;
} else {
tnconf = __rpcgettp(xprt->xp_fd);
if (tnconf) {
netid = mem_strdup(tnconf->nc_netid);
flag = 1;
freenetconfigent(tnconf);
}
} /* must have been created with svc_raw_create */
if ((netid == NULL) && (flag == 1))
return (false);

That is some ugly code.  I didn't touch anything anywhere near it, so
the failure is mystifying.  Talked to DanG about it a week ago (the
12th), he said to talk to you

Meanwhile, Ganesha actually calls this with nfs_rpc_dispatch_dummy(),
so this is never ever used for dispatch.

Register_program() also has a comment:

02526d732 (Jim Lieb  2013-10-10 20:50:47 -0700  878)
/*  fix svc_register! */

So maybe a long-time problem?

Do we still need port mapping???

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Nfs-ganesha-devel mailing list
Nfs-ganesha-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel


Re: [Nfs-ganesha-devel] async dispatch not good

2017-06-19 Thread Matt Benjamin
Hi,

- Original Message -
> From: "William Allen Simpson" <william.allen.simp...@gmail.com>
> To: "Matt Benjamin" <mbenja...@redhat.com>
> Cc: "NFS Ganesha Developers" <nfs-ganesha-devel@lists.sourceforge.net>
> Sent: Monday, June 19, 2017 10:03:53 PM
> Subject: Re: [Nfs-ganesha-devel] async dispatch not good
> 
> On 6/19/17 3:41 PM, Matt Benjamin wrote:
> > it's not about memory, this is the problem we're trying to avoid
> > 
> > but, referring for context to our verbal discussion earlier today, your
> > suggestion to hybridize the existing output side (which depends on
> > blocking sockets) and an async input side using recv() seems work at least
> > exploring;  I assume you are proposing to use recv() with MSG_DONTWAIT?
> > Yes.  Linux does support MSG_DONTWAIT, and it should be possible to try
> the recv() writev() hybrid approach.  At least there's one Oracle
> article that says it works
> 
> The underlying problem is EPOLL reaallly isn't a good design.  What we
> need for speed is callbacks that tell us that the read/write is done,
> not signals that there might be more data pending -- which cause us to
> do more system calls to find out.  System calls are the problem.

They have latency, sure.

> 
> kqueue is a much better design.  We should try to get kqueue support in
> the Linux kernel.  That would aid portability, too.

You're welcome to try, seems political.

> 
> But what I'm doing right now is backing out my previous attempt.  Even
> after dumping the mass code, awful lot of hooks to undo

Sorry.

> 
> My thought now is it's better to get the big changes in, then work on
> TCP I-O re-write separately (as I was doing for UDP and RDMA).  Quick
> and dirty shims, but only temporarily.

One of the key goals I have is read-frags-ahead/non-blocking decode.  Has been 
at the top of the queue since our initial meetings.  Seems like your recv() 
technique should work.  

> 
> While I'm thinking about it, why does Ganesha call svc_reg()?  AFAICT,
> that's just filling in a tree that is never used anymore.
> 
> Can I remove that code in Ganesha?  It's a pain to maintain in ntirpc.

If it's no longer effective, then eventually, sure.  Is it a substantial help 
to your work?

Matt

> 

-- 
Matt Benjamin
Red Hat, Inc.
315 West Huron Street, Suite 140A
Ann Arbor, Michigan 48103

http://www.redhat.com/en/technologies/storage

tel.  734-821-5101
fax.  734-769-8938
cel.  734-216-5309

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Nfs-ganesha-devel mailing list
Nfs-ganesha-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel


Re: [Nfs-ganesha-devel] async dispatch not good

2017-06-19 Thread William Allen Simpson

On 6/19/17 3:41 PM, Matt Benjamin wrote:

it's not about memory, this is the problem we're trying to avoid

but, referring for context to our verbal discussion earlier today, your 
suggestion to hybridize the existing output side (which depends on blocking 
sockets) and an async input side using recv() seems work at least exploring;  I 
assume you are proposing to use recv() with MSG_DONTWAIT?
Yes.  Linux does support MSG_DONTWAIT, and it should be possible to try

the recv() writev() hybrid approach.  At least there's one Oracle
article that says it works

The underlying problem is EPOLL reaallly isn't a good design.  What we
need for speed is callbacks that tell us that the read/write is done,
not signals that there might be more data pending -- which cause us to
do more system calls to find out.  System calls are the problem.

kqueue is a much better design.  We should try to get kqueue support in
the Linux kernel.  That would aid portability, too.

But what I'm doing right now is backing out my previous attempt.  Even
after dumping the mass code, awful lot of hooks to undo

My thought now is it's better to get the big changes in, then work on
TCP I-O re-write separately (as I was doing for UDP and RDMA).  Quick
and dirty shims, but only temporarily.

While I'm thinking about it, why does Ganesha call svc_reg()?  AFAICT,
that's just filling in a tree that is never used anymore.

Can I remove that code in Ganesha?  It's a pain to maintain in ntirpc.

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Nfs-ganesha-devel mailing list
Nfs-ganesha-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel


Re: [Nfs-ganesha-devel] async dispatch not good

2017-06-19 Thread Matt Benjamin
Hi Bill,

inline

- Original Message -
> From: "William Allen Simpson" 
> To: "NFS Ganesha Developers" 
> Sent: Monday, June 19, 2017 3:04:52 AM
> Subject: [Nfs-ganesha-devel] async dispatch not good
> 
> As folks may have noticed, I've been re-working my old 2015 dispatch
> patches that eliminate the network input-side queues in Ganesha.
> 
> Matt had wanted fully async non-blocking I-O.  I've been poking at it
> for a week, and now am sure that's the wrong way to go.

I don't think so, but, below

> 
> It might still be good for FSALs.  Remains to be seen.  DanG and
> Soumya are looking at that now.
> 
> The devil in userland network I-O is system calls.  Each epoll_wait
> is a system call.  Each read or write is a system call.  Each thread
> switch is a system call.
> 
> My code in Ganesha v2.5 (NTIRPC v1.5) gets the network output down to
> one system call per request on a very hot thread.  Cannot do better,
> as trying harder would just push the data into kernel buffers,
> possibly slowing our own output (for various reasons).
> 
> Trying to re-work that for async non-blocking calls instead means
> many more system calls.  Instead of one clean writev with the TCP
> fragment header and all ready buffers in one single call, we'd at
> minimum have a call, an epoll_wait, spawn another work thread, then
> another call and/or release the buffer, rinse and repeat.

the expensive part of this (spawn) is necessary only due to aspects of the old 
design, but, considering effort, ok, below

> 
> For a long buffer chain (the times we want more performance), we'd
> have much less performance -- roughly 2 + (3 * number of buffers)
> additional system calls.  For common short response chains, still
> have the extra overhead of the epoll system call, doubling calls.
> 
> Also, using writev minimizes buffer copies.  Eliminating data
> copying will usually give far better performance.
> 
> The only thing async output is saving is waiting threads.  But I've
> already got the output threads down to the minimum (per interface).
> No gain here!
> 
> On the input side, the truly optimum reduction in system calls would
> be one read to get the TCP fragment header and up to 1500 bytes of
> data, followed (only when needed) by another read to get the entire
> rest of long fragments in one fell swoop.

well, maybe, not considering blocking?  I think we really do want avoid 
blocking in the paths that now can/do, but, below

> 
> With async input I've tried level triggered, and am getting spurious
> epoll read data signals.  Googling shows that's been a problem since
> at least 2014, but possible to program around.

ok

> 
> Still, this could be better, had it not been terrible for output-side.
> 
> Changing to edge triggered means that every good read would be
> followed by another read to make sure that we've gotten all the data.
> That is, common small reads turn into two (2) reads.  Doubling our
> system calls in the common case is not the way to go
> 
> In conclusion, with epoll we know when input data is available, so
> input threads aren't sitting around waiting anyway, and trying to
> minimize threads results in more system calls and poorer performance.
> 
> NTIRPC already defaults to 200 worker threads.  If we need more, we
> should allocate more.  Memory should not be an issue.

it's not about memory, this is the problem we're trying to avoid

but, referring for context to our verbal discussion earlier today, your 
suggestion to hybridize the existing output side (which depends on blocking 
sockets) and an async input side using recv() seems work at least exploring;  I 
assume you are proposing to use recv() with MSG_DONTWAIT?

Matt

> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Nfs-ganesha-devel mailing list
> Nfs-ganesha-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel
> 

-- 
Matt Benjamin
Red Hat, Inc.
315 West Huron Street, Suite 140A
Ann Arbor, Michigan 48103

http://www.redhat.com/en/technologies/storage

tel.  734-821-5101
fax.  734-769-8938
cel.  734-216-5309

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Nfs-ganesha-devel mailing list
Nfs-ganesha-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel