Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
Makefile export-ignore
patches.lock.json export-ignore
/phpbench.json export-ignore
/bench/ export-ignore
109 changes: 109 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Benchmark

on:
workflow_dispatch:
inputs:
runs:
description: Repetitions of the whole matrix
required: false
default: '1'
pull_request:
paths:
- 'src/**'
- 'core/**'
- 'bench/**'
- 'composer.json'
- '.github/workflows/benchmark.yml'

permissions:
contents: read

concurrency:
cancel-in-progress: true
group: benchmark-${{ github.ref }}

jobs:
benchmark:
permissions:
contents: read
name: RoadRunner vs sdk-core
runs-on: ubuntu-latest
timeout-minutes: 60
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
XDEBUG_MODE: off
TEMPORAL_ADDRESS: 127.0.0.1:7557
steps:
- name: Check Out Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6

- name: Setup PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: 8.4
extensions: dom, sockets, curl, protobuf, ffi, pcntl, posix
ini-values: opcache.enable_cli=1

- name: Install dependencies with composer
uses: ramsey/composer-install@5c2bcf28d7b060ef3c601d7b476d5430a7b46c27 # v4

- name: Download binaries
run: composer get:binaries

- name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler libprotobuf-dev

- name: Cache the bridge build
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: |
~/.cargo/registry
~/.cargo/git
core/bridge/target
key: bridge-${{ runner.os }}-${{ hashFiles('core/bridge/Cargo.lock', 'core/bridge/src/**', 'core/bridge/build.rs') }}
restore-keys: bridge-${{ runner.os }}-

- name: Build the sdk-core bridge
run: cargo build --release --lib --manifest-path core/bridge/Cargo.toml

- name: Start the Temporal server
run: |
docker compose -f bench/server/compose.yaml up -d
for i in $(seq 1 60); do
./temporal operator namespace describe default --address "$TEMPORAL_ADDRESS" >/dev/null 2>&1 && exit 0
sleep 2
done
docker compose -f bench/server/compose.yaml logs
exit 1

- name: Run the benchmark matrix
timeout-minutes: 45
run: bench/matrix.sh
env:
BENCH_RUNS: ${{ inputs.runs || '1' }}
BENCH_TIMEOUT: 180
BENCH_RUN_TIMEOUT: 420
BENCH_RESULTS: ${{ github.workspace }}/bench/matrix.jsonl

- name: Print results
if: always()
run: |
{
echo "## Worker benchmark: RoadRunner vs sdk-core"
echo
echo "Runner: $(nproc) CPU, $(free -g | awk '/Mem/ {print $2}') GB, PHP $(php -r 'echo PHP_VERSION;'). The Temporal server runs on the same runner, compare the rows with each other only."
echo
bench/summary.sh bench/matrix.jsonl
} | tee -a "$GITHUB_STEP_SUMMARY"

- name: Upload raw results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: benchmark-results
path: bench/matrix.jsonl
if-no-files-found: ignore

- name: Stop the Temporal server
if: always()
run: docker compose -f bench/server/compose.yaml down
134 changes: 134 additions & 0 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Core transport

on:
push:
paths:
- 'src/**'
- 'testing/**'
- 'tests/**'
- 'core/**'
- 'composer.json'
- 'phpunit.xml.dist'
- '.github/workflows/core.yml'
pull_request:
paths:
- 'src/**'
- 'testing/**'
- 'tests/**'
- 'core/**'
- 'composer.json'
- 'phpunit.xml.dist'
- '.github/workflows/core.yml'

permissions:
contents: read

concurrency:
cancel-in-progress: true
group: core-${{ github.ref }}

env:
CARGO_TERM_COLOR: never
BRIDGE_MANIFEST: core/bridge/Cargo.toml

jobs:
bridge:
name: Bridge (Rust)
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Check Out Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6

- name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler libprotobuf-dev

- name: Cache the bridge build
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: |
~/.cargo/registry
~/.cargo/git
core/bridge/target
key: bridge-checks-${{ runner.os }}-${{ hashFiles('core/bridge/Cargo.lock', 'core/bridge/src/**', 'core/bridge/build.rs') }}
restore-keys: bridge-checks-${{ runner.os }}-

- name: Format
run: cargo fmt --manifest-path "$BRIDGE_MANIFEST" -- --check

- name: Clippy
run: cargo clippy --release --all-targets --manifest-path "$BRIDGE_MANIFEST" -- -D warnings

- name: Unit tests
run: cargo test --release --lib --manifest-path "$BRIDGE_MANIFEST"

- name: The generated header matches the sources
run: |
cargo build --release --lib --manifest-path "$BRIDGE_MANIFEST"
git diff --exit-code core/bridge/include

php:
name: PHP ${{ matrix.php }} on sdk-core, ${{ matrix.suite }}
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- { suite: core, php: '8.2' }
- { suite: core, php: '8.4' }
- { suite: functional, php: '8.4' }
- { suite: functional-timeskip, php: '8.4' }
- { suite: acceptance, php: '8.4' }
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TEMPORAL_HEADLESS: true
TEMPORAL_WORKER_TRANSPORT: core
XDEBUG_MODE: off
steps:
- name: Check Out Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6

- name: Setup PHP without ext-grpc
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: ${{ matrix.php }}
extensions: dom, sockets, curl, protobuf, ffi, pcntl, posix, :grpc

- name: Install dependencies with composer
uses: ramsey/composer-install@5c2bcf28d7b060ef3c601d7b476d5430a7b46c27 # v4

- name: Download binaries
run: composer get:binaries

- name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler libprotobuf-dev

- name: Cache the bridge build
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: |
~/.cargo/registry
~/.cargo/git
core/bridge/target
key: bridge-${{ runner.os }}-${{ hashFiles('core/bridge/Cargo.lock', 'core/bridge/src/**', 'core/bridge/build.rs') }}
restore-keys: bridge-${{ runner.os }}-

- name: Build the sdk-core bridge
run: cargo build --release --lib --manifest-path "$BRIDGE_MANIFEST"

- name: Unit and native tests
if: matrix.suite == 'core'
run: tests/runner.php vendor/bin/phpunit --testsuite=Core --color=always --testdox

- name: Functional
if: matrix.suite == 'functional'
run: composer test:func

- name: Functional with time skipping
if: matrix.suite == 'functional-timeskip'
run: composer test:func-timeskip

- name: Acceptance
if: matrix.suite == 'acceptance'
run: vendor/bin/phpunit --testsuite=Acceptance --testdox
2 changes: 1 addition & 1 deletion .github/workflows/run-test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: ${{ matrix.php }}
extensions: dom, sockets, grpc, curl ${{ matrix.extensions-suffix }}
extensions: dom, sockets, grpc, curl, ffi ${{ matrix.extensions-suffix }}

- name: Validate composer.json and composer.lock
run: composer validate --strict
Expand Down
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
return \Spiral\CodeStyle\Builder::create()
->include(__DIR__ . '/src')
->include(__DIR__ . '/testing/src')
->include(__DIR__ . '/core/grpc')
->include(__FILE__)
->allowRisky(true)
->build();
3 changes: 3 additions & 0 deletions bench/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
results.jsonl
matrix.jsonl
rusage
28 changes: 28 additions & 0 deletions bench/.rr.core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: "3"

rpc:
listen: tcp://127.0.0.1:6556

kv:
bench:
driver: memory
config: {}

service:
workflow:
command: "php -dopcache.enable_cli=1 -dxdebug.mode=off -dpcov.enabled=0 worker.php"
process_num: ${BENCH_WORKFLOW_WORKERS}
remain_after_exit: true
restart_sec: 1
env:
TEMPORAL_CORE_ROLE: workflow
activity:
command: "php -dopcache.enable_cli=1 -dxdebug.mode=off -dpcov.enabled=0 worker.php"
process_num: ${BENCH_ACTIVITY_WORKERS}
remain_after_exit: true
restart_sec: 1
env:
TEMPORAL_CORE_ROLE: activity

logs:
level: error
12 changes: 12 additions & 0 deletions bench/.rr.kv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3"

rpc:
listen: tcp://127.0.0.1:6556

kv:
bench:
driver: memory
config: {}

logs:
level: error
21 changes: 21 additions & 0 deletions bench/.rr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: "3"

rpc:
listen: tcp://127.0.0.1:6556

server:
command: "php -dopcache.enable_cli=1 -dxdebug.mode=off -dpcov.enabled=0 worker.php"

temporal:
address: ${TEMPORAL_ADDRESS}
namespace: default
activities:
num_workers: ${BENCH_ACTIVITY_WORKERS}

kv:
bench:
driver: memory
config: {}

logs:
level: error
19 changes: 19 additions & 0 deletions bench/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

require __DIR__ . '/../vendor/autoload.php';

function benchEnv(string $name): string
{
$value = \getenv($name);
if ($value === false || $value === '') {
throw new \RuntimeException("$name is not set, run the benchmark through bench/run.sh or set it");
}

return $value;
}

foreach (\glob(__DIR__ . '/src/*.php') as $file) {
require_once $file;
}
32 changes: 32 additions & 0 deletions bench/matrix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -u
cd "$(dirname "$0")"
export BENCH_RESULTS=${BENCH_RESULTS:-$PWD/matrix.jsonl}
FAILED=0
run() {
echo "::group::${BENCH_LABEL:-$2} $3 $4 $5 $6 ${BENCH_RATE:+@${BENCH_RATE}/s}"
local code=0
timeout --kill-after=15 "${BENCH_RUN_TIMEOUT:-600}" "$@" 2>&1 || code=$?
echo "::endgroup::"
if [ "$code" -ne 0 ]; then
echo "FAILED ($code): $*"
FAILED=1
fi
}
for r in $(seq 1 "${BENCH_RUNS:-2}"); do
for t in rr rr-core; do
run ./run.sh $t seq 1000 1 100
run ./run.sh $t seq 200 10 100
run ./run.sh $t noact 2000 0 100
run ./run.sh $t par 100 20 100
BENCH_RATE=50 run ./run.sh $t seq 1000 1 100
BENCH_RATE=100 run ./run.sh $t seq 1000 1 100
BENCH_RATE=100 run ./run.sh $t noact 1000 0 100
run ./run.sh $t io 100 10 100
run ./run.sh $t cpu 300 1 5
done
BENCH_LABEL=core-4wf BENCH_WORKFLOW_WORKERS=4 run ./run.sh rr-core cpu 300 1 5
BENCH_LABEL=core-4wf BENCH_WORKFLOW_WORKERS=4 run ./run.sh rr-core noact 2000 0 100
done
echo MATRIX DONE
exit $FAILED
Loading
Loading