question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Startup time performance investigation

See original GitHub issue

In order to figure out how to make it faster, I wanted to see how it looked like right now.

Node startup time

Doing nothing with node takes ~40ms. So no matter what we do, we’ll never be able to get below 40ms.

time node -e ''
real	0m0.043s

Prettier startup time

Pretty printing an empty file with prettier takes ~150ms. This includes loading all the JavaScript and parsing/generating IR/printing nothing… :p

time echo '' | ./prettier.js --stdin > /dev/null
real	0m0.153s

Printing a 2k lines file

It takes ~420ms to print a 2.5k lines file.

time ./prettier.js ../src/printer.js > /dev/null
real	0m0.425s

npm run time

npm run startup time is ~380ms. This means that you consistently pay the overhead just for the fancy alias.

"scripts": {
    "donothing": "true",
time npm run donothing > /dev/null
real	0m0.383s

yarn run time

yarn run startup time is ~240ms. This is better (even though it’s still super slow).

time yarn run donothing > /dev/null
real	0m0.246s

Conclusion

If we want a snappy experience inside of the editor, we’ll likely want to load the JavaScript code once and then use it multiple times. We absolutely don’t want to do npm run prettier on every save otherwise we’d have to pay for half a second (380ms + 150ms = 530ms) every single time!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:27
  • Comments:15 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
jlongstercommented, Jan 24, 2017

Luckily we don’t encourage using npm or yarn in production, people just use the prettier CLI.

Atom gets the benefit of already being in JS, so it loads the module once and will reuse it.

For other editors, we do re-execute the script every single time. For smaller files it’s acceptable, but if we want to fix this, we’d need to start a “server” or something that can persist across executions.

I’m curious how much the 420ms for a 2k lines file goes down after JIT. You’d have to write a custom script for that which runs it multiple times.

0reactions
vjeuxcommented, Mar 1, 2017

This is not very actionable, I’m closing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Performance Study on the VM Startup Time in the Cloud
In this paper, we study the startup time of cloud VMs across three real-world cloud providers -- Amazon EC2, Windows Azure and Rackspace....
Read more >
Exercise 1 - Evaluate Fast Startup Using the Assessment Toolkit
Boot time is a common benchmark that is often used to measure Windows performance. Over the lifetime of a system, longer boot times...
Read more >
App startup time - Android Developers
This document provides information to help you optimize your app's launch time. It begins by explaining the internals of the launch process.
Read more >
How to Stand the Test of Time as a Startup - Forbes
To gain relevancy over time, you have to show momentum through: Larger fundraises and increasing prices over time; Financial performance that ...
Read more >
Testing App Startup Performance - Medium
Automating startup. Performance testing should always involve running a test many times, to reduce the inherent variability in results; the more ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found