Skip to content

Commit 6b6c455

Browse files
joyeecheungMedhansh404
authored andcommitted
lib: remove unnecessary refreshHrtimeBuffer()
We now serialize/deseialize the hrtime buffers properly instead of throwing them away at serialization and creating new ones at pre-execution, so there is no need to reset the variables to the binding property at pre-execution time. PR-URL: nodejs#51446 Refs: nodejs#48655 Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Jithil P Ponnan <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Marco Ippolito <[email protected]>
1 parent c19bdc0 commit 6b6c455

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

lib/internal/process/per_thread.js

+7-16
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,13 @@ const { exitCodes: { kNoFailure } } = internalBinding('errors');
5757

5858
const binding = internalBinding('process_methods');
5959

60-
let hrValues;
61-
let hrBigintValues;
62-
63-
function refreshHrtimeBuffer() {
64-
// The 3 entries filled in by the original process.hrtime contains
65-
// the upper/lower 32 bits of the second part of the value,
66-
// and the remaining nanoseconds of the value.
67-
hrValues = binding.hrtimeBuffer;
68-
// Use a BigUint64Array in the closure because this is actually a bit
69-
// faster than simply returning a BigInt from C++ in V8 7.1.
70-
hrBigintValues = new BigUint64Array(binding.hrtimeBuffer.buffer, 0, 1);
71-
}
72-
73-
// Create the buffers.
74-
refreshHrtimeBuffer();
60+
// The 3 entries filled in by the original process.hrtime contains
61+
// the upper/lower 32 bits of the second part of the value,
62+
// and the remaining nanoseconds of the value.
63+
const hrValues = binding.hrtimeBuffer;
64+
// Use a BigUint64Array because this is actually a bit
65+
// faster than simply returning a BigInt from C++ in V8 7.1.
66+
const hrBigintValues = new BigUint64Array(binding.hrtimeBuffer.buffer, 0, 1);
7567

7668
function hrtime(time) {
7769
binding.hrtime();
@@ -425,5 +417,4 @@ module.exports = {
425417
wrapProcessMethods,
426418
hrtime,
427419
hrtimeBigInt,
428-
refreshHrtimeBuffer,
429420
};

lib/internal/process/pre_execution.js

-2
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,6 @@ function patchProcessObject(expandArgv1) {
211211
const binding = internalBinding('process_methods');
212212
binding.patchProcessObject(process);
213213

214-
require('internal/process/per_thread').refreshHrtimeBuffer();
215-
216214
// Since we replace process.argv[0] below, preserve the original value in case the user needs it.
217215
ObjectDefineProperty(process, 'argv0', {
218216
__proto__: null,

0 commit comments

Comments
 (0)