Skip to content

Commit 9d71e6a

Browse files
jasnelldanbev
authored andcommitted
src: deprecate global COUNTER_* 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. PR-URL: #22485 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: João Reis <reis@janeasystems.com>
1 parent 6e746f1 commit 9d71e6a

23 files changed

+33
-871
lines changed

configure.py

-18
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

-2
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

-2
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

+26-1
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@
172172
NativeModule.require('internal/process/esm_loader').setup();
173173
}
174174

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

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

200225
setupAllowedFlags();

lib/net.js

-2
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

-58
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
}],
@@ -569,28 +563,6 @@
569563
}],
570564
],
571565
}],
572-
[ 'node_use_perfctr=="true"', {
573-
'defines': [ 'HAVE_PERFCTR=1' ],
574-
'dependencies': [ 'node_perfctr' ],
575-
'include_dirs': [
576-
'src',
577-
'tools/msvs/genfiles',
578-
'<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h
579-
],
580-
'sources': [
581-
'src/node_win32_perfctr_provider.h',
582-
'src/node_win32_perfctr_provider.cc',
583-
'src/node_counters.cc',
584-
'src/node_counters.h',
585-
],
586-
'conditions': [
587-
['node_intermediate_lib_type != "static_library"', {
588-
'sources': [
589-
'tools/msvs/genfiles/node_perfctr_provider.rc',
590-
],
591-
}],
592-
],
593-
}],
594566
[ 'node_use_dtrace=="true"', {
595567
'defines': [ 'HAVE_DTRACE=1' ],
596568
'dependencies': [
@@ -714,30 +686,6 @@
714686
} ]
715687
]
716688
},
717-
# generate perf counter header and resource files
718-
{
719-
'target_name': 'node_perfctr',
720-
'type': 'none',
721-
'conditions': [
722-
[ 'node_use_perfctr=="true"', {
723-
'actions': [
724-
{
725-
'action_name': 'node_perfctr_man',
726-
'inputs': [ 'src/res/node_perfctr_provider.man' ],
727-
'outputs': [
728-
'tools/msvs/genfiles/node_perfctr_provider.h',
729-
'tools/msvs/genfiles/node_perfctr_provider.rc',
730-
'tools/msvs/genfiles/MSG00001.BIN',
731-
],
732-
'action': [ 'ctrpp <@(_inputs) '
733-
'-o tools/msvs/genfiles/node_perfctr_provider.h '
734-
'-rc tools/msvs/genfiles/node_perfctr_provider.rc'
735-
]
736-
},
737-
],
738-
} ]
739-
]
740-
},
741689
{
742690
'target_name': 'node_js2c',
743691
'type': 'none',
@@ -758,9 +706,6 @@
758706
[ 'node_use_dtrace=="false" and node_use_etw=="false"', {
759707
'inputs': [ 'src/notrace_macros.py' ]
760708
}],
761-
[ 'node_use_perfctr=="false"', {
762-
'inputs': [ 'src/noperfctr_macros.py' ]
763-
}],
764709
[ 'node_debug_lib=="false"', {
765710
'inputs': [ 'tools/nodcheck_macros.py' ]
766711
}],
@@ -989,9 +934,6 @@
989934
'HAVE_OPENSSL=1',
990935
],
991936
}],
992-
[ 'node_use_perfctr=="true"', {
993-
'defines': [ 'HAVE_PERFCTR=1' ],
994-
}],
995937
['v8_enable_inspector==1', {
996938
'sources': [
997939
'test/cctest/test_inspector_socket.cc',

src/node.cc

-8
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
@@ -2152,10 +2148,6 @@ void LoadEnvironment(Environment* env) {
21522148
InitDTrace(env, global);
21532149
#endif
21542150

2155-
#if defined HAVE_PERFCTR
2156-
InitPerfCounters(env, global);
2157-
#endif
2158-
21592151
// Enable handling of uncaught exceptions
21602152
// (FatalException(), break on uncaught exception in debugger)
21612153
//

src/node_counters.cc

-145
This file was deleted.

0 commit comments

Comments
 (0)