In current version of node, socket write is always 'async', which creates 
some write contexts, put it into queue, and get it out when write data 
finished, and call the callback. But for socket write, if data size is less 
than system socket buffer(which can be modified by 
/proc/sys/net/core/wmem_max), write() is indeed nonblock, and all async 
work can be saved, than the performance of write+callback will be improve 
significantly.

I've forked and made a patch:
https://github.com/freedaxin/node/commit/dba71315bf229b7815c08188ef88097bfbf43135

I added a benchmark(benchmark/net_rw.js), and the time consumption 
decreased by about 20%.

It doesn't change the user api, but StreamWrap::WriteBuffer() returns a 
Number if all data has been written.

I have run `make jslint test`, found two problems, and changed the test 
code. 
1. In /test/simple/test-debugger-repl.js, one of the child processes always 
does not exit, I didn't found the reason, and changed the finish cleanup 
behaviours, and passed the test. But I still don't know what's the problem.

2. In /test/simple/test-tcp-wrap-listen.js, because I changed the return 
value of StreamWrap::WriteBuffer(), so the test should be modified.

It's still not a perfect patch, add such a sync feature to async node is 
somehow incompatible with the code logic. And I've noticed that the stream 
related code is not stable yet, so if this patch is acceptable, more 
imporvements can be made later.

btw: windows version has not been changed yet.

issue link:
https://github.com/joyent/node/issues/4699

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to