Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2aec229
Add Jetpack performance testing CI infrastructure
LiamSarsfield Dec 12, 2025
a2d8577
Trim verbose JSDoc and remove dead code from performance scripts
LiamSarsfield Dec 12, 2025
e0b91db
Fix eslint import/no-unresolved for standalone dependencies
LiamSarsfield Dec 12, 2025
6e1f661
Fix race condition with sequential container startup
LiamSarsfield Dec 12, 2025
f9dfbd5
Fix ESLint config: remove import/no-unresolved rule
LiamSarsfield Dec 12, 2025
63dca30
Disable import/no-unresolved rule for performance scripts
LiamSarsfield Dec 12, 2025
6595660
Add detailed calibration verification logging
LiamSarsfield Dec 12, 2025
bbdb6ea
Add tools/performance
LiamSarsfield Dec 14, 2025
c768b58
Update pnpm-lock.yaml to include dotenv and playwright dependencies f…
LiamSarsfield Dec 14, 2025
2492d1e
Update docker-compose.yml to change the dependency condition for the …
LiamSarsfield Dec 14, 2025
e4b74d9
Enhance performance testing documentation and scripts
LiamSarsfield Dec 14, 2025
df0cfd2
Add baseMetrics placeholder in post-to-codevitals.js
LiamSarsfield Dec 14, 2025
ce3b20d
Refactor browser launch configuration in calibrate-throttling.js
LiamSarsfield Dec 14, 2025
55e48ba
Merge remote-tracking branch 'origin/trunk' into add/perf-testing-ci-mvp
LiamSarsfield Dec 15, 2025
e2c9808
Refactor ESLint configuration for performance testing CLI scripts
LiamSarsfield Dec 18, 2025
d85f183
Update performance testing setup and documentation
LiamSarsfield Dec 18, 2025
c9dc15d
Merge remote-tracking branch 'origin/trunk' into add/perf-testing-ci-mvp
LiamSarsfield Dec 18, 2025
0ed39b5
Enhance Jetpack_WPCom_Connection_Simulator to log unhandled endpoints
LiamSarsfield Dec 19, 2025
e3e0860
Merge remote-tracking branch 'origin/trunk' into add/perf-testing-ci-mvp
LiamSarsfield Dec 19, 2025
9e2df0e
Merge branch 'trunk' into add/perf-testing-ci-mvp
LiamSarsfield Jan 3, 2026
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
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ packages:
- tools/cli
- tools/e2e-commons
- tools/js-tools
- tools/performance
- .github/files/coverage-munger

engineStrict: true
Expand Down
9 changes: 9 additions & 0 deletions tools/performance/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
results/*.json
results/*.log
.env
.env.local
playwright-report/
test-results/
build/
calibration.json
51 changes: 51 additions & 0 deletions tools/performance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Jetpack Performance Testing

Measures wp-admin dashboard LCP (Largest Contentful Paint) for Jetpack with simulated WordPress.com connection.

## CI Usage

The test suite is designed to run in TeamCity. See build configuration for setup.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it'd make more sense to run it in Actions rather than TeamCity, on each commit to trunk instead of backfilling weekly.

If you're running it in TeamCity, are you looking at the monorepo, or at https://github.com/Automattic/jetpack-production which has the already-built plugin?

Copy link
Contributor

Choose a reason for hiding this comment

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

One of the exploration intents is to see about reusing work. With our GHE instance, TeamCity is the runner we have to use, so seeing the pros/cons of TC here.

Copy link
Contributor Author

@LiamSarsfield LiamSarsfield Dec 18, 2025

Choose a reason for hiding this comment

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

I wonder if it'd make more sense to run it in Actions rather than TeamCity, on each commit to trunk instead of backfilling weekly.

GitHub Actions runners can have unpredictable performance variability due to shared infrastructure. For detecting small regressions (5-10%), this noise can drown out minor regressions over time. The TeamCity build runs on a dedicated machine with no other agents interfering.

If you're running it in TeamCity, are you looking at the monorepo, or at Automattic/jetpack-production which has the already-built plugin?

The monorep is used instead of the already-built plugin mainly so we can leverage commit level tracking, so we can have the ability to bisect when issues appear (where needed). It may not be needed for now though, but you can see within CodeVitals that a point can be clicked and we can see the commit details when clicking on the commit SHA.

Screenshot 2025-12-18 at 14 37 07

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that every commit that changes anything in Jetpack gets mirrored to Automattic/jetpack-production, absent rare cases where something goes wrong with the mirroring. Each commit there also includes a footer like Upstream-Ref: Automattic/jetpack@d5b54134bb471f3a54d04b12e128e6e0e2d77bde to make it easy to find the corresponding monorepo commit.

It's up to you, but it may save having to build each monorepo commit before you can test it.

It'll also either save you testing commits that don't affect Jetpack-the-plugin at all or save you having to maintain code to try to identify which ones do. I see your P2 post mentions

that touched PHP files in Jetpack or packages

That would unnecessarily test changes to packages like packages/jetpack-mu-wpcom, unless you have a list of packages to ignore. It could also miss JS-only changes that might still affect the LCP timing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that every commit that changes anything in Jetpack gets mirrored to Automattic/jetpack-production, absent rare cases where something goes wrong with the mirroring. Each commit there also includes a footer like Upstream-Ref: d5b5413 to make it easy to find the corresponding monorepo commit.

Actually yes! I should have checked this before hand, I didn't realise Automattic/jetpack-production has bissectable commits like this. It'll also help regarding the issue you mentioned for testing commits that don't affect Jetpack-the-plugin also. Thanks, I'll update the TeamCity build to use that instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use jetpack-production, the implementation now:

  1. Clones jetpack-production instead of building from the monorepo
  2. Parses Upstream-Ref from each mirror commit to track the original monorepo SHA in CodeVitals
  3. Removes file filtering from the TC scheduler

The monorepo VCS root is still used for the tools/performance/ scripts, but the plugin itself comes directly from the pre-built mirror.


### Build Steps

1. Build Jetpack plugin
2. Install dependencies (`pnpm install`)
3. Install Playwright (`pnpm exec playwright install chromium --with-deps`)
4. Calibrate CPU throttling (`pnpm calibrate`)
5. Run tests (`pnpm test --skip-rsync`)

### Environment Variables

| Variable | Description |
|----------|-------------|
| `CODEVITALS_TOKEN` | API token for posting results to CodeVitals |
| `CODEVITALS_URL` | CodeVitals API URL (default: https://www.codevitals.run) |
| `COMPOSE_PROJECT_NAME` | Unique Docker project name for build isolation |
| `GIT_COMMIT` | Git commit SHA for tracking |
| `GIT_BRANCH` | Git branch for tracking (default: trunk) |
| `ITERATIONS` | Number of measurement iterations (default: 5) |
| `WP_ADMIN_USER` | WordPress admin username (default: admin) |
| `WP_ADMIN_PASS` | WordPress admin password (default: password) |

## Metric

- `wp-admin-dashboard-connection-sim-largestContentfulPaint` - Dashboard LCP with simulated Jetpack connection

## How It Works

1. **Docker Setup**: Spins up WordPress with Jetpack and a simulated WordPress.com connection (fake tokens + mocked API with 200ms latency)
2. **CPU Calibration**: Normalizes CPU speed across different machines for consistent results
3. **LCP Measurement**: Uses Playwright to log in to wp-admin and measure Largest Contentful Paint
4. **Results**: Posts metrics to CodeVitals for tracking over time

## Scripts

| Script | Description |
|--------|-------------|
| `pnpm test` | Run full test suite |
| `pnpm test:quick` | Quick test with 2 iterations |
| `pnpm calibrate` | Run CPU throttling calibration |
| `pnpm measure` | Run LCP measurement only |
| `pnpm report` | Post results to CodeVitals only |
| `pnpm test -- --skip-rsync` | Run tests without rebuilding Jetpack |
| `pnpm test -- --skip-codevitals` | Run tests without posting to CodeVitals |
85 changes: 85 additions & 0 deletions tools/performance/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Jetpack Performance Testing Environment
# Single WordPress instance with simulated Jetpack connection for LCP measurement.
#
# Ports are assigned dynamically by Docker. Use 'docker compose port <service> 80' to discover.

services:
# Shared MySQL database
db:
image: mysql:8.0
command: --default-authentication-plugin=mysql_native_password
volumes:
- db_data:/var/lib/mysql
- ./init-databases.sql:/docker-entrypoint-initdb.d/init.sql:ro
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: rootpassword
networks:
- jetpack-perf
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-prootpassword"]
interval: 5s
timeout: 5s
retries: 20
start_period: 30s

# WordPress with Jetpack simulated connection
# Uses mu-plugin to fake connection tokens and intercept WP.com API calls with artificial latency
wordpress-jetpack-connected:
image: wordpress:6.7-php8.2-apache
ports:
- "80" # Dynamic port - use 'docker compose port wordpress-jetpack-connected 80' to discover
restart: unless-stopped
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: rootpassword
WORDPRESS_DB_NAME: wp_jetpack_connected
WORDPRESS_TABLE_PREFIX: wp_
WORDPRESS_DEBUG: "false"
# Simulated latency in milliseconds (configurable)
WPCOM_SIMULATED_LATENCY_MS: ${WPCOM_SIMULATED_LATENCY_MS:-200}
volumes:
- wp_jetpack_connected:/var/www/html
- ../build/jetpack:/var/www/html/wp-content/plugins/jetpack:ro
# Mount the mu-plugin for connection simulation
- ./mu-plugins:/var/www/html/wp-content/mu-plugins:ro
networks:
- jetpack-perf
depends_on:
db:
condition: service_healthy

# WP-CLI for setup operations
wpcli:
image: wordpress:cli-2.10-php8.2
user: "33:33" # Match www-data UID from WordPress Debian image
volumes:
- wp_jetpack_connected:/var/www/html/jetpack-connected
- ./setup-wordpress.sh:/usr/local/bin/setup-wordpress.sh:ro
- ../build/jetpack:/var/www/html/jetpack-connected/wp-content/plugins/jetpack:ro
- ./mu-plugins:/var/www/html/jetpack-connected/wp-content/mu-plugins:ro
networks:
- jetpack-perf
depends_on:
db:
condition: service_healthy
wordpress-jetpack-connected:
condition: service_started
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: rootpassword
WP_ADMIN_USER: ${WP_ADMIN_USER:-admin}
WP_ADMIN_PASS: ${WP_ADMIN_PASS:-password}
WP_ADMIN_EMAIL: ${WP_ADMIN_EMAIL:-admin@example.com}
# Run setup and exit
command: ["sh", "/usr/local/bin/setup-wordpress.sh"]

networks:
jetpack-perf:
driver: bridge

volumes:
db_data:
wp_jetpack_connected:
6 changes: 6 additions & 0 deletions tools/performance/docker/init-databases.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- Initialize database for Jetpack connected WordPress instance
CREATE DATABASE IF NOT EXISTS wp_jetpack_connected;

-- Grant permissions
GRANT ALL PRIVILEGES ON wp_jetpack_connected.* TO 'root'@'%';
FLUSH PRIVILEGES;
Loading
Loading