On Wed, Oct 30, 2013 at 11:03 AM, Ashish <
aashee...@gmail.com> wrote:
> On Wednesday, October 30, 2013 10:40:03 PM UTC+5:30, Sam Roberts wrote:
> I had that mechanism to write one response and in callback to write next.
> But it becomes way too slow and we miss performance benefits of asynchronous
> writes.
Are you sure? As in, you benchmarked on RECEIVE side? Because while
you might be memcopy data into the kernel really quickly, so it looks
"fast", if the system is running out of bufers, then it could mean you
are making a big pile of unsent data in the kernel really "fast", not
that the receipient is geting data as fast as they can.
> (Also IMHO once we get ENOBUFS, TCP stream is potentially screwed up anyways
> so its
> not recommended to hold back and continue after wait.
Not true on Linux, doubt if its true on Windows, should be temporary.
I've seen this on dgram connections more often, not on tcp. We dealt
with by busy looping on write... waiting till ENOBUFS stopped, then
continuing. That worked well because of specifics of what we doing,
load generation, but might not work for you.
Its not clear whether you tried Saul's suggestion of pausing briefly
and trying again. Or tried to up your net stacks buffer capacity.
> The best bet is to
> avoid getting into
> the situation in the first place by knowing how much data is outstanding on
> the link and
> managing it actively before the OS has to step in by running out of
> resources)
The buf pool referred to is global to net stack, I think, not specific
to a single link. It could be caused by sheer number of connections,
not data on specfic link.
Anyhow, the logic is close to identical either way:
- you want to check before, and then pause before checking again (I
assume), and then write eventually when bufs avail
- but this is almost same as just writing, and then when ENOBUFS
occurs, pause, then write same data again, until success
Since the first would require doing something outside of uv that is
windows specific and be prone to race conditions anyhow, and latter is
possible, why not try latter?
Sam