Skip to content

Conversation

@deanq
Copy link
Member

@deanq deanq commented Nov 18, 2025

Performance benchmarking tools for measuring and comparing cold start times across different code changes.

Instructions inside scripts/README.md

Add comprehensive tooling to measure and compare cold start performance
across different branches and code changes.

Changes:
- Add test_cold_start.py: measures import times, module counts, and lazy
  loading status with 10 iterations per measurement
- Add benchmark_cold_start.sh: automates running benchmarks on different
  git branches with stash/restore logic
- Add compare_benchmarks.py: analyzes and visualizes differences between
  two benchmark runs with colored output
- Add benchmark_results/ to .gitignore: exclude generated JSON data

The benchmark suite validates:
- Import time for runpod, runpod.serverless, and runpod.endpoint
- Total module count and runpod-specific module count
- Whether paramiko and SSH CLI modules are eagerly or lazy-loaded
- Performance regression detection (fails if import > 1000ms)

Usage:
  # Run on current branch
  uv run pytest tests/test_performance/test_cold_start.py

  # Compare two branches
  ./scripts/benchmark_cold_start.sh main feature-branch

Results saved to benchmark_results/ as timestamped JSON files for
historical comparison and CI/CD integration.
Add detailed README for cold start benchmarking tools covering:
- Quick start examples for common use cases
- Tool documentation with usage patterns and output examples
- Result file structure and naming conventions
- Performance targets and interpretation guidance
- CI/CD integration examples
- Troubleshooting common issues

The guide enables developers to effectively measure, compare, and
validate cold start performance improvements across code changes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a comprehensive cold start benchmarking infrastructure to measure and compare import performance of the runpod package across different branches and code changes. The tooling helps identify performance regressions and validate optimizations like lazy loading.

Key changes:

  • Adds automated benchmarking test suite for measuring import times, module counts, and lazy loading behavior
  • Provides comparison tooling with visual diff output to analyze performance changes between branches
  • Includes shell automation for branch-based benchmarking with safe git operations

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_performance/test_cold_start.py Core benchmark implementation measuring import times in isolated subprocesses with statistical analysis
tests/test_performance/init.py Package initialization for performance test module
scripts/compare_benchmarks.py Analysis tool comparing two benchmark results with colored terminal output
scripts/benchmark_cold_start.sh Shell automation for running benchmarks across git branches with safe state management
scripts/README.md Comprehensive documentation of benchmarking tools, workflows, and performance targets

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Address code review feedback from PR #467:

1. Fix median calculation for even-length lists
   - Previously only returned single middle value
   - Now correctly averages the two middle values for even-length lists
   - Maintains correct behavior for odd-length lists

2. Update usage message to match documented pattern
   - Changed from "python" to "uv run python scripts/..."
   - Aligns with project's uv-based tooling conventions
   - Matches usage examples in README and throughout codebase

These fixes improve statistical accuracy and documentation consistency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants