--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 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 unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/2a3f6115-e1f5-40cd-a821-9a326590720e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I am surprised at the performance hit this buffering causes. Should it really take 4.5 seconds to write 100,000 lines and 290 seconds to write 200,000 lines?
Node 0.12 will have better support for writev / corking and uncorking, which will allow you to coalesce writes and regain some of the efficiency lost by the individual writes ignoring fs buffering (although it doesn’t look like fs.createWriteStream() returns a stream that coalesces by default, so you’ll have to write your own). Which is, I suspect, the source of the lag you’re seeing – each write to the stream has to succeed and be acknowledged before the next one can be performed, whereas fs.write() / fs.writeSync() are writing to the fs’s buffer. The difference is going to be especially pronounced with an append-only file like a log.
F
function benchmarkWriteStream() {const stream = fs.createWriteStream('./dummyWriteStream.log', {encoding: "utf8",mode: parseInt('0644', 8)});const startTime = new Date();
var i = NUM_WRITES;(function doWrite(){if(i--) {var ret = stream.write(DUMMY_MESSAGE);if(!ret) stream.once('drain',doWrite);else doWrite();}else stream.end('');})();
stream.on('finish', function onFinish() {
const diff = (new Date() - startTime) / 1000;console.log('writeStream.write took', diff, 'seconds');
});}though it is 2 times slower than sync variant
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 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 unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CAHG3qKrMqwNPKYLM-joR9oOuWENQvd4wqXQ1zd9QwPh5p%2BmxuA%40mail.gmail.com.
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 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 unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CAHG3qKrMqwNPKYLM-joR9oOuWENQvd4wqXQ1zd9QwPh5p%2BmxuA%40mail.gmail.com.