:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(devex): average the product durations slice over recent runs (#105716)
Julian Beza8d212ad254b
diff --git a/.github/workflows/ci-backend-update-test-timing.yml b/.github/workflows/ci-backend-update-test-timing.ymlindex 7de9d23d7dfd..58240ecabd90 100644--- a/.github/workflows/ci-backend-update-test-timing.yml+++ b/.github/workflows/ci-backend-update-test-timing.yml@@ -29,7 +29,7 @@ jobs:collect-and-merge:name: Collect timing data from CI artifactsruns-on: depot-ubuntu-24.04- timeout-minutes: 10+ timeout-minutes: 15steps:- name: Get app tokenid: app-token@@ -74,11 +74,12 @@ jobs:# Only consider runs from the past 14 days to ensure artifacts haven't expiredecho "Searching for Backend CI runs with timing artifacts..."- # The per-segment file-mode plan (.test_durations.core/.temporal) is averaged over- # the last N runs to damp one run's timing noise (~-8pp makespan/mean on real PRs,- # 1 -> 5 runs; the achievable floor is ~0%). The union .test_durations and the- # JUnit de-tax still use the newest run alone (the primary). N stays small so the- # extra downloads stay modest.+ # The per-segment file-mode plans (.test_durations.core/.temporal) and the+ # products slice of the union are averaged over the last N runs to damp one+ # run's timing noise (~-8pp makespan/mean on real PRs, 1 -> 5 runs; the+ # achievable floor is ~0%). The rest of the union .test_durations and the JUnit+ # de-tax still use the newest run alone (the primary). N stays small because+ # every extra run downloads its product timing artifacts, the largest set.N="${BACKEND_RUNS_TO_AVERAGE:-5}"# Guard a mis-set variable: a non-integer would make the `-ge` test below error# out (never breaking the loop) and silently average every candidate run.@@ -215,7 +216,7 @@ jobs:echo "::warning::No JUnit artifacts found — falling back to statistical carrier detection"# Multi-run: pull timing + JUnit for each run we average into the per-segment- # file-mode plan (Core/Temporal only). Each run is de-taxed + scoped on its own+ # file-mode plans and the products slice. Each run is de-taxed + scoped on its own# below, then averaged. The primary is also downloaded here (into its own dir) so# the union/JUnit steps above stay untouched. A run with no JUnit just gets its# per-segment slice skipped, same fallback as the single-run path.@@ -228,6 +229,15 @@ jobs:--pattern "junit-results-backend-core-*" \--pattern "junit-results-backend-temporal-*" \--dir "runs/$rid/junit" || echo "::warning::No JUnit for run $rid — its per-segment slice is skipped"+ # The primary's Products artifacts are already in timing_artifacts and+ # junit_artifacts. Product timing artifacts are the largest set, so do not+ # download them twice.+ if [ "$rid" != "$BACKEND_RUN_ID" ]; then+ gh run download "$rid" --pattern "timing_data-Products-*" --dir "runs/$rid/timing" \+ || echo "::warning::No Products timing for run $rid — its products slice is skipped"+ gh run download "$rid" --pattern "product-junit-results-*" --dir "runs/$rid/junit" \+ || echo "::warning::No Products JUnit for run $rid — its products slice is skipped"+ fidone# Download dagster timing artifacts if available@@ -245,6 +255,7 @@ jobs:- name: Process timing dataenv:DAGSTER_RUN_ID: ${{ steps.find-dagster-run.outputs.run_id }}+ BACKEND_RUN_ID: ${{ steps.find-backend-run.outputs.run_id }}BACKEND_RUN_IDS: ${{ steps.find-backend-run.outputs.run_ids }}run: |# Process each segment separately with migration tax correction, then merge.@@ -295,6 +306,26 @@ jobs:echo "::error::Products slice failed with no previous map to stand in; refusing to publish a map without product entries"exit 1fi+ else+ # Split product shards plan from this slice, so average it over the same runs+ # as the per-segment plans below. Each older run goes through the same drift+ # check as the newest one, and a run that fails it stays out of the average.+ # The newest slice goes first because it anchors which tests the average keeps.+ products_files="/tmp/products_durations"+ for rid in $BACKEND_RUN_IDS; do+ if [ "$rid" = "$BACKEND_RUN_ID" ]; then+ continue+ fi+ if uv run .github/scripts/optimize_test_durations.py "runs/$rid/timing" "/tmp/products_$rid" \+ --segment Products --junit-dir "runs/$rid/junit" --fail-on-drift; then+ products_files="$products_files /tmp/products_$rid"+ fi+ done+ if uv run .github/scripts/optimize_test_durations.py /tmp/products_averaged --average-files $products_files; then+ mv /tmp/products_averaged /tmp/products_durations+ else+ echo "::warning::Products multi-run average failed, keeping the newest run's slice"+ fifi# Process Dagster segment if available@@ -361,7 +392,7 @@ jobs:# Also drop timing/JUnit download dirs (incl. the per-run runs/ tree) so the# artifact upload below only sees the merged files.- rm -rf timing_artifacts junit_artifacts runs /tmp/core_* /tmp/temporal_* /tmp/products_durations /tmp/dagster_durations+ rm -rf timing_artifacts junit_artifacts runs /tmp/core_* /tmp/temporal_* /tmp/products_* /tmp/dagster_durations- name: Compute the cache keyid: durations-meta