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

Esbuild bench #3

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
folder:
# TODO: needs a bit of work to work on CI
# - 'rules_js-npm'
- 'rules_ts'

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Write engflow credentials
working-directory: ${{ matrix.folder }}
run: |
touch engflow.crt engflow.key
chmod 0600 engflow.crt engflow.key
echo "$ENGFLOW_CLIENT_CRT" > engflow.crt
echo "$ENGFLOW_PRIVATE_KEY" > engflow.key
env:
ENGFLOW_CLIENT_CRT: ${{ secrets.ENGFLOW_CLIENT_CRT }}
ENGFLOW_PRIVATE_KEY: ${{ secrets.ENGFLOW_PRIVATE_KEY }}
- name: Run benchmarks
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
XDG_CACHE_HOME: ~/.cache/bazel-repo
working-directory: ${{ matrix.folder }}
run: ./run_benchmarks.sh
2 changes: 1 addition & 1 deletion rules_js-npm/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1.1
5.3.0
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,9 @@ source ./benchmark_4.sh
git checkout npm_install/package.json
git checkout npm_translate_lock/package.json
git checkout yarn_install/package.json

# sort the results
cat "$results_file" | sort > "$results_file"

echo "========================================"
cat "$results_file"
61 changes: 60 additions & 1 deletion rules_ts/.bazelrc
Original file line number Diff line number Diff line change
@@ -1 +1,60 @@
build --worker_max_instances=8
# In general, the rules in this repository assume that runfiles
# are enabled as we do not support no runfiles case.
#
# If you are developing on Windows, you must either run bazel
# with administrator priviledges or enable developer mode. If
# you do not you may hit this error on Windows:
#
# Bazel needs to create symlinks to build the runfiles tree.
# Creating symlinks on Windows requires one of the following:
# 1. Bazel is run with administrator privileges.
# 2. The system version is Windows 10 Creators Update (1703) or later
# and developer mode is enabled.
build --enable_runfiles

build --incompatible_allow_tags_propagation

# Turn off legacy external runfiles.
# This prevents accidentally depending on this feature, which Bazel will remove.
build --nolegacy_external_runfiles

# Turn on --incompatible_strict_action_env which was on by default
# in Bazel 0.21.0 but turned off again in 0.22.0. Follow
# https://github.com/bazelbuild/bazel/issues/7026 for more details.
# This flag is needed to so that postinstall scripts can be executed
# on the host.
# See https://github.com/angular/angular/issues/27514.
build --incompatible_strict_action_env

# TODO: enable once this is supported in Bazel
build:rbe --experimental_allow_unresolved_symlinks

# Generic remote cache
build --remote_local_fallback
build --remote_download_toplevel
build --remote_timeout=3600
build --remote_upload_local_results
## Fixes builds hanging on CI that get the TCP connection closed without sending RST packets.
build --grpc_keepalive_time=30s

# Generic remote build execution
build:rbe --extra_execution_platforms=@aspect_rules_js//platforms:x86_64_linux_remote
build:rbe --genrule_strategy=remote
build:rbe --host_platform=@aspect_rules_js//platforms:x86_64_linux_remote
build:rbe --jobs=32

# EngFlow remote cache
build:rbe --bes_backend=grpcs://tourmaline.cluster.engflow.com
build:rbe --bes_results_url=https://tourmaline.cluster.engflow.com/invocation/
build:rbe --remote_cache=grpcs://tourmaline.cluster.engflow.com

# EngFlow remote build execution
build:rbe --remote_executor=grpcs://tourmaline.cluster.engflow.com

# TODO: remove workaround for failure
build:rbe --modify_execution_info=GoCompilePkg=+no-remote-exec

# These files are written during CI setup, using secrets registered with the CI platforms
# For local development with RBE, you should override these in your ~/.bazelrc
build:rbe --tls_client_certificate=engflow.crt
build:rbe --tls_client_key=engflow.key
2 changes: 1 addition & 1 deletion rules_ts/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.2.0
aspect-build/6.0.0-aspect1
4 changes: 4 additions & 0 deletions rules_ts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ src
bazel-*
node_modules
ts_project
ts_project_rbe
ts_project_worker
ts_project_sandboxed_worker
ts_project_swc
ts_project_swc_rbe
ts_project_worker_swc
ts_project_sandboxed_worker_swc
ts_project_esbuild
ts_project_rules_nodejs
ts_project_rules_nodejs_swc
ts_library
ts_library_rbe
tsc
27 changes: 23 additions & 4 deletions rules_ts/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ nodejs_register_toolchains(
http_archive(
name = "aspect_rules_swc",
# HEAD of https://github.com/aspect-build/rules_swc/tree/swc_rust_2
sha256 = "1d3cfb38426728c5464c15b9d393ff1bf114a1b2a25091f261758252a770eaad",
strip_prefix = "rules_swc-acc8fc27903ecb49a44725813be7c2e2d21e660a",
url = "https://github.com/aspect-build/rules_swc/archive/acc8fc27903ecb49a44725813be7c2e2d21e660a.tar.gz",
sha256 = "74f49c7cd25ce62b1c09681723cec5577fd07bac4790bc65474d32d53de4e843",
strip_prefix = "rules_swc-d94c52f017a87c958dc431ebaac10cc034a816f5",
url = "https://github.com/aspect-build/rules_swc/archive/d94c52f017a87c958dc431ebaac10cc034a816f5.tar.gz",
)

load("@aspect_rules_swc//swc:dependencies.bzl", "rules_swc_dependencies")
Expand All @@ -40,7 +40,26 @@ swc_register_toolchains(
"darwin-arm64": "sha512-DuBBKIyk0iUGPmq6RQc7/uOCkGnvB0JDWQbWxA2NGAEcK0ZtI9J0efG9M1/gLIb0QD+d2DVS5Lx7VRIUFTx9lA==",
"darwin-x64": "sha512-WvDN6tRjQ/p+4gNvT4UVU4VyJLXy6hT4nT6mGgrtftG/9pP5dDPwwtTm86ISfqGUs8/LuZvrr4Nhwdr3j+0uAA==",
},
swc_version = "v1.2.204",
swc_version = "v1.2.244",
)

http_archive(
name = "aspect_rules_esbuild",
# HEAD of https://github.com/dzbarsky/rules_esbuild/tree/esbuild_transpiler
sha256 = "24f49ec473c9a96e8efef0f211642579ebc790e4e21cd6a5818ae4bfc610deb0",
strip_prefix = "rules_esbuild-e23be685e07a78ef14dd744ac844193dec09bd2c",
url = "https://github.com/aspect-build/rules_esbuild/archive/e23be685e07a78ef14dd744ac844193dec09bd2c.tar.gz",
)

load("@aspect_rules_esbuild//esbuild:dependencies.bzl", "rules_esbuild_dependencies")

rules_esbuild_dependencies()

load("@aspect_rules_esbuild//esbuild:repositories.bzl", "LATEST_VERSION", "esbuild_register_toolchains")

esbuild_register_toolchains(
name = "esbuild",
esbuild_version = LATEST_VERSION,
)

########################################################
Expand Down
2 changes: 1 addition & 1 deletion rules_ts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -o errexit -o nounset
style=$1

rm -rf "$style"
node generator.js "$style" "$style" 5 10 10 1000
node generator.js "$style" "$style" 5 10 10 100
27 changes: 27 additions & 0 deletions rules_ts/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ const featureNames = [
class Generator {
static STYLES = [
'ts_project',
'ts_project_rbe',
'ts_project_worker',
'ts_project_sandboxed_worker',
'ts_project_swc',
'ts_project_swc_rbe',
'ts_project_worker_swc',
'ts_project_sandboxed_worker_swc',
'ts_project_esbuild',
'ts_project_rules_nodejs',
'ts_project_rules_nodejs_swc',
'ts_library',
'ts_library_rbe',
'tsc',
]

Expand Down Expand Up @@ -139,6 +143,7 @@ ${this._ts_attributes()}
_load() {
switch (this.style) {
case 'ts_project':
case 'ts_project_rbe':
case 'ts_project_worker':
case 'ts_project_sandboxed_worker':
return [
Expand All @@ -147,6 +152,7 @@ ${this._ts_attributes()}
].join("\n")

case 'ts_project_swc':
case 'ts_project_swc_rbe':
case 'ts_project_worker_swc':
case 'ts_project_sandboxed_worker_swc':
return [
Expand All @@ -155,6 +161,12 @@ ${this._ts_attributes()}
'load("@aspect_rules_swc//swc:defs.bzl", "swc_transpiler")',
].join("\n")

case 'ts_project_esbuild':
return [
'load("@aspect_rules_ts//ts:defs.bzl", "ts_project")',
'load("@aspect_rules_js//js:defs.bzl", "js_library")',
'load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild_transpiler")',
].join("\n")
case 'ts_project_rules_nodejs':
return [
'load("@npm//@bazel/typescript:index.bzl", "ts_project")',
Expand All @@ -168,6 +180,7 @@ ${this._ts_attributes()}
].join("\n")

case 'ts_library':
case 'ts_library_rbe':
return [
'load("@npm_tslibrary//@bazel/concatjs:index.bzl", ts_project = "ts_library")',
'load("@npm_tslibrary//@bazel/concatjs:index.bzl", js_library = "ts_library")',
Expand Down Expand Up @@ -202,11 +215,14 @@ ${this._ts_attributes()}
_root_build(rootDeps) {
switch (this.style) {
case 'ts_project':
case 'ts_project_rbe':
case 'ts_project_worker':
case 'ts_project_sandboxed_worker':
case 'ts_project_swc':
case 'ts_project_swc_rbe':
case 'ts_project_worker_swc':
case 'ts_project_sandboxed_worker_swc':
case 'ts_project_esbuild':
return `
# Generated BUILD file, see /generate.js
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
Expand All @@ -230,6 +246,7 @@ ${rootDeps.map(d => ` \"${d}\",`).join("\n")}
case 'ts_project_rules_nodejs':
case 'ts_project_rules_nodejs_swc':
case 'ts_library':
case 'ts_library_rbe':
return `
# Generated BUILD file, see /generate.js
${this._load()}
Expand All @@ -253,6 +270,7 @@ ${rootDeps.map(d => ` \"${d}\",`).join("\n")}
let attrs = []
switch (this.style) {
case 'ts_project':
case 'ts_project_rbe':
attrs.push(` tsconfig = "//${this.outputDir}:tsconfig",`)
attrs.push(' declaration = True,')
attrs.push(' supports_workers = False,')
Expand All @@ -266,6 +284,7 @@ ${rootDeps.map(d => ` \"${d}\",`).join("\n")}
break;

case 'ts_project_swc':
case 'ts_project_swc_rbe':
attrs.push(` tsconfig = "//${this.outputDir}:tsconfig",`)
attrs.push(' declaration = True,')
attrs.push(' transpiler = swc_transpiler,')
Expand All @@ -280,6 +299,13 @@ ${rootDeps.map(d => ` \"${d}\",`).join("\n")}
attrs.push(' supports_workers = True,')
break;

case 'ts_project_esbuild':
attrs.push(` tsconfig = "//${this.outputDir}:tsconfig",`)
attrs.push(' declaration = True,')
attrs.push(' transpiler = esbuild_transpiler,')
attrs.push(' supports_workers = False,')
break;

case 'ts_project_rules_nodejs':
attrs.push(` tsconfig = "//${this.outputDir}:tsconfig.json",`)
attrs.push(' declaration = True,')
Expand All @@ -292,6 +318,7 @@ ${rootDeps.map(d => ` \"${d}\",`).join("\n")}
break;

case 'ts_library':
case 'ts_library_rbe':
attrs.push(` tsconfig = "//${this.outputDir}:tsconfig.json",`)
break;

Expand Down
4 changes: 4 additions & 0 deletions rules_ts/run_benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ else
bazel_flags+=( --noworker_sandboxing )
fi

if [[ "$style" == *"rbe"* ]]; then
bazel_flags+=( --config=rbe )
fi

pushd "$style"
if [ "$style" == "tsc" ]; then
yarn install
Expand Down
10 changes: 10 additions & 0 deletions rules_ts/run_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,28 @@ rm -f "$results_file"

styles=(
'ts_project'
'ts_project_rbe'
'ts_project_worker'
'ts_project_sandboxed_worker'
'ts_project_swc'
'ts_project_swc_rbe'
'ts_project_worker_swc'
'ts_project_sandboxed_worker_swc'
'ts_project_esbuild'
'ts_project_rules_nodejs'
'ts_project_rules_nodejs_swc'
'ts_library'
'ts_library_rbe'
'tsc'
)

for style in "${styles[@]}"
do
./run_benchmark.sh "$style" "$results_file"
done

# sort the results
sort "$results_file" -o "$results_file"

echo "========================================"
cat "$results_file"