Skip to content

perf: avoid loadFullConfig when creating block hoist plugin #13223

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

Merged
merged 2 commits into from
Apr 27, 2021

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Apr 26, 2021

Q                       A
License MIT

Improve performance of loading block hoist plugin. The benchmark is conducted after removing the LOADED_PLUGIN cache:

current load block-hoist plugin: 622750 ops/sec ±1.82% (0.002ms)
baseline load block-hoist plugin: 12027 ops/sec ±7.69% (0.083ms)

For this reason I didn't add the benchmark files since the it can not be run without modifying the source.

Creating the plugin from constructor is 50x faster than hooking into loadConfig. However, since we already cache it, it would probably not have any real world performance changes. The benefit of this PR is that we don't have to maintain the parameters of loadConfig.sync.

@JLHwung JLHwung added pkg: core PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories labels Apr 26, 2021
@babel-bot
Copy link
Collaborator

babel-bot commented Apr 26, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/45634/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 26, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit a2f3002:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@@ -9,14 +8,13 @@ export default function loadBlockHoistPlugin(): Plugin {
// Lazy-init the internal plugin to remove the init-time circular
// dependency between plugins being passed @babel/core's export object,
// which loads this file, and this 'loadConfig' loading plugins.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: this comment needs to be updated.

@JLHwung JLHwung merged commit 88da2e8 into babel:main Apr 27, 2021
@JLHwung JLHwung deleted the perf-block-hoist branch April 27, 2021 18:39
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jul 28, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: core PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants