Browse Source

src: remove the tracing module entirely

PR-URL: https://github.com/iojs/io.js/pull/124
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
archived-io.js-v0.12
Bert Belder 10 years ago
parent
commit
2b6a0f85f3
  1. 1
      doc/api/all.markdown
  2. 66
      doc/api/tracing.markdown
  3. 3
      lib/repl.js
  4. 65
      lib/tracing.js
  5. 1
      node.gyp
  6. 3
      src/node.js
  7. 26
      test/simple/test-v8-flags.js
  8. 53
      test/simple/test-v8-gc.js
  9. 36
      test/simple/test-v8-stats.js

1
doc/api/all.markdown

@ -35,4 +35,3 @@
@include debugger
@include cluster
@include smalloc
@include tracing

66
doc/api/tracing.markdown

@ -1,66 +0,0 @@
# Tracing
Stability: 1 - Experimental
The tracing module is designed for instrumenting your Node application. It is
not meant for general purpose use.
`require('tracing')` to use this module.
## v8
The `v8` property is an [EventEmitter][], it exposes events and interfaces
specific to the version of `v8` built with node. These interfaces are subject
to change by upstream and are therefore not covered under the stability index.
### Event: 'gc'
`function (before, after) { }`
Emitted each time a GC run is completed.
`before` and `after` are objects with the following properties:
```
{
type: 'mark-sweep-compact',
flags: 0,
timestamp: 905535650119053,
total_heap_size: 6295040,
total_heap_size_executable: 4194304,
total_physical_size: 6295040,
used_heap_size: 2855416,
heap_size_limit: 1535115264
}
```
### getHeapStatistics()
Returns an object with the following properties
```
{
total_heap_size: 7326976,
total_heap_size_executable: 4194304,
total_physical_size: 7326976,
used_heap_size: 3476208,
heap_size_limit: 1535115264
}
```
### setFlagsFromString()
Set additional V8 command line flags. Use with care; changing settings
after the VM has started may result in unpredictable behavior, including
crashes and data loss. Or it may simply do nothing.
Usage:
```
// Print GC events to stdout for one minute.
var v8 = require('tracing').v8;
v8.setFlagsFromString('--trace_gc');
setTimeout(function() { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
```

3
lib/repl.js

@ -74,8 +74,7 @@ exports.writer = util.inspect;
exports._builtinLibs = ['assert', 'buffer', 'child_process', 'cluster',
'crypto', 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'https', 'net',
'os', 'path', 'punycode', 'querystring', 'readline', 'stream',
'string_decoder', 'tls', 'tty', 'url', 'util', 'vm', 'zlib', 'smalloc',
'tracing'];
'string_decoder', 'tls', 'tty', 'url', 'util', 'vm', 'zlib', 'smalloc'];
function REPLServer(prompt, stream, eval_, useGlobal, ignoreUndefined) {

65
lib/tracing.js

@ -1,65 +0,0 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
var EventEmitter = require('events');
var v8binding, process;
// This needs to be loaded early, and before the "process" object is made
// global. So allow src/node.js to pass the process object in during
// initialization.
exports._nodeInitialization = function nodeInitialization(pobj) {
process = pobj;
v8binding = process.binding('v8');
// Finish setting up the v8 Object.
v8.getHeapStatistics = v8binding.getHeapStatistics;
v8.setFlagsFromString = v8binding.setFlagsFromString;
// Do a little housekeeping.
delete exports._nodeInitialization;
};
// v8
var v8 = exports.v8 = new EventEmitter();
function emitGC(before, after) {
v8.emit('gc', before, after);
}
v8.on('newListener', function(name) {
if (name === 'gc' && EventEmitter.listenerCount(this, name) === 0) {
v8binding.startGarbageCollectionTracking(emitGC);
}
});
v8.on('removeListener', function(name) {
if (name === 'gc' && EventEmitter.listenerCount(this, name) === 0) {
v8binding.stopGarbageCollectionTracking();
}
});

1
node.gyp

@ -57,7 +57,6 @@
'lib/string_decoder.js',
'lib/sys.js',
'lib/timers.js',
'lib/tracing.js',
'lib/tls.js',
'lib/_tls_common.js',
'lib/_tls_legacy.js',

3
src/node.js

@ -42,9 +42,6 @@
process.EventEmitter = EventEmitter; // process.EventEmitter is deprecated
// Setup the tracing module
NativeModule.require('tracing')._nodeInitialization(process);
// do this good and early, since it handles errors.
startup.processFatal();

26
test/simple/test-v8-flags.js

@ -1,26 +0,0 @@
// Copyright (c) 2014, StrongLoop Inc.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
var common = require('../common');
var assert = require('assert');
var v8 = require('tracing').v8;
var vm = require('vm');
v8.setFlagsFromString('--allow_natives_syntax');
assert(eval('%_IsSmi(42)'));
assert(vm.runInThisContext('%_IsSmi(42)'));
v8.setFlagsFromString('--noallow_natives_syntax');
assert.throws(function() { eval('%_IsSmi(42)') }, SyntaxError);
assert.throws(function() { vm.runInThisContext('%_IsSmi(42)') }, SyntaxError);

53
test/simple/test-v8-gc.js

@ -1,53 +0,0 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// Flags: --expose_gc
var common = require('../common');
var assert = require('assert');
var v8 = require('tracing').v8;
assert(typeof gc === 'function', 'Run this test with --expose_gc.');
var ncalls = 0;
var before;
var after;
function ongc(before_, after_) {
// Try very hard to not create garbage because that could kick off another
// garbage collection cycle.
before = before_;
after = after_;
ncalls += 1;
}
gc();
v8.on('gc', ongc);
gc();
v8.removeListener('gc', ongc);
gc();
assert.equal(ncalls, 1);
assert.equal(typeof before, 'object');
assert.equal(typeof after, 'object');
assert.equal(typeof before.timestamp, 'number');
assert.equal(typeof after.timestamp, 'number');
assert.equal(before.timestamp <= after.timestamp, true);

36
test/simple/test-v8-stats.js

@ -1,36 +0,0 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common');
var assert = require('assert');
var v8 = require('tracing').v8;
var s = v8.getHeapStatistics();
var keys = [
'heap_size_limit',
'total_heap_size',
'total_heap_size_executable',
'total_physical_size',
'used_heap_size'];
assert.deepEqual(Object.keys(s).sort(), keys);
keys.forEach(function(key) {
assert.equal(typeof s[key], 'number');
});
Loading…
Cancel
Save