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
ππβ¨ Significantly speed up gulp dist
and gulp check-types
#21939
Conversation
Okay, I've tested this PR a bunch of different ways, and it's yielding a significant speed up with no apparent downsides. (So far π€) Ready for review! |
The numbers are in. On average, this PR results in a:
See #21939 (comment) for more details. |
Very cool! Can this also improve perf for local dev by keeping the compiler running in the background? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing! Two little comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments addressed.
Re: using this for local dev:
- As written, a nailgun server will be used for
gulp dist
orgulp check-types
on linux or macos, irrespective of whether it's local dev or CI. (The server is cleaned up whether or not thegulp
task is successful.) - If you were asking about using this to start up an always-running compiler instance, it's definitely possible:
# Start runner.jar as a nailgun server
# You can drop the '&' and use a separate terminal for the server
$ java -XX:+TieredCompilation -server -cp \
third_party/nailgun/nailgun-server.jar:build-system/runner/dist/runner.jar \
com.facebook.nailgun.NGServer [PORT] &
NGServer 1.0.0-SNAPSHOT started on all addresses, port 2113.
# Use nailgun to compile code with runner.jar
$ echo "const foo = 42; function bar() { return foo * 2; }" > foo.js
$ third_party/nailgun/nailgun-runner [--nailgun-port PORT] \
org.ampproject.AmpCommandLineRunner -- --js foo.js
var foo=42;function bar(){return 2*foo};
# Stop nailgun server
# Ctrl+C works if the server is started without an '&'
$ third_party/nailgun/nailgun-runner [--nailgun-port PORT] ng-stop
NGServer shut down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This brought gulp dist
on my 2015 Macbook Pro from 34min to 6.58min. Also, my computer is actually usable during this time, unlike the old setup. ππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππ
I've tested this PR in a bunch of ways:
|
RE: Local dev: Could you wrap that in a gulp task? |
@cramforce Sent you #21977 |
Background:
gulp dist
used to take ~2 minutes on Linux, ~3 minutes on a Macbook Pro, and ~11 minutes on Travis to minify the runtime and all extensions.gulp dist
is the top cause of slow CI builds.)gulp-closure-compiler
plugin (defunct, hasn't seen an update in 3 years) in favor of the nativegulp
plugin ofgoogle-closure-compiler
(official repo for closure compiler, updated monthly) (π Replacegulp-closure-compiler
withgoogle-closure-compiler
(reprise)Β #21900).What this PR does:
Adopts
nailgun
, which can start up any java binary in the background in server mode, and allow it to be reused during successive calls while eliminating the long start-up time.Changes:
build-system/runner/dist/runner.jar
to a single jar instead of a jar-in-jar (to work withnailgun
)nailgun
binaries from https://github.com/facebook/nailgun tobuild-system/runner/nailgun/
gulpfile.js
andbuild-system/tasks/compile.js
to start up and use a nailgun server duringgulp dist
andgulp check-types
(on supported platforms)Running time improvements:
gulp dist
(all extensions):gulp dist
(no extensions):gulp check-types
:References:
nailgun
project: http://www.martiansoftware.com/nailgunnailgun
: of https://github.com/facebook/nailgunrunner.jar
: https://stackoverflow.com/q/515428Current release:
Fixes #10277