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

feat: Add --profile option to lerna exec and lerna run #2376

Merged
merged 16 commits into from Dec 27, 2019

Conversation

bweggersen
Copy link
Contributor

@bweggersen bweggersen commented Dec 10, 2019

Adds an option to profile the run and exec commands. It produces a performance profile which can be analyzed using DevTools in a Chromium-based browser.

Description

Profiles the run and exec commands and produces a performance profile which can be analyzed using DevTools in a Chromium-based browser (direct url: devtools://devtools/bundled/devtools_app.html). The profile shows a timeline of the operations where each operation is assigned to an open slot. The number of slots is determined by the --concurrency option and the number of open slots is determined by --concurrency minus the number of ongoing operations. The end result is a visualization of the parallel execution of your scripts.

image

The default location of the performance profiles is at the root of your project.

Motivation and Context

We have over 200 packages in our repository and we see build time regressions from time to time. Visualizing lerna run build helps us uncover obvious mistakes or opportunities for improvement. For instance, in the example above, the final green box in thread 0 depends on the green box immediately preceding it on thread 1 (expanding the threads in the DevTool reveals the name of each package). By splitting the green package on thread 1, we can allow the final package on thread 0 to start much sooner, giving us a performance improvement of ~5 mins on all builds.

How Has This Been Tested?

I have tested this locally with all the argument permutations. If we should have some more formal testing of this feature, I would greatly appreciate some guidance on what that could look like.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

package-lock.json Outdated Show resolved Hide resolved
package-lock.json Outdated Show resolved Hide resolved
utils/run-topologically/profiler.js Outdated Show resolved Hide resolved
utils/run-topologically/profiler.js Outdated Show resolved Hide resolved
utils/run-topologically/profiler.js Outdated Show resolved Hide resolved
utils/run-topologically/run-topologically.js Outdated Show resolved Hide resolved
commands/exec/index.js Outdated Show resolved Hide resolved
commands/exec/README.md Outdated Show resolved Hide resolved
commands/exec/README.md Outdated Show resolved Hide resolved
commands/exec/command.js Outdated Show resolved Hide resolved
This reverts commit 0a440f3.
Copy link
Contributor Author

@bweggersen bweggersen left a comment

Choose a reason for hiding this comment

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

Thank you for taking the time to review the PR!!

Copy link
Member

@evocateur evocateur left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

commands/exec/README.md Outdated Show resolved Hide resolved
@evocateur evocateur changed the title Add Performance Profiler to run and exec feat: Add --profile option to lerna exec and lerna run Dec 27, 2019
@evocateur evocateur merged commit 6290174 into lerna:master Dec 27, 2019
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.

None yet

2 participants