Skip to content

Commit

Permalink
more efficient node.js process startup (vercel/turborepo#7661)
Browse files Browse the repository at this point in the history
### Description

* Slow start for the concurrency of parallel booting node.js processes
(1, 2, 4, ...)
* Depending on historic statistics avoid booting up a new process, but
wait for one to finish computing

Loading the `/home` route on 16-core machine

Before:

```
16 x Node.js process startup 9.09s avg 568.07ms
16 x Node.js initialization 10.58s avg 660.96ms
276 x Node.js evaluation 30.17s avg 109.30ms
```

After:

```
7 x Node.js process startup 1261.79ms avg 180.26ms
7 x Node.js initialization 3.15s avg 450.21ms
276 x Node.js evaluation 29.41s avg 106.55ms
```


### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->


Closes PACK-2680
  • Loading branch information
sokra authored Mar 13, 2024
1 parent 682eaa1 commit dc91635
Show file tree
Hide file tree
Showing 2 changed files with 370 additions and 189 deletions.
2 changes: 1 addition & 1 deletion crates/turbopack-node/src/evaluate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ pub async fn compute(
let args = evaluate_context.args().iter().try_join().await?;
// Assume this is a one-off operation, so we can kill the process
// TODO use a better way to decide that.
let kill = args.is_empty();
let kill = !evaluate_context.keep_alive();

// Workers in the pool could be in a bad state that we didn't detect yet.
// The bad state might even be unnoticeable until we actually send the job to the
Expand Down
Loading

0 comments on commit dc91635

Please sign in to comment.