test(core): add ASV performance benchmarks for core module #10961

Merged
HAL9000 merged 3 commits from test/core-asv-benchmarks into master 2026-05-08 14:21:42 +00:00

3 Commits

Author SHA1 Message Date
HAL9000 7688f96cd3 test(core): fix ASV benchmark timing methodology and remove unused imports
CI / benchmark-publish (pull_request) Has been skipped
CI / helm (pull_request) Successful in 43s
CI / push-validation (pull_request) Successful in 45s
CI / lint (pull_request) Successful in 1m6s
CI / build (pull_request) Successful in 1m5s
CI / quality (pull_request) Successful in 1m30s
CI / typecheck (pull_request) Successful in 1m39s
CI / benchmark-regression (pull_request) Failing after 1m35s
CI / security (pull_request) Successful in 1m50s
CI / integration_tests (pull_request) Successful in 3m45s
CI / e2e_tests (pull_request) Successful in 4m33s
CI / unit_tests (pull_request) Successful in 7m22s
CI / docker (pull_request) Successful in 2m3s
CI / coverage (pull_request) Successful in 14m50s
CI / status-check (pull_request) Successful in 8s
- Remove unused `from typing import Any` import from core_retry_patterns_bench.py
- Refactor CircuitBreakerStateTransitionBench into three separate benchmark classes (CircuitBreakerClosedToOpenTransitionBench, CircuitBreakerOpenToHalfOpenTransitionBench, CircuitBreakerHalfOpenToClosedTransitionBench), each with a proper setup() method that pre-creates the CircuitBreaker in the correct initial state so only the transition itself is measured
- Move open-state CircuitBreaker creation for async fast-fail benchmark into setup() in CircuitBreakerAsyncBench, eliminating instance creation overhead from the timed method

Addresses reviewer feedback on PR #10961.
2026-05-08 13:11:16 +00:00
HAL9000 e776761ba7 fix(bench): correct API usage and formatting in core ASV benchmark files
- Fix get_retry_decorator() calls to use category string instead of
  keyword arguments (max_attempts, base_delay, etc.)
- Fix retry_on_result() calls to pass required predicate argument
- Fix retry_service_operation() to use circuit_breaker= (CircuitBreaker
  instance) instead of use_circuit_breaker= (bool), and backoff_strategy=
  instead of wait_strategy=
- Fix is_read_only_plan_operation() calls to pass dict instead of string
- Fix RetryContext() to use operation_name= instead of service_name=,
  remove non-existent use_circuit_breaker and attempt_count constructor params
- Fix retry_auto_debug() to use max_debug_attempts= instead of
  service_name=/operation_name= (which are not valid parameters)
- Remove unused Any import from core_circuit_breaker_bench.py
- Apply ruff format to all three benchmark files to fix CI format check
2026-05-08 13:11:16 +00:00
HAL9000 8c408bffe4 test(core): add ASV performance benchmarks for core module
Added three new ASV benchmark suites for the core module:

1. core_circuit_breaker_bench.py - Benchmarks for CircuitBreaker class:
   - Closed state call overhead
   - Open state fast-fail latency
   - State transition overhead (closed→open, open→half-open, half-open→closed)
   - Async operations
   - Initialization overhead

2. core_retry_patterns_bench.py - Benchmarks for retry decorators:
   - Decorator construction overhead for exponential backoff, jitter, timeout, and result-based retry
   - Happy-path invocation overhead
   - Async decorator operations
   - Decorator usage with function arguments
   - Factory function performance
   - Various configuration scenarios

3. core_retry_service_patterns_bench.py - Benchmarks for service-level retry:
   - retry_service_operation decorator construction and invocation
   - retry_auto_debug decorator performance
   - RetryContext operations
   - is_read_only_plan_operation utility
   - Different wait strategies (exponential, linear, fixed, jitter)

These benchmarks ensure latency regressions in core resilience primitives are caught early.

ISSUES CLOSED: #1921
2026-05-08 13:11:16 +00:00