Skip to content
Merged
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
108 changes: 108 additions & 0 deletions .github/workflows/session-benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Session Benchmarks

on:
pull_request:
branches:
- main
- release*
- release/*
- release-*
schedule:
- cron: "23 7 * * 2"
workflow_dispatch:
inputs:
mode:
description: Workload size
required: true
default: stress
type: choice
options:
- fast
- stress

permissions:
contents: read

jobs:
session:
name: ${{ github.event_name == 'pull_request' && 'Fast' || inputs.mode || 'Stress' }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
env:
CARGO_TARGET_DIR: ${{ github.workspace }}/.target-session-benchmarks
PET_SESSION_STRESS: ${{ (github.event_name == 'schedule' || inputs.mode == 'stress') && '1' || '' }}
RUST_BACKTRACE: 1
RUST_LOG: warn
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set up Python fixture
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Test session metrics parser
run: python -B -m unittest scripts.tests.test_session_metrics -v

- name: Run session benchmark
id: benchmark
timeout-minutes: 35
run: |
mode=fast
if [ "${PET_SESSION_STRESS}" = "1" ]; then
mode=stress
fi

set +e
cargo test --release --features ci-perf -p pet --test session_performance long_lived_session_benchmark -- --nocapture 2>&1 | tee session-output.txt
benchmark_status=${PIPESTATUS[0]}
python -B scripts/session_metrics.py extract \
--input session-output.txt \
--output session-metrics.json \
--benchmark-status "$benchmark_status" \
--mode "$mode"
metrics_status=$?
set -e
rm -f session-output.txt
if [ "$benchmark_status" -ne 0 ]; then
exit "$benchmark_status"
fi
exit "$metrics_status"
shell: bash

- name: Ensure failure metrics
if: always()
run: |
mode=fast
if [ "${PET_SESSION_STRESS}" = "1" ]; then
mode=stress
fi
python -B scripts/session_metrics.py ensure-failure \
--output session-metrics.json \
--mode "$mode" \
--reason benchmark-timeout-or-interruption
rm -f session-output.txt
shell: bash

- name: Upload session metrics
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: session-metrics-${{ matrix.os }}
path: session-metrics.json
if-no-files-found: error
30 changes: 30 additions & 0 deletions crates/pet/tests/fixtures/session_sitecustomize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import os
from pathlib import Path
import sys
import time


barrier = os.environ.get("PET_SESSION_RESOLVE_BARRIER")
resolve_root = os.environ.get("PET_SESSION_RESOLVE_ROOT")
if barrier and resolve_root:
prefix = os.path.normcase(os.path.realpath(sys.prefix))
root_prefix = os.path.normcase(os.path.realpath(resolve_root)) + os.sep
if not prefix.startswith(root_prefix):
barrier = None
else:
barrier = None

if barrier:
root = Path(barrier)
(root / f"entered-{os.getpid()}").write_text("entered", encoding="ascii")
deadline = time.monotonic() + 20
release = root / "release"
while not release.exists():
if time.monotonic() >= deadline:
(root / f"failed-{os.getpid()}").write_text("timeout", encoding="ascii")
os._exit(86)
time.sleep(0.005)
(root / f"released-{os.getpid()}").write_text("released", encoding="ascii")
Loading
Loading