From ac3bc2ed41c18cfd45772ec895afe98a929ab78c Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 15 Apr 2010 01:29:39 -0700 Subject: [PATCH 1/5] Simplify GC idle notification In particular, don't leave the timeout running when the heap is fully compacted. --- benchmark/http_simple.js | 2 ++ src/node.cc | 52 ++++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/benchmark/http_simple.js b/benchmark/http_simple.js index e1eb6b57799..e709f2d7242 100644 --- a/benchmark/http_simple.js +++ b/benchmark/http_simple.js @@ -4,6 +4,8 @@ var puts = require("sys").puts; var old = (process.argv[2] == 'old'); +puts('pid ' + process.pid); + http = require(old ? "http_old" : 'http'); if (old) puts('old version'); diff --git a/src/node.cc b/src/node.cc index 76027da4abf..cabd92a06a8 100644 --- a/src/node.cc +++ b/src/node.cc @@ -102,8 +102,21 @@ static ev_tstamp last_active; static ev_timer gc_timer; static ev_check gc_check; static ev_idle gc_idle; -static bool needs_gc; -#define GC_INTERVAL 2.0 +#define GC_INTERVAL 1.0 + +static void gc_timer_start () { + if (!ev_is_active(&gc_timer)) { + ev_timer_start(EV_DEFAULT_UC_ &gc_timer); + ev_unref(EV_DEFAULT_UC); + } +} + +static void gc_timer_stop () { + if (ev_is_active(&gc_timer)) { + ev_ref(EV_DEFAULT_UC); + ev_timer_stop(EV_DEFAULT_UC_ &gc_timer); + } +} static void CheckIdleness(EV_P_ ev_timer *watcher, int revents) { @@ -115,15 +128,10 @@ static void CheckIdleness(EV_P_ ev_timer *watcher, int revents) { ev_tstamp idle_time = ev_now(EV_DEFAULT_UC) - last_active; if (idle_time > GC_INTERVAL) { - if (needs_gc) { - needs_gc = false; - if (!V8::IdleNotification()) { - ev_idle_start(EV_DEFAULT_UC_ &gc_idle); - } + if (!V8::IdleNotification()) { + ev_idle_start(EV_DEFAULT_UC_ &gc_idle); } - // reset the timer - gc_timer.repeat = GC_INTERVAL; - ev_timer_again(EV_DEFAULT_UC_ watcher); + gc_timer_stop(); } } @@ -136,8 +144,8 @@ static void NotifyIdleness(EV_P_ ev_idle *watcher, int revents) { if (V8::IdleNotification()) { ev_idle_stop(EV_A_ watcher); + gc_timer_stop(); } - needs_gc = false; } @@ -149,23 +157,18 @@ static void Activity(EV_P_ ev_check *watcher, int revents) { // Don't count GC watchers as activity. - pending -= ev_is_pending(&gc_timer); - pending -= ev_is_pending(&gc_idle); - pending -= ev_is_pending(&next_tick_watcher); - //if (ev_is_pending(&gc_check)) pending--; // This probably never happens? + if (ev_is_pending(&gc_timer)) pending--; + if (ev_is_pending(&gc_idle)) pending--; + if (ev_is_pending(&gc_check)) pending--; + + assert(pending >= 0); //fprintf(stderr, "activity, pending: %d\n", pending); if (pending) { last_active = ev_now(EV_DEFAULT_UC); ev_idle_stop(EV_DEFAULT_UC_ &gc_idle); - - if (!needs_gc) { - gc_timer.repeat = GC_INTERVAL; - ev_timer_again(EV_DEFAULT_UC_ &gc_timer); - } - - needs_gc = true; + gc_timer_start(); } } @@ -1594,10 +1597,7 @@ int main(int argc, char *argv[]) { ev_idle_init(&node::tick_spinner, node::Spin); - ev_init(&node::gc_timer, node::CheckIdleness); - node::gc_timer.repeat = GC_INTERVAL; - ev_timer_again(EV_DEFAULT_UC_ &node::gc_timer); - ev_unref(EV_DEFAULT_UC); + ev_timer_init(&node::gc_timer, node::CheckIdleness, 2*GC_INTERVAL, 2*GC_INTERVAL); ev_check_init(&node::gc_check, node::Activity); ev_check_start(EV_DEFAULT_UC_ &node::gc_check); From d2e1b0855f3630ef2be45b477e93d8bc865cc7b7 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 15 Apr 2010 01:37:27 -0700 Subject: [PATCH 2/5] Move two broken tests to disabled folder --- test/{pummel => disabled}/test-http-big-proxy-responses.js | 0 test/{simple => disabled}/test-http-head-request.js | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test/{pummel => disabled}/test-http-big-proxy-responses.js (100%) rename test/{simple => disabled}/test-http-head-request.js (100%) diff --git a/test/pummel/test-http-big-proxy-responses.js b/test/disabled/test-http-big-proxy-responses.js similarity index 100% rename from test/pummel/test-http-big-proxy-responses.js rename to test/disabled/test-http-big-proxy-responses.js diff --git a/test/simple/test-http-head-request.js b/test/disabled/test-http-head-request.js similarity index 100% rename from test/simple/test-http-head-request.js rename to test/disabled/test-http-head-request.js From 5281f2901249de173704234238a4cb872b4fb884 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 15 Apr 2010 02:01:49 -0700 Subject: [PATCH 3/5] Use new method of getting chars written for UTF8 --- lib/net.js | 5 +---- src/node_buffer.cc | 9 ++++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/net.js b/lib/net.js index 60801507241..e683101f5b1 100644 --- a/lib/net.js +++ b/lib/net.js @@ -432,10 +432,7 @@ Stream.prototype._writeOut = function (data, encoding) { if (encoding == 'utf8' || encoding == 'utf-8') { // default to utf8 bytesWritten = pool.write(data, 'utf8', pool.used); - // XXX Hacky way to find out the number of characters written. - // Waiting for a more optimal way: http://codereview.chromium.org/1539013 - var _s = pool.toString('utf8', pool.used, pool.used + bytesWritten); - charsWritten = _s.length; + charsWritten = Buffer._charsWritten; } else { bytesWritten = pool.write(data, encoding, pool.used); charsWritten = bytesWritten; diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 45586c38c31..62c667b40c7 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -38,6 +38,7 @@ using namespace v8; static Persistent length_symbol; +static Persistent chars_written_sym; Persistent Buffer::constructor_template; @@ -308,11 +309,16 @@ Handle Buffer::Utf8Write(const Arguments &args) { const char *p = buffer->data() + offset; + int char_written; + int written = s->WriteUtf8((char*)p, buffer->length_ - offset, - NULL, + &char_written, String::HINT_MANY_WRITES_EXPECTED); + constructor_template->GetFunction()->Set(chars_written_sym, + Integer::New(char_written)); + if (written > 0 && p[written-1] == '\0') written--; return scope.Close(Integer::New(written)); @@ -463,6 +469,7 @@ void Buffer::Initialize(Handle target) { HandleScope scope; length_symbol = Persistent::New(String::NewSymbol("length")); + chars_written_sym = Persistent::New(String::NewSymbol("_charsWritten")); Local t = FunctionTemplate::New(Buffer::New); constructor_template = Persistent::New(t); From 2ad587cc354e2694bc47be01eca9b15b6db46377 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 15 Apr 2010 02:09:36 -0700 Subject: [PATCH 4/5] Default to UTF8 on stream write --- lib/net.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/net.js b/lib/net.js index e683101f5b1..0554f3a69f8 100644 --- a/lib/net.js +++ b/lib/net.js @@ -429,7 +429,7 @@ Stream.prototype._writeOut = function (data, encoding) { allocNewPool(); } - if (encoding == 'utf8' || encoding == 'utf-8') { + if (!encoding || encoding == 'utf8' || encoding == 'utf-8') { // default to utf8 bytesWritten = pool.write(data, 'utf8', pool.used); charsWritten = Buffer._charsWritten; From 311d7dee19034ff1c6bc9098c36973b8d687eaba Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 15 Apr 2010 01:54:20 -0700 Subject: [PATCH 5/5] bump version --- ChangeLog | 24 +++++++++++++++++++++++- doc/api_header.html | 2 +- doc/index.html | 4 ++-- wscript | 2 +- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9eef860976d..d36033a8cbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,26 @@ -2010.04.09, Version 0.1.90 +2010.04.15, Version 0.1.91 + + * Add incoming.httpVersion + + * Object.prototype problem with C-Ares binding + + * REPL can be run from multiple different streams. (Matt Ranney) + + * After V8 heap is compact, don't use a timer every 2 seconds. + + * Improve nextTick implementation. + + * Add primative support for Upgrading HTTP connections. + (See commit log for docs 760bba5) + + * Add timeout and maxBuffer options to child_process.exec + + * Fix bugs. + + * Upgrade V8 to 2.2.3.1 + + +2010.04.09, Version 0.1.90, 07e64d45ffa1856e824c4fa6afd0442ba61d6fd8 * Merge writing of networking system (net2) - New Buffer object for binary data. diff --git a/doc/api_header.html b/doc/api_header.html index 498bc9ebd3a..7340bdbbde8 100644 --- a/doc/api_header.html +++ b/doc/api_header.html @@ -130,7 +130,7 @@
-
Node v0.1.90
+
Node v0.1.91
diff --git a/doc/index.html b/doc/index.html index e9c96c94935..338798cbf83 100644 --- a/doc/index.html +++ b/doc/index.html @@ -95,8 +95,8 @@ server.listen(7000, "localhost"); git repo

- 2010.04.09 - node-v0.1.90.tar.gz + 2010.04.15 + node-v0.1.91.tar.gz

Build

diff --git a/wscript b/wscript index bafc139f4e4..e04b68515c6 100644 --- a/wscript +++ b/wscript @@ -7,7 +7,7 @@ from os.path import join, dirname, abspath from logging import fatal cwd = os.getcwd() -VERSION="0.1.90" +VERSION="0.1.91" APPNAME="node.js" import js2c