From 44a0f7417b78a2d32bc0434670c5a924dd8d85b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisendo=CC=88rfer?= Date: Fri, 29 Jun 2012 10:44:42 +0100 Subject: [PATCH] Improve domain usage in http_simple benchmark There were two problems with the way domains were used in the benchmark: a) A global domain was created. IMO this is not how one would normally use domains, as an error caught by a global domain would be just as difficult to handle as an 'uncaughtException' one. More importantly: Setting up a global domain makes implicit domain member tracking expensive as per-request domains will now also be tracked as members of the global domain. b) The per-request domains created in the benchmark were never entered. While it didn't have an impact on the performance of the benchmark, it does seem a bit pointless to not enter the domains, so this patch causes them to be entered. --- benchmark/http_simple.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/benchmark/http_simple.js b/benchmark/http_simple.js index 1b3cee7f4fd..ff7885ebd66 100644 --- a/benchmark/http_simple.js +++ b/benchmark/http_simple.js @@ -13,15 +13,8 @@ var fixed = makeString(20 * 1024, 'C'), var useDomains = process.env.NODE_USE_DOMAINS; -// set up one global domain. if (useDomains) { var domain = require('domain'); - var gdom = domain.create(); - gdom.on('error', function(er) { - console.log('Error on global domain', er); - throw er; - }); - gdom.enter(); } var server = http.createServer(function (req, res) { @@ -29,6 +22,7 @@ var server = http.createServer(function (req, res) { var dom = domain.create(); dom.add(req); dom.add(res); + dom.enter(); } var commands = req.url.split('/');