Closed
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.perf_hooksIssues and PRs related to the perf_hooks module and performance measurement APIs.Issues and PRs related to the perf_hooks module and performance measurement APIs.
Description
Version
master branch
Platform
All
Subsystem
perf_hooks
What steps will reproduce the bug?
function f() {}
let h1 = perf_hooks.createHistogram()
let h2 = perf_hooks.createHistogram()
let f1 = perf_hooks.performance.timerify(f, {histogram: h1})
let f2 = perf_hooks.performance.timerify(f, {histogram: h2})
f1 !== f2 // expect true, actual falseHow often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
Every calls of performance.timerify(fn) should return a new timerified function instance for fn, at least if options is provided.
What do you see instead?
Currently timerify will cache the timerfied function as fn[kTimerified], so timerify(fn) always return same timerified function for fn, even different options was given.
Additional information
Current cache behavior is not very useful, and cause problems for the use cases which need multiple timerified versions (for example, record timing for different usage of the same function).
PS. It also will throw if fn is frozen/sealed/non-extensible.
Reacted by Benjamin Gruenbaum and Alex Yang
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.perf_hooksIssues and PRs related to the perf_hooks module and performance measurement APIs.Issues and PRs related to the perf_hooks module and performance measurement APIs.
Activity
himself65 commentedon Apr 24, 2022
Related:
node/lib/internal/perf/timerify.js
Lines 74 to 123 in a75d4e2
himself65 commentedon Apr 24, 2022
Upstream PR: #37136
It seems like the memorization is for the performance
himself65 commentedon Apr 24, 2022
I'm working on this issue
perf_hooks: return different functions in timerify
perf_hooks: return different functions in timerify
perf_hooks: return different functions in timerify
perf_hooks: return different functions in timerify
perf_hooks: return different functions in timerify
perf_hooks: return different functions in timerify
perf_hooks: return different functions in timerify