Skip to content

Commit

Permalink
RUSageMeter: remove C++ class and associated bindings and tests
Browse files Browse the repository at this point in the history
The native CPU metric instrumentation isn't needed anymore since
Node.js version 12 provides bindings of its own for this data. We
don't use the non-CPU metrics provided by RUSageMeter (memory, context
switches, etc) so it's okay to remove this feature wholesale.

A corresponding change in the calling code in the main agent repo is
forthcoming.

Fixes #154
  • Loading branch information
jordigh committed Mar 17, 2022
1 parent 44e810e commit 574cd89
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 329 deletions.
4 changes: 1 addition & 3 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"src/GCBinder.cpp",
"src/LoopChecker.hpp",
"src/LoopChecker.cpp",
"src/Metric.hpp",
"src/RUsageMeter.hpp",
"src/RUsageMeter.cpp"
"src/Metric.hpp"
],
"defines": [
"NOMINMAX"
Expand Down
56 changes: 1 addition & 55 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ function NativeMetricEmitter(opts) {
this.bound = false
this._timeout = null

this._rusageMeter = new natives.RUsageMeter()
this.usageEnabled = true

this._gcBinder = new natives.GCBinder()
this.gcEnabled = true

Expand All @@ -52,36 +49,6 @@ function NativeMetricEmitter(opts) {
}
util.inherits(NativeMetricEmitter, EventEmitter)

/**
* @interface RUsageStats
*
* @description
* Resource usage statistics.
*
* Properties marked (X) are unmaintained by the operating system and are
* likely to be just `0`.
*
* @property {number} ru_utime - user CPU time used in milliseconds
* @property {number} ru_stime - system CPU time used in milliseconds
* @property {number} ru_maxrss - maximum resident set size in bytes
* @property {number} ru_ixrss - integral shared memory size (X)
* @property {number} ru_idrss - integral unshared data size (X)
* @property {number} ru_isrss - integral unshared stack size (X)
* @property {number} ru_minflt - page reclaims (soft page faults) (X)
* @property {number} ru_majflt - page faults (hard page faults)
* @property {number} ru_nswap - swaps (X)
* @property {number} ru_inblock - block input operations
* @property {number} ru_oublock - block output operations
* @property {number} ru_msgsnd - IPC messages sent (X)
* @property {number} ru_msgrcv - IPC messages received (X)
* @property {number} ru_nsignals - signals received (X)
* @property {number} ru_nvcsw - voluntary context switches (X)
* @property {number} ru_nivcsw - involuntary context switches (X)
*
* @see http://docs.libuv.org/en/v1.x/misc.html#c.uv_getrusage
* @see http://docs.libuv.org/en/v1.x/misc.html#c.uv_rusage_t
*/

/**
* @interface LoopMetrics
*
Expand Down Expand Up @@ -125,34 +92,14 @@ util.inherits(NativeMetricEmitter, EventEmitter)
* @param {number} [timeout]
* The number of milliseconds between samplings. Defaults to 15 seconds.
*/
NativeMetricEmitter.prototype.bind = function bind(timeout) {
NativeMetricEmitter.prototype.bind = function bind() {
if (this.bound) {
return
}

timeout = timeout || DEFAULT_TIMEOUT
this._gcBinder.bind()
this._loopChecker.bind()

this._timeout = setTimeout(nativeMetricTimeout.bind(this), timeout).unref()
function nativeMetricTimeout() {
if (this._rusageMeter) {
/**
* Resource usage sampling event.
*
* @event NativeMetricEmitter#usage
* @type {object}
*
* @property {RUsageStats} diff - The change in stats since last sampling.
* @property {RUsageStats} current - The current usage statistics.
*/
this.emit('usage', this._rusageMeter.read())
}
if (this.bound) {
this._timeout = setTimeout(nativeMetricTimeout.bind(this), timeout).unref()
}
}

this.bound = true
}

Expand All @@ -166,7 +113,6 @@ NativeMetricEmitter.prototype.unbind = function unbind() {

this._gcBinder.unbind()
this._loopChecker.unbind()
clearTimeout(this._timeout)
this.bound = false
}

Expand Down
103 changes: 0 additions & 103 deletions src/RUsageMeter.cpp

This file was deleted.

77 changes: 0 additions & 77 deletions src/RUsageMeter.hpp

This file was deleted.

2 changes: 0 additions & 2 deletions src/native_metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@

#include "GCBinder.hpp"
#include "LoopChecker.hpp"
#include "RUsageMeter.hpp"

namespace nr {

NAN_MODULE_INIT(Init) {
Nan::HandleScope scope;
GCBinder::Init(target);
RUsageMeter::Init(target);
LoopChecker::Init(target);
}

Expand Down
89 changes: 0 additions & 89 deletions tests/unit/ru-meter.tap.js

This file was deleted.

0 comments on commit 574cd89

Please sign in to comment.