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

lib: make navigator properties lazy #53649

Merged

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Jun 30, 2024

Noticed in some benchmarking/profiling that the Navigator object constructor was rather expensive and slow due to initialization of properties during construction. It makes more sense for these to be lazily initialized on first access.

Flamegraphs... of `node -pe "navigator"

Before:
image

After:
image

@jasnell jasnell requested review from mcollina and anonrig June 30, 2024 07:48
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/web-standards

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Jun 30, 2024
@jasnell jasnell added the performance Issues and PRs related to the performance of Node.js. label Jun 30, 2024
@jasnell jasnell force-pushed the make-navigator-properties-lazy branch from 5a3b5a3 to 3d2e10f Compare June 30, 2024 07:53
Noticed in some benchmarking/profiling that the Navigator object
constructor was rather expensive and slow due to initialization
of properties during construction. It makes more sense for these
to be lazily initialized on first access.
@jasnell jasnell force-pushed the make-navigator-properties-lazy branch from 3d2e10f to 875952b Compare June 30, 2024 07:56
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

@anonrig anonrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jun 30, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 3, 2024
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

@richardlau richardlau added the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 4, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 4, 2024
@nodejs-github-bot nodejs-github-bot merged commit 8040994 into nodejs:main Jul 4, 2024
57 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 8040994

ljharb added a commit to ljharb/node that referenced this pull request Jul 8, 2024
…form

Preserves most of nodejs#53649, except for `#language` due to the lack of Intl primordials.
ljharb added a commit to ljharb/node that referenced this pull request Jul 8, 2024
Preserves most of nodejs#53649, except for `#language` due to the lack of Intl primordials.
ljharb added a commit to ljharb/node that referenced this pull request Jul 8, 2024
Preserves most of nodejs#53649, except for `#language` due to the lack of Intl primordials.
ljharb added a commit to ljharb/node that referenced this pull request Jul 8, 2024
Preserves most of nodejs#53649,
except for `#language` due to the lack of Intl primordials.
ljharb added a commit to ljharb/node that referenced this pull request Jul 8, 2024
Preserves most of nodejs#53649,
except for `#language` due to the lack of Intl primordials.
ljharb added a commit to ljharb/node that referenced this pull request Jul 8, 2024
Preserves most of nodejs#53649,
except for `#language` due to the lack of Intl primordials.
ljharb added a commit to ljharb/node that referenced this pull request Jul 8, 2024
Preserves most of nodejs#53649,
except for `#language` due to the lack of Intl primordials.
ljharb added a commit to ljharb/node that referenced this pull request Jul 8, 2024
Preserves most of nodejs#53649,
except for `#language` due to the lack of Intl primordials.
ljharb added a commit to ljharb/node that referenced this pull request Jul 8, 2024
Preserves most of nodejs#53649,
except for `#language` due to the lack of Intl primordials.
ljharb added a commit to ljharb/node that referenced this pull request Jul 8, 2024
Preserves most of nodejs#53649,
except for `#language` due to the lack of Intl primordials.
ljharb added a commit to ljharb/node that referenced this pull request Jul 8, 2024
Preserves most of nodejs#53649,
except for `#language` due to the lack of Intl primordials.
ljharb added a commit to ljharb/node that referenced this pull request Jul 9, 2024
ljharb added a commit to ljharb/node that referenced this pull request Jul 9, 2024
ljharb added a commit to ljharb/node that referenced this pull request Jul 9, 2024
ljharb added a commit to ljharb/node that referenced this pull request Jul 11, 2024
ljharb added a commit to ljharb/node that referenced this pull request Jul 11, 2024
ljharb added a commit to ljharb/node that referenced this pull request Jul 11, 2024
aduh95 pushed a commit that referenced this pull request Jul 12, 2024
Noticed in some benchmarking/profiling that the Navigator object
constructor was rather expensive and slow due to initialization
of properties during construction. It makes more sense for these
to be lazily initialized on first access.

PR-URL: #53649
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@aduh95 aduh95 mentioned this pull request Jul 12, 2024
ljharb added a commit to ljharb/node that referenced this pull request Jul 15, 2024
ljharb added a commit to ljharb/node that referenced this pull request Jul 15, 2024
ljharb added a commit to ljharb/node that referenced this pull request Jul 15, 2024
nodejs-github-bot pushed a commit that referenced this pull request Jul 15, 2024
Preserves #53649.

PR-URL: #53765
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
aduh95 pushed a commit that referenced this pull request Jul 16, 2024
Noticed in some benchmarking/profiling that the Navigator object
constructor was rather expensive and slow due to initialization
of properties during construction. It makes more sense for these
to be lazily initialized on first access.

PR-URL: #53649
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
aduh95 pushed a commit that referenced this pull request Jul 16, 2024
Preserves #53649.

PR-URL: #53765
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
aduh95 pushed a commit that referenced this pull request Jul 16, 2024
Preserves #53649.

PR-URL: #53765
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
ehsankhfr pushed a commit to ehsankhfr/node that referenced this pull request Jul 18, 2024
Preserves nodejs#53649.

PR-URL: nodejs#53765
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@targos targos added the dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. needs-ci PRs that need a full CI run. performance Issues and PRs related to the performance of Node.js.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants