This repository has been archived by the owner on Apr 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
decrease build times for pack command
- We can reuse the tarball and append new files (node binaries in this case) instead of compressing/extracting multiple times. This prevents un-necessary copying of files in the built tarball. We can also build all `targets` in parallel in the following way: - Download Node.js versions for targets in parallel instead of serially - Use [workerpool][1] to create gzip files in parallel - Run all `xz` compression with maximum available threads. xz has [supported multicore computation since 5.2 (2014)][1]. - Like gzip, run all `xz` compression in parallel instead of waiting for each target to build. Running this in the Heroku CLI produced identical tarballs in 65% amount of time (~111s seconds vs ~344 seconds before this change). It's likely even a bit faster since I was running it locally which has some boot-up time due to ts-node compiling typescript at runtime. [1]: https://www.npmjs.com/package/workerpool [2]: https://www.phoronix.com/scan.php?page=news_item&px=MTg3MDM
- Loading branch information
1 parent
ea4bae7
commit 8c60eff
Showing
7 changed files
with
549 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const {worker} = require('workerpool'); | ||
const {createGzip} = require('zlib'); | ||
const {pipeline: streamPipeline} = require('stream'); | ||
const {promisify} = require('util'); | ||
const fs = require('fs'); | ||
|
||
const pipeline = promisify(streamPipeline); | ||
|
||
function gzip(filePath, target) { | ||
const gzip = createGzip({level: 6}); | ||
const readStream = fs.createReadStream(filePath); | ||
const writeStream = fs.createWriteStream(target); | ||
return pipeline(readStream, gzip, writeStream).then(() => true); | ||
} | ||
|
||
worker({ | ||
gzip: gzip | ||
}) |
Oops, something went wrong.