Skip to content

events: improve once() performance

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)
  • events
Description of change

This commit takes advantage of the performance improvements V8 has made to function.bind() in V8 5.4 and uses it to avoid constant recompilation/reoptimization of the wrapper closure used in once(). This change results in ~27% performance increase for once().

Example results with included benchmark:

                             improvement significant      p.value
events/ee-once.js n=20000000     27.17 %         *** 2.322255e-10

CI: https://ci.nodejs.org/job/node-test-pull-request/5581/

Merge request reports

Loading