-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf_hooks: fix rangeerror #54772
base: main
Are you sure you want to change the base?
perf_hooks: fix rangeerror #54772
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ const { | |
ArrayPrototypeFilter, | ||
ArrayPrototypeIncludes, | ||
ArrayPrototypePush, | ||
ArrayPrototypePushApply, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to this PR: Can we eventually add an eslint rule to avoid using this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would be the rational for such a rule? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. V8 has a hard limit on function argument count and without explicitly checking the number, it is easy to make a mistake? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Depending on use it can also be significantly faster. In undici we batch the .apply calls in our data url parser for performance: https://github.com/nodejs/undici/blob/89a46dd54f7d7db7513c435fac8042769ee9e9b5/lib/web/fetch/data-url.js#L657-L674 |
||
ArrayPrototypeSlice, | ||
ArrayPrototypeSort, | ||
Error, | ||
|
@@ -307,7 +306,9 @@ class PerformanceObserver { | |
maybeIncrementObserverCount(type); | ||
if (buffered) { | ||
const entries = filterBufferMapByNameAndType(undefined, type); | ||
ArrayPrototypePushApply(this.#buffer, entries); | ||
for (let i = 0; i < entries.length; i++) { | ||
ArrayPrototypePush(this.#buffer, entries[i]); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand the necessary fix but we should benchmark this to make sure it's not too much of a regression. Might make sense to split |
||
kPending.add(this); | ||
if (kPending.size) | ||
queuePending(); | ||
|
@@ -514,9 +515,15 @@ function filterBufferMapByNameAndType(name, type) { | |
return []; | ||
} else { | ||
bufferList = []; | ||
ArrayPrototypePushApply(bufferList, markEntryBuffer); | ||
ArrayPrototypePushApply(bufferList, measureEntryBuffer); | ||
ArrayPrototypePushApply(bufferList, resourceTimingBuffer); | ||
for (let i = 0; i < markEntryBuffer.length; i++) { | ||
ArrayPrototypePush(bufferList, markEntryBuffer[i]); | ||
} | ||
for (let i = 0; i < measureEntryBuffer.length; i++) { | ||
ArrayPrototypePush(bufferList, measureEntryBuffer[i]); | ||
} | ||
for (let i = 0; i < resourceTimingBuffer.length; i++) { | ||
ArrayPrototypePush(bufferList, resourceTimingBuffer[i]); | ||
} | ||
} | ||
if (name !== undefined) { | ||
bufferList = ArrayPrototypeFilter(bufferList, (buffer) => buffer.name === name); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s not the correct place to document, as this is not a performance issue IIUC