Skip to content
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

refactor(lib/request): remove unused params #327

Merged
merged 1 commit into from
Feb 4, 2025
Merged

refactor(lib/request): remove unused params #327

merged 1 commit into from
Feb 4, 2025

Conversation

Fdawgs
Copy link
Member

@Fdawgs Fdawgs commented Jan 7, 2025

Not used at all within their respective functions.

Checklist

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

historically, these impacted perf as it removed a C++ call in V8.

@Fdawgs
Copy link
Member Author

Fdawgs commented Jan 8, 2025

historically, these impacted perf as it removed a C++ call in V8.

Thanks for the insight @mcollina, do you know if this is still a thing with Node >= 20?

@Uzlopak
Copy link
Contributor

Uzlopak commented Jan 8, 2025

is there more information regarding this "hack"?

@mcollina
Copy link
Member

mcollina commented Jan 8, 2025

https://v8.dev/blog/adaptor-frame

@mcollina
Copy link
Member

mcollina commented Jan 8, 2025

do you know if this is still a thing with Node >= 20?

It shouldn't be, but it should be measured.

@Fdawgs Fdawgs closed this Jan 16, 2025
@Fdawgs Fdawgs deleted the ref/unused branch January 16, 2025 01:42
@Fdawgs Fdawgs restored the ref/unused branch January 29, 2025 19:59
@Fdawgs Fdawgs reopened this Jan 29, 2025
@Fdawgs
Copy link
Member Author

Fdawgs commented Feb 4, 2025

Threw together a quick benchmark:

'use strict'

const Benchmark = require('benchmark')
const suite = new Benchmark.Suite()

function noParams () {
  return 'hello'
}

function unusedParams (_unused) {
  return 'hello'
}

suite.add('Unused Params Function', function () {
  unusedParams()
})
  .add('No Params Function', function () {
    noParams()
  })
  .on('cycle', function (event) {
    console.log(String(event.target))
  })
  .on('complete', function () {
    console.log('Fastest is ' + this.filter('fastest').map('name'))
  })
  .run()

Output (running on Intel i7-13650HX @4.9Ghz) with Node 20.18.1:

Unused Params Function x 1,710,143,718 ops/sec ±0.32% (94 runs sampled)
No Params Function x 1,721,140,393 ops/sec ±0.28% (95 runs sampled)
Fastest is No Params Function

@Fdawgs Fdawgs requested review from mcollina and Uzlopak February 4, 2025 15:10
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Fdawgs Fdawgs merged commit f60173c into main Feb 4, 2025
24 checks passed
@Fdawgs Fdawgs deleted the ref/unused branch February 4, 2025 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants