Skip to content

Instantly share code, notes, and snippets.

@tjfontaine tjfontaine/a.txt
Last active Aug 29, 2015

Embed
What would you like to do?
Values are time in nanoseconds
pre-monotonic change
ready
value ------------- Distribution ------------- count
8388608 | 0
16777216 |@@@ 188
33554432 |@@@@@@@@@@ 624
67108864 |@@@@@@ 354
134217728 |@@@@@@ 389
268435456 |@@@@@@@@ 485
536870912 |@@@@@ 336
1073741824 |@@ 104
2147483648 | 2
4294967296 | 0
Worst start up time -- 2 seconds, best 16ms
init
value ------------- Distribution ------------- count
1048576 | 0
2097152 | 6
4194304 |@@@@@@@@ 513
8388608 |@@@@@@@@@@ 597
16777216 |@@@@@ 300
33554432 |@@@@ 227
67108864 |@@@@ 241
134217728 |@@@ 189
268435456 |@@@ 200
536870912 |@@@ 170
1073741824 |@ 61
2147483648 | 0
worst time 1 second, best time 4ms
after monotonic change
ready
value ------------- Distribution ------------- count
8388608 | 0
16777216 |@@@@@@@@ 513
33554432 |@@@@@@ 386
67108864 |@@@@@ 331
134217728 |@@@@@@@ 433
268435456 |@@@@@@ 379
536870912 |@@@@@ 332
1073741824 |@ 72
2147483648 | 12
4294967296 | 0
worst ready time 2 seconds, best ready time 16ms
init
value ------------- Distribution ------------- count
65536 | 0
131072 |@ 52
262144 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1866
524288 |@ 59
1048576 | 20
2097152 | 15
4194304 |@ 65
8388608 |@ 60
16777216 |@ 33
33554432 |@ 40
67108864 |@ 47
134217728 |@ 47
268435456 |@ 90
536870912 |@@ 105
1073741824 | 13
2147483648 | 3
4294967296 | 0
worst init 2 seconds, best init 131 microseconds
diff --git a/node.gyp b/node.gyp
index f6586c4..ad90b83 100644
--- a/node.gyp
+++ b/node.gyp
@@ -428,7 +428,8 @@
'action_name': 'node_dtrace_provider_o',
'inputs': [
'src/node_provider.d',
- '<(OBJ_DIR)/node/src/node_dtrace.o'
+ '<(OBJ_DIR)/node/src/node_dtrace.o',
+ '<(OBJ_DIR)/node/src/node.o'
],
'outputs': [
'<(OBJ_DIR)/node/src/node_dtrace_provider.o'
diff --git a/src/node.cc b/src/node.cc
index ac906f0..707627e 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -82,6 +82,8 @@ typedef int mode_t;
#include "node_script.h"
#include "v8_typed_array.h"
+#include "node_provider.h"
+
using namespace v8;
# ifdef __APPLE__
@@ -1714,13 +1716,16 @@ static Handle<Value> Uptime(const Arguments& args) {
HandleScope scope;
double uptime;
- uv_err_t err = uv_uptime(&uptime);
+ uv_update_time(uv_default_loop());
+ uptime = uv_now(uv_default_loop());
- if (err.code != UV_OK) {
- return Undefined();
- }
+ return scope.Close(Number::New((uptime - prog_start_time) / 1000));
+}
- return scope.Close(Number::New(uptime - prog_start_time));
+static Handle<Value> Ready(const Arguments& args) {
+ NODE_PROC_READY();
+ HandleScope scope;
+ return scope.Close(Undefined());
}
@@ -2420,6 +2425,7 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
NODE_SET_METHOD(process, "uptime", Uptime);
NODE_SET_METHOD(process, "memoryUsage", MemoryUsage);
+ NODE_SET_METHOD(process, "ready", Ready);
NODE_SET_METHOD(process, "binding", Binding);
@@ -2893,7 +2899,7 @@ static Handle<Value> DebugEnd(const Arguments& args) {
char** Init(int argc, char *argv[]) {
// Initialize prog_start_time to get relative uptime.
- uv_uptime(&prog_start_time);
+ prog_start_time = uv_now(uv_default_loop());
// Make inherited handles noninheritable.
uv_disable_stdio_inheritance();
@@ -3045,6 +3051,8 @@ static char **copy_argv(int argc, char **argv) {
}
int Start(int argc, char *argv[]) {
+ NODE_PROC_START();
+
// Hack aroung with the argv pointer. Used for process.title = "blah".
argv = uv_setup_args(argc, argv);
@@ -3054,7 +3062,9 @@ int Start(int argc, char *argv[]) {
// This needs to run *before* V8::Initialize()
// Use copy here as to not modify the original argv:
+ NODE_INIT_START();
Init(argc, argv_copy);
+ NODE_INIT_STOP();
V8::Initialize();
{
diff --git a/src/node.js b/src/node.js
index b54ff51..807bfca 100644
--- a/src/node.js
+++ b/src/node.js
@@ -57,6 +57,8 @@
startup.resolveArgv0();
+ process.ready();
+
// There are various modes that Node can run in. The most common two
// are running from a script and running the REPL - but there are a few
// others like the debugger or running --eval arguments. Here we decide
diff --git a/src/node_provider.d b/src/node_provider.d
index 6f95b03..47fcd5b 100644
--- a/src/node_provider.d
+++ b/src/node_provider.d
@@ -77,6 +77,10 @@ provider node {
int p, int fd) : (node_connection_t *c, string a, int p, int fd);
probe gc__start(int t, int f);
probe gc__done(int t, int f);
+ probe init__start();
+ probe init__stop();
+ probe proc__start();
+ probe proc__ready();
};
#pragma D attributes Evolving/Evolving/ISA provider node provider
#!/usr/sbin/dtrace -s
node*:::proc-start
{
self->proc_start = timestamp;
}
node*:::proc-ready
/self->proc_start/
{
@["ready"] = quantize(timestamp - self->proc_start);
self->proc_start = 0;
}
node*:::init-start
{
self->init_start = timestamp;
}
node*:::init-stop
/self->init_start/
{
@["init"] = quantize(timestamp - self->init_start);
self->init_start = 0;
}
END
{
printa(@);
}
var execFile = require('child_process').execFile;
var cluster = require('cluster');
var TOTAL_RUNS = 50;
var CONCURRENCY = 50;
function doit(id, count) {
if (count > TOTAL_RUNS)
process.exit(0);
//console.log('launching', id, count);
var child = execFile(process.execPath, ['-e', '']);
child.on('close', function() {
doit(id, ++count);
});
}
if (cluster.isMaster) {
for (var i = 0; i < CONCURRENCY; i++)
cluster.fork();
} else {
doit(1, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.