Skip to content

Commit 4e6ef4d

Browse files
committed
src: deprecate global COUNTER_* functions and remove perfctr
To support Performance Counters on Windows, a number of global `COUNTER_` methods were added that are undocumented and really only intended to be used internally by Node.js. Unfortunately, the perfctr support apparently hasn't even worked for quite a while and no one has even complained. This removes the perfctr support and replaces the global functions with deprecated non-ops for now, with the intent of removing those outright in the next major release cycle.
1 parent 9392535 commit 4e6ef4d

24 files changed

+34
-872
lines changed

configure.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,6 @@
455455

456456
parser.add_option_group(http2_optgroup)
457457

458-
parser.add_option('--with-perfctr',
459-
action='store_true',
460-
dest='with_perfctr',
461-
help='build with performance counters (default is true on Windows)')
462-
463458
parser.add_option('--without-dtrace',
464459
action='store_true',
465460
dest='without_dtrace',
@@ -475,11 +470,6 @@
475470
dest='without_npm',
476471
help='do not install the bundled npm (package manager)')
477472

478-
parser.add_option('--without-perfctr',
479-
action='store_true',
480-
dest='without_perfctr',
481-
help='build without performance counters')
482-
483473
# Dummy option for backwards compatibility
484474
parser.add_option('--with-snapshot',
485475
action='store_true',
@@ -1018,14 +1008,6 @@ def configure_node(o):
10181008
else:
10191009
o['variables']['node_use_etw'] = 'false'
10201010

1021-
# By default, enable Performance counters on Windows.
1022-
if flavor == 'win':
1023-
o['variables']['node_use_perfctr'] = b(not options.without_perfctr)
1024-
elif options.with_perfctr:
1025-
raise Exception('Performance counter is only supported on Windows.')
1026-
else:
1027-
o['variables']['node_use_perfctr'] = 'false'
1028-
10291011
o['variables']['node_with_ltcg'] = b(options.with_ltcg)
10301012
if flavor != 'win' and options.with_ltcg:
10311013
raise Exception('Link Time Code Generation is only supported on Windows.')

lib/_http_client.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ util.inherits(ClientRequest, OutgoingMessage);
285285

286286
ClientRequest.prototype._finish = function _finish() {
287287
DTRACE_HTTP_CLIENT_REQUEST(this, this.connection);
288-
COUNTER_HTTP_CLIENT_REQUEST();
289288
OutgoingMessage.prototype._finish.call(this);
290289
};
291290

@@ -554,7 +553,6 @@ function parserOnIncomingClient(res, shouldKeepAlive) {
554553
}
555554

556555
DTRACE_HTTP_CLIENT_RESPONSE(socket, req);
557-
COUNTER_HTTP_CLIENT_RESPONSE();
558556
req.res = res;
559557
res.req = req;
560558

lib/_http_server.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ util.inherits(ServerResponse, OutgoingMessage);
140140

141141
ServerResponse.prototype._finish = function _finish() {
142142
DTRACE_HTTP_SERVER_RESPONSE(this.connection);
143-
COUNTER_HTTP_SERVER_RESPONSE();
144143
OutgoingMessage.prototype._finish.call(this);
145144
};
146145

@@ -624,7 +623,6 @@ function parserOnIncoming(server, socket, state, req, keepAlive) {
624623

625624
res.shouldKeepAlive = keepAlive;
626625
DTRACE_HTTP_SERVER_REQUEST(req, socket);
627-
COUNTER_HTTP_SERVER_REQUEST();
628626

629627
if (socket._httpMessage) {
630628
// There are already pending outgoing res, append.

lib/internal/bootstrap/node.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@
171171
NativeModule.require('internal/process/esm_loader').setup();
172172
}
173173

174+
const { deprecate } = NativeModule.require('internal/util');
174175
{
175176
// Install legacy getters on the `util` binding for typechecking.
176177
// TODO(addaleax): Turn into a full runtime deprecation.
177178
const { pendingDeprecation } = process.binding('config');
178-
const { deprecate } = NativeModule.require('internal/util');
179179
const utilBinding = internalBinding('util');
180180
const types = internalBinding('types');
181181
for (const name of [
@@ -194,6 +194,31 @@
194194
}
195195
}
196196

197+
// TODO(jasnell): The following have been globals since around 2012.
198+
// That's just silly. The underlying perfctr support has been removed
199+
// so these are now deprecated non-ops that can be removed after one
200+
// major release cycle.
201+
if (process.platform === 'win32') {
202+
function noop() {}
203+
const names = [
204+
'NET_SERVER_CONNECTION',
205+
'NET_SERVER_CONNECTION_CLOSE',
206+
'HTTP_SERVER_REQUEST',
207+
'HTTP_SERVER_RESPONSE',
208+
'HTTP_CLIENT_REQUEST',
209+
'HTTP_CLIENT_RESPONSE'
210+
];
211+
for (var n = 0; n < names.length; n++) {
212+
Object.defineProperty(global, `COUNTER_${names[n]}`, {
213+
configurable: true,
214+
enumerable: false,
215+
value: deprecate(noop,
216+
`COUNTER_${names[n]}() is deprecated.`,
217+
'DEP00XX')
218+
});
219+
}
220+
}
221+
197222
perf.markMilestone(NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE);
198223

199224
setupAllowedFlags();

lib/net.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ Socket.prototype._destroy = function(exception, cb) {
615615
cb(exception);
616616

617617
if (this._server) {
618-
COUNTER_NET_SERVER_CONNECTION_CLOSE(this);
619618
debug('has server');
620619
this._server._connections--;
621620
if (this._server._emitCloseIfDrained) {
@@ -1522,7 +1521,6 @@ function onconnection(err, clientHandle) {
15221521
socket._server = self;
15231522

15241523
DTRACE_NET_SERVER_CONNECTION(socket);
1525-
COUNTER_NET_SERVER_CONNECTION(socket);
15261524
self.emit('connection', socket);
15271525
}
15281526

node.gyp

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
'v8_trace_maps%': 0,
55
'node_use_dtrace%': 'false',
66
'node_use_etw%': 'false',
7-
'node_use_perfctr%': 'false',
87
'node_no_browser_globals%': 'false',
98
'node_code_cache_path%': '',
109
'node_use_v8_platform%': 'true',
@@ -285,11 +284,6 @@
285284
'sources': [
286285
'tools/msvs/genfiles/node_etw_provider.rc'
287286
],
288-
}],
289-
[ 'node_use_perfctr=="true"', {
290-
'sources': [
291-
'tools/msvs/genfiles/node_perfctr_provider.rc',
292-
],
293287
}]
294288
],
295289
}],
@@ -565,28 +559,6 @@
565559
}],
566560
],
567561
}],
568-
[ 'node_use_perfctr=="true"', {
569-
'defines': [ 'HAVE_PERFCTR=1' ],
570-
'dependencies': [ 'node_perfctr' ],
571-
'include_dirs': [
572-
'src',
573-
'tools/msvs/genfiles',
574-
'<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h
575-
],
576-
'sources': [
577-
'src/node_win32_perfctr_provider.h',
578-
'src/node_win32_perfctr_provider.cc',
579-
'src/node_counters.cc',
580-
'src/node_counters.h',
581-
],
582-
'conditions': [
583-
['node_intermediate_lib_type != "static_library"', {
584-
'sources': [
585-
'tools/msvs/genfiles/node_perfctr_provider.rc',
586-
],
587-
}],
588-
],
589-
}],
590562
[ 'node_use_dtrace=="true"', {
591563
'defines': [ 'HAVE_DTRACE=1' ],
592564
'dependencies': [
@@ -710,30 +682,6 @@
710682
} ]
711683
]
712684
},
713-
# generate perf counter header and resource files
714-
{
715-
'target_name': 'node_perfctr',
716-
'type': 'none',
717-
'conditions': [
718-
[ 'node_use_perfctr=="true"', {
719-
'actions': [
720-
{
721-
'action_name': 'node_perfctr_man',
722-
'inputs': [ 'src/res/node_perfctr_provider.man' ],
723-
'outputs': [
724-
'tools/msvs/genfiles/node_perfctr_provider.h',
725-
'tools/msvs/genfiles/node_perfctr_provider.rc',
726-
'tools/msvs/genfiles/MSG00001.BIN',
727-
],
728-
'action': [ 'ctrpp <@(_inputs) '
729-
'-o tools/msvs/genfiles/node_perfctr_provider.h '
730-
'-rc tools/msvs/genfiles/node_perfctr_provider.rc'
731-
]
732-
},
733-
],
734-
} ]
735-
]
736-
},
737685
{
738686
'target_name': 'node_js2c',
739687
'type': 'none',
@@ -754,9 +702,6 @@
754702
[ 'node_use_dtrace=="false" and node_use_etw=="false"', {
755703
'inputs': [ 'src/notrace_macros.py' ]
756704
}],
757-
[ 'node_use_perfctr=="false"', {
758-
'inputs': [ 'src/noperfctr_macros.py' ]
759-
}],
760705
[ 'node_debug_lib=="false"', {
761706
'inputs': [ 'tools/nodcheck_macros.py' ]
762707
}],
@@ -985,9 +930,6 @@
985930
'HAVE_OPENSSL=1',
986931
],
987932
}],
988-
[ 'node_use_perfctr=="true"', {
989-
'defines': [ 'HAVE_PERFCTR=1' ],
990-
}],
991933
['v8_enable_inspector==1', {
992934
'sources': [
993935
'test/cctest/test_inspector_socket.cc',

src/node.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
#include "node_context_data.h"
3232
#include "tracing/traced_value.h"
3333

34-
#if defined HAVE_PERFCTR
35-
#include "node_counters.h"
36-
#endif
37-
3834
#if HAVE_OPENSSL
3935
#include "node_crypto.h"
4036
#endif
@@ -2229,10 +2225,6 @@ void LoadEnvironment(Environment* env) {
22292225
InitDTrace(env, global);
22302226
#endif
22312227

2232-
#if defined HAVE_PERFCTR
2233-
InitPerfCounters(env, global);
2234-
#endif
2235-
22362228
// Enable handling of uncaught exceptions
22372229
// (FatalException(), break on uncaught exception in debugger)
22382230
//

src/node_counters.cc

Lines changed: 0 additions & 145 deletions
This file was deleted.

0 commit comments

Comments
 (0)