Three private tiles in the codeflash workspace: - codeflash-rules: 6 steering rules (code-style, architecture, optimization-patterns, git-conventions, testing-rules, language-rules) - codeflash-docs: 7 doc pages (domain-types, optimization-pipeline, context-extraction, verification, ai-service, configuration) - codeflash-skills: 2 skills (debug-optimization-failure, add-codeflash-feature)
2.4 KiB
2.4 KiB
Codeflash Internal Documentation
CodeFlash is an AI-powered Python code optimizer that automatically improves code performance while maintaining correctness. It uses LLMs to generate optimization candidates, verifies correctness through test execution, and benchmarks performance improvements.
Pipeline Overview
Discovery → Ranking → Context Extraction → Test Gen + Optimization → Baseline → Candidate Evaluation → PR
- Discovery (
discovery/): Find optimizable functions across the codebase usingFunctionVisitor - Ranking (
benchmarking/function_ranker.py): Rank functions by addressable time using trace data - Context (
context/): Extract code dependencies — split into read-writable (modifiable) and read-only (reference) - Optimization (
optimization/,api/): Generate candidates via AI service, runs concurrently with test generation - Verification (
verification/): Run candidates against tests via custom pytest plugin, compare outputs - Benchmarking (
benchmarking/): Measure performance, select best candidate by speedup - Result (
result/,github/): Create PR with winning optimization
Key Entry Points
| Task | File |
|---|---|
| CLI arguments & commands | cli_cmds/cli.py |
| Optimization orchestration | optimization/optimizer.py → Optimizer.run() |
| Per-function optimization | optimization/function_optimizer.py → FunctionOptimizer |
| Function discovery | discovery/functions_to_optimize.py |
| Context extraction | context/code_context_extractor.py |
| Test execution | verification/test_runner.py, verification/pytest_plugin.py |
| Performance ranking | benchmarking/function_ranker.py |
| Domain types | models/models.py, models/function_types.py |
| AI service | api/aiservice.py → AiServiceClient |
| Configuration | code_utils/config_consts.py |
Documentation Pages
- Domain Types — Core data types and their relationships
- Optimization Pipeline — Step-by-step data flow through the pipeline
- Context Extraction — How code context is extracted and token-limited
- Verification — Test execution, pytest plugin, deterministic patches
- AI Service — AI service client endpoints and request types
- Configuration — Config schema, effort levels, thresholds