Skip to content

Commit

Permalink
feat: introduce v8 snapshots to improve startup performance (#24295)
Browse files Browse the repository at this point in the history
Co-authored-by: Lachlan Miller <[email protected]>
Co-authored-by: Zach Bloomquist <[email protected]>
Co-authored-by: Tyler Biethman <[email protected]>
Co-authored-by: Matt Henkes <[email protected]>
Co-authored-by: Chris Breiding <[email protected]>
Co-authored-by: Matt Schile <[email protected]>
Co-authored-by: Mark Noonan <[email protected]>
Co-authored-by: Zachary Williams <[email protected]>
Co-authored-by: Ben M <[email protected]>
Co-authored-by: Zachary Williams <[email protected]>
Co-authored-by: astone123 <[email protected]>
Co-authored-by: Bill Glesias <[email protected]>
Co-authored-by: Emily Rohrbough <[email protected]>
Co-authored-by: Emily Rohrbough <[email protected]>
Co-authored-by: semantic-release-bot <[email protected]>
Co-authored-by: Adam Stone <[email protected]>
Co-authored-by: Blue F <[email protected]>
Co-authored-by: GitStart <[email protected]>
Co-authored-by: Mike Plummer <[email protected]>
Co-authored-by: Jordan <[email protected]>
Co-authored-by: Sam Goodger <[email protected]>
Co-authored-by: Colum Ferry <[email protected]>
Co-authored-by: Stokes Player <[email protected]>
Co-authored-by: Vilhelm Melkstam <[email protected]>
Co-authored-by: amehta265 <[email protected]>
  • Loading branch information
1 parent 440a08b commit b0c0eaa
Show file tree
Hide file tree
Showing 335 changed files with 37,371 additions and 623 deletions.
2 changes: 1 addition & 1 deletion .circleci/cache-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Bump this version to force CI to re-create the cache from scratch.

9-13-22
10-31-22
132 changes: 109 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ mainBuildFilters: &mainBuildFilters
branches:
only:
- develop
- fix-ci-deps
- issue-23843_electron_21_upgrade
- 'feature/v8-snapshots'

# usually we don't build Mac app - it takes a long time
# but sometimes we want to really confirm we are doing the right thing
Expand All @@ -37,8 +36,7 @@ macWorkflowFilters: &darwin-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ 'correct-dashboard-results', << pipeline.git.branch >> ]
- equal: [ 'issue-23843_electron_21_upgrade', << pipeline.git.branch >> ]
- equal: [ 'feature/v8-snapshots', << pipeline.git.branch >> ]
- matches:
pattern: "-release$"
value: << pipeline.git.branch >>
Expand All @@ -47,8 +45,7 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ 'webkit-multidomain', << pipeline.git.branch >> ]
- equal: [ 'issue-23843_electron_21_upgrade', << pipeline.git.branch >> ]
- equal: [ 'feature/v8-snapshots', << pipeline.git.branch >> ]
- matches:
pattern: "-release$"
value: << pipeline.git.branch >>
Expand All @@ -66,8 +63,7 @@ windowsWorkflowFilters: &windows-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ linux-arm64, << pipeline.git.branch >> ]
- equal: [ 'ryanm/fix/windows-node-module-install', << pipeline.git.branch >> ]
- equal: [ 'feature/v8-snapshots', << pipeline.git.branch >> ]
- matches:
pattern: "-release$"
value: << pipeline.git.branch >>
Expand Down Expand Up @@ -114,25 +110,27 @@ executors:
environment:
PLATFORM: windows

darwin-arm64:
darwin-arm64: &darwin-arm64-executor
machine: true
environment:
PLATFORM: darwin

linux-arm64:
linux-arm64: &linux-arm64-executor
machine:
image: ubuntu-2004:2022.04.1
resource_class: arm.medium
environment:
PLATFORM: linux
# TODO: Disabling snapshots for now on Linux Arm 64 architectures. Will revisit with https://github.com/cypress-io/cypress/issues/23557
DISABLE_SNAPSHOT_REQUIRE: 1

commands:
verify_should_persist_artifacts:
steps:
- run:
name: Check current branch to persist artifacts
command: |
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "issue-23843_electron_21_upgrade" ]]; then
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "feature/v8-snapshots" ]]; then
echo "Not uploading artifacts or posting install comment for this branch."
circleci-agent step halt
fi
Expand Down Expand Up @@ -199,6 +197,11 @@ commands:
command: |
source ./scripts/ensure-node.sh
yarn build
- run:
name: Generate v8 snapshot
command: |
source ./scripts/ensure-node.sh
yarn build-v8-snapshot-prod
- prepare-modules-cache # So we don't throw these in the workspace cache
- persist_to_workspace:
root: ~/
Expand Down Expand Up @@ -478,7 +481,7 @@ commands:
- run:
name: Run driver tests in Cypress
environment:
CYPRESS_KONFIG_ENV: production
CYPRESS_CONFIG_ENV: production
command: |
echo Current working directory is $PWD
echo Total containers $CIRCLE_NODE_TOTAL
Expand Down Expand Up @@ -562,7 +565,7 @@ commands:
# internal PR
cmd=$([[ <<parameters.percy>> == 'true' ]] && echo 'yarn percy exec --parallel -- --') || true
DEBUG=<<parameters.debug>> \
CYPRESS_KONFIG_ENV=production \
CYPRESS_CONFIG_ENV=production \
CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \
PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \
PERCY_ENABLE=${PERCY_TOKEN:-0} \
Expand All @@ -588,7 +591,7 @@ commands:
cd ../..
DEBUG=<<parameters.debug>> \
CYPRESS_KONFIG_ENV=production \
CYPRESS_CONFIG_ENV=production \
PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \
PERCY_ENABLE=${PERCY_TOKEN:-0} \
PERCY_PARALLEL_TOTAL=-1 \
Expand Down Expand Up @@ -1063,14 +1066,16 @@ commands:
# notarization on Mac can take a while
no_output_timeout: "45m"
command: |
source ./scripts/ensure-node.sh
node --version
if [[ `node ./scripts/get-platform-key.js` == 'linux-arm64' ]]; then
# these are missing on Circle and there is no way to pre-install them on Arm
sudo apt-get update
sudo apt-get install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
DISABLE_SNAPSHOT_REQUIRE=1 yarn binary-build --version $(node ./scripts/get-next-version.js)
else
yarn binary-build --version $(node ./scripts/get-next-version.js)
fi
source ./scripts/ensure-node.sh
node --version
yarn binary-build --version $(node ./scripts/get-next-version.js)
- run:
name: Zip the binary
command: |
Expand Down Expand Up @@ -1207,7 +1212,7 @@ jobs:
<<: *defaultsParameters
resource_class:
type: string
default: medium+
default: large
resource_class: << parameters.resource_class >>
steps:
- restore_cached_workspace
Expand Down Expand Up @@ -1316,6 +1321,52 @@ jobs:
PERCY_PARALLEL_TOTAL=-1 \
yarn percy snapshot ./cli/visual-snapshots
v8-integration-tests:
<<: *defaults
parameters:
<<: *defaultsParameters
resource_class:
type: string
default: medium
resource_class: << parameters.resource_class >>
parallelism: 1
steps:
- restore_cached_workspace
- restore_cached_system_tests_deps
# TODO: Remove this once we switch off self-hosted M1 runners
- when:
condition:
equal: [ *darwin-arm64-executor, << parameters.executor >> ]
steps:
- run: rm -f /tmp/cypress/junit/*
- unless:
condition:
or:
- equal: [ *linux-arm64-executor, << parameters.executor >> ] # TODO: Figure out how to support linux-arm64 when we get to linux arm64 build: https://github.com/cypress-io/cypress/issues/23557
steps:
- run:
name: Run v8 integration tests
command: |
source ./scripts/ensure-node.sh
yarn test-integration --scope "'@tooling/{packherd,v8-snapshot,electron-mksnapshot}'"
- verify-mocha-results:
expectedResultCount: 3
- when:
condition:
or:
- equal: [ *linux-arm64-executor, << parameters.executor >> ]
steps:
- run:
name: Run v8 integration tests
command: |
source ./scripts/ensure-node.sh
yarn test-integration --scope "'@tooling/packherd'"
- verify-mocha-results:
expectedResultCount: 1
- store_test_results:
path: /tmp/cypress
- store-npm-logs

unit-tests:
<<: *defaults
parameters:
Expand Down Expand Up @@ -1346,7 +1397,7 @@ jobs:
# run type checking for each individual package
- run: yarn lerna run types
- verify-mocha-results:
expectedResultCount: 10
expectedResultCount: 18
- store_test_results:
path: /tmp/cypress
# CLI tests generate HTML files with sample CLI command output
Expand Down Expand Up @@ -1677,7 +1728,7 @@ jobs:
working_directory: packages/reporter
- run:
command: |
CYPRESS_KONFIG_ENV=production \
CYPRESS_CONFIG_ENV=production \
CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \
PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \
PERCY_ENABLE=${PERCY_TOKEN:-0} \
Expand All @@ -1700,7 +1751,7 @@ jobs:
- restore_cached_system_tests_deps
- run:
command: |
CYPRESS_KONFIG_ENV=production \
CYPRESS_CONFIG_ENV=production \
CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \
PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \
PERCY_ENABLE=${PERCY_TOKEN:-0} \
Expand All @@ -1722,7 +1773,7 @@ jobs:
- restore_cached_system_tests_deps
- run:
command: |
CYPRESS_KONFIG_ENV=production \
CYPRESS_CONFIG_ENV=production \
CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \
PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \
PERCY_ENABLE=${PERCY_TOKEN:-0} \
Expand Down Expand Up @@ -1932,7 +1983,7 @@ jobs:
<<: *defaultsParameters
resource_class:
type: string
default: medium+
default: large
resource_class: << parameters.resource_class >>
steps:
- restore_cached_workspace
Expand All @@ -1951,6 +2002,7 @@ jobs:
type: string
default: medium+
steps:
- restore_cached_workspace
- clone-repo-and-checkout-branch:
repo: cypress-example-kitchensink
- install-required-node
Expand Down Expand Up @@ -1986,6 +2038,7 @@ jobs:
test-kitchensink-against-staging:
<<: *defaults
steps:
- restore_cached_workspace
- clone-repo-and-checkout-branch:
repo: cypress-example-kitchensink
- install-required-node
Expand All @@ -2011,6 +2064,7 @@ jobs:
test-against-staging:
<<: *defaults
steps:
- restore_cached_workspace
- clone-repo-and-checkout-branch:
repo: cypress-test-tiny
- run:
Expand Down Expand Up @@ -2517,6 +2571,9 @@ linux-x64-workflow: &linux-x64-workflow
- npm-cypress-schematic:
requires:
- build
- v8-integration-tests:
requires:
- system-tests-node-modules-install
# This release definition must be updated with any new jobs
# Any attempts to automate this are welcome
# If CircleCI provided an "after all" hook, then this wouldn't be necessary
Expand Down Expand Up @@ -2567,6 +2624,7 @@ linux-x64-workflow: &linux-x64-workflow
- run-reporter-component-tests-chrome
- run-webpack-dev-server-integration-tests
- run-vite-dev-server-integration-tests
- v8-integration-tests

# various testing scenarios, like building full binary
# and testing it on a real project
Expand Down Expand Up @@ -2677,6 +2735,13 @@ linux-arm64-workflow: &linux-arm64-workflow
requires:
- linux-arm64-build

- v8-integration-tests:
name: linux-arm64-v8-integration-tests
executor: linux-arm64
resource_class: arm.medium
requires:
- linux-arm64-build

darwin-x64-workflow: &darwin-x64-workflow
jobs:
- node_modules_install:
Expand Down Expand Up @@ -2716,6 +2781,13 @@ darwin-x64-workflow: &darwin-x64-workflow
requires:
- darwin-x64-build

- v8-integration-tests:
name: darwin-x64-v8-integration-tests
executor: mac
resource_class: macos.x86.medium.gen2
requires:
- darwin-x64-build

darwin-arm64-workflow: &darwin-arm64-workflow
jobs:
- node_modules_install:
Expand All @@ -2742,6 +2814,13 @@ darwin-arm64-workflow: &darwin-arm64-workflow
requires:
- darwin-arm64-build

- v8-integration-tests:
name: darwin-arm64-v8-integration-tests
executor: darwin-arm64
resource_class: cypress-io/latest_m1
requires:
- darwin-arm64-build

windows-workflow: &windows-workflow
jobs:
- node_modules_install:
Expand Down Expand Up @@ -2803,6 +2882,13 @@ windows-workflow: &windows-workflow
requires:
- windows-create-build-artifacts

- v8-integration-tests:
name: windows-v8-integration-tests
executor: windows
resource_class: windows.large
requires:
- windows-build

workflows:
linux-x64:
<<: *linux-x64-workflow
Expand Down
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,7 @@ system-tests/projects/react-app-webpack-5-unconfigured/**/*

system-tests/project-fixtures/**
system-tests/projects/**/*/expected-cypress*/**/*

# These are generated files that are not linted
tooling/electron-mksnapshot/bin/**
tooling/v8-snapshot/cache/**
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = {
'**/scripts/**',
'**/test/**',
'**/system-tests/**',
'tooling/**',
'packages/{app,driver,frontend-shared,launchpad}/cypress/**',
'*.test.ts',
// ignore in packages that don't run in the Cypress process
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,7 @@ globbed_node_modules
# Autogenerated files, typically from graphql-code-generator
*.gen.ts
*.gen.json

# Snapshot Binaries
snapshot_blob.bin
v8_context_snapshot.x86_64.bin
10 changes: 10 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"composables",
"dedup",
"ERRORED",
"esbuild",
"execa",
"Fetchable",
"Fetchables",
Expand All @@ -19,17 +20,26 @@
"intlify",
"Lachlan",
"loggedin",
"mksnapshot",
"msapplication",
"norewrite",
"NOTESTS",
"OVERLIMIT",
"overscan",
"packherd",
"Pinia",
"pnpm",
"pseudoclass",
"revparse",
"Screenshotting",
"semibold",
"shiki",
"snapbuild",
"snapgen",
"snapshottable",
"snapshotted",
"snapshotting",
"sourcemaps",
"speclist",
"testid",
"TIMEDOUT",
Expand Down
Loading

5 comments on commit b0c0eaa

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b0c0eaa Nov 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.12.0/linux-arm64/develop-b0c0eaa508bb6dafdc1997bc00fb7ed6f5bcc160/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b0c0eaa Nov 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.12.0/linux-x64/develop-b0c0eaa508bb6dafdc1997bc00fb7ed6f5bcc160/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b0c0eaa Nov 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.12.0/darwin-x64/develop-b0c0eaa508bb6dafdc1997bc00fb7ed6f5bcc160/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b0c0eaa Nov 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.12.0/darwin-arm64/develop-b0c0eaa508bb6dafdc1997bc00fb7ed6f5bcc160/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b0c0eaa Nov 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.12.0/win32-x64/develop-b0c0eaa508bb6dafdc1997bc00fb7ed6f5bcc160/cypress.tgz

Please sign in to comment.