Skip to main content

AI tool to connect Redis OSS source code, benchmarks, and profiling data. Includes GitHub PR performance analyzer, function analysis service, and profiling analysis system.

Project description

RedOpt

AI tool to connect source code, benchmarks, and profiling data. Includes a GitHub PR performance analyzer, Function Analysis Service, and Profiling Analysis System.

Features

  • ๐Ÿค– OpenAI Agent Integration: Built using OpenAI's Agent framework
  • ๐Ÿ“Š Performance Analysis: Analyzes GitHub PRs for performance improvements and regressions
  • ๐Ÿ” Redis Focus: Specifically designed for Redis performance analysis
  • โš™๏ธ Simple Configuration: Easy setup with environment variables
  • ๐Ÿง  Function Analysis Service: Complete C/C++ function analysis with LLVM/Clang AST parsing, graph embeddings, call tree analysis, and semantic similarity search
  • ๐Ÿ”ฅ Real pprof Profiling Analysis: Parse binary pprof files with precise CPU percentages, function-level performance data, and command impact analysis
  • ๐Ÿ’ฌ Single Question Mode: Ask performance questions directly via CLI: redopt chat "question"
  • ๐Ÿ—„๏ธ SQLite Performance Database: Lightweight, efficient storage for profiling data with flat/cumulative CPU percentages
  • ๐Ÿ”— Multiple Interfaces: AI agent tools, REST API, and interactive chat interface
  • ๐Ÿ“ข Slack Notifications: Automatic alerts for significant performance impacts via webhook integration

Architecture Overview

                    Redis Code Analyzer Architecture

    Input Sources              Processing Pipeline           User Interfaces
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚ Project     โ”‚โ”€โ”€indexโ”€โ”€โ”€โ–ถโ”‚                     โ”‚       โ”‚ ๐Ÿค– AI Chat  โ”‚
    โ”‚ Source Code โ”‚           โ”‚   LLVM/Clang        โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚ Agent       โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜           โ”‚   Parser            โ”‚       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚         โ”‚           โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”           โ”‚         โ–ผ           โ”‚       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚ C/C++       โ”‚โ”€analyzeโ”€โ”€โ–ถโ”‚   Graph Converter   โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚ ๐ŸŒ REST API โ”‚
    โ”‚ Functions   โ”‚           โ”‚         โ”‚           โ”‚       โ”‚ Server      โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜           โ”‚         โ–ผ           โ”‚       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚   Graph2Vec         โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”           โ”‚   Encoder           โ”‚       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚ GitHub      โ”‚โ”€โ”€PRโ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚         โ”‚           โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚ ๐Ÿ“Š GitHub   โ”‚
    โ”‚ PR URLs     โ”‚           โ”‚         โ–ผ           โ”‚       โ”‚ PR Analyzer โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                        โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚ Benchmark   โ”‚โ”€โ”€parseโ”€โ”€โ”€โ–ถโ”‚                   โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚ ๐Ÿ”ฅ Profilingโ”‚
    โ”‚ YAML Files  โ”‚           โ”‚  Perf Script      โ”‚         โ”‚ Analysis    โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜           โ”‚  Parser           โ”‚         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚         โ”‚         โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”           โ”‚         โ–ผ         โ”‚         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚ Perf Script โ”‚โ”€profileโ”€โ”€โ–ถโ”‚  Hotspot Analysis โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚ ๐Ÿ“ˆ Command  โ”‚
    โ”‚ Data        โ”‚           โ”‚  & Command        โ”‚         โ”‚ Group       โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜           โ”‚  Group Mapping    โ”‚         โ”‚ Mapping     โ”‚
                              โ”‚         โ”‚         โ”‚
                              โ”‚         โ–ผ         โ”‚
                              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                        โ”‚
                                        โ–ผ
                              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                              โ”‚   Redis Database    โ”‚
                              โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
                              โ”‚   โ”‚ Functions   โ”‚   โ”‚
                              โ”‚   โ”‚ Embeddings  โ”‚   โ”‚
                              โ”‚   โ”‚ Metadata    โ”‚   โ”‚
                              โ”‚   โ”‚ Profiles    โ”‚   โ”‚
                              โ”‚   โ”‚ Hotspots    โ”‚   โ”‚
                              โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
                              โ”‚         โ”‚           โ”‚
                              โ”‚         โ–ผ           โ”‚
                              โ”‚   Vector Search     โ”‚
                              โ”‚   (Similarity)      โ”‚
                              โ”‚   RediSearch        โ”‚
                              โ”‚   (Profiling)       โ”‚
                              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

    Flow 1: Source Code โ†’ Clang AST โ†’ Graphs โ†’ Embeddings โ†’ Redis โ†’ Search
    Flow 2: GitHub PR โ†’ Analysis โ†’ Performance Impact โ†’ Results
    Flow 3: Benchmark YAML + Perf Data โ†’ Hotspots โ†’ Command Mapping โ†’ Redis

Data Flow Explanation

  1. ๐Ÿ“ฅ Input Processing:

    • Codebase Indexing: Redis source code โ†’ LLVM/Clang parser
    • Interactive Analysis: User provides C/C++ functions โ†’ Direct analysis
    • PR Analysis: GitHub URLs โ†’ Performance-focused analysis
    • Profiling Analysis: Benchmark YAML + Perf script data โ†’ Hotspot analysis
    • Chat Queries: Natural language โ†’ AI agent processing
  2. โš™๏ธ Core Analysis Pipelines:

    Function Analysis Pipeline:

    • AST Generation: LLVM/Clang extracts Abstract Syntax Trees
    • Graph Conversion: ASTs transformed to NetworkX graph structures
    • Vector Encoding: Graph2Vec generates semantic embeddings
    • Complexity Analysis: Cyclomatic complexity calculation

    Profiling Analysis Pipeline:

    • Benchmark Parsing: YAML benchmark definitions โ†’ structured metadata
    • Perf Script Parsing: Collapsed stack format โ†’ call stacks and hotspots
    • Command Mapping: Functions โ†’ Redis commands โ†’ command groups
    • Hotspot Analysis: Sample counts โ†’ percentage coverage โ†’ performance impact
  3. ๐Ÿ—„๏ธ Storage & Retrieval:

    • Redis Database: Stores function metadata, graphs, embeddings, profiles, and hotspots
    • Vector Search: Cosine similarity for semantic function matching
    • RediSearch: Full-text and structured search for profiling data
    • JSON Backup: File-based storage for offline analysis
  4. ๐Ÿ”Œ User Interfaces:

    • AI Chat Agent: Conversational interface with function analysis and profiling tools
    • REST API: Programmatic access for integration
    • PR Analyzer: Specialized GitHub PR performance analysis
    • Profiling Dashboard: Command group performance analysis

Key Components

๐Ÿ”ง Function Analysis Tools

  • analyze_function_code(): Parse and analyze C/C++ functions using LLVM/Clang
  • find_similar_functions_by_id(): Semantic similarity search using Graph2Vec embeddings
  • search_functions_by_name(): Name-based function lookup in the pre-indexed Redis database
  • find_function_callers() / find_function_callees(): Call tree analysis for function relationships
  • find_redis_commands_using_function(): Map functions to Redis commands
  • check_function_database_status(): System health and statistics

๐Ÿ”ฅ Profiling Analysis Tools

  • get_function_performance_hotspots(): Find performance hotspots for specific functions
  • get_commands_affected_by_function(): See which Redis commands use a function
  • get_top_performance_hotspots(): Get overall performance hotspots across all benchmarks
  • get_hotspots_by_command_group(): Get hotspots for specific command groups (sorted-set, string, etc.)
  • search_performance_functions(): Search functions in performance profiling data
  • get_profiling_database_status(): Check profiling database status and statistics

๐Ÿ“Š Processing Pipeline

  • LLVM/Clang Parser: Industry-standard AST extraction from C/C++ code
  • Graph Converter: Transforms ASTs into NetworkX graph structures
  • Graph2Vec Encoder: Generates vector embeddings for semantic similarity
  • Perf Script Parser: Parses collapsed stack format from perf tools
  • Hotspot Analyzer: Maps call stacks to function performance metrics
  • Command Group Mapper: Links functions to Redis commands and command groups
  • Deduplication: Filters function declarations, keeps only implementations

๐Ÿ—„๏ธ Storage Layer

  • Redis Database: High-performance storage for functions, embeddings, and profiling data
  • Vector Search: Cosine similarity search on function embeddings
  • RediSearch: Full-text search on profiling data with command group indexing
  • JSON Files: Backup storage and offline analysis capability

๐Ÿค– AI Integration

  • Conversational Agent: Natural language interface for code and performance analysis
  • Function Tools: Automated function analysis and similarity search
  • Profiling Tools: Performance hotspot analysis and command group insights
  • Context Awareness: Maintains conversation history and context

Workflow Examples

๐Ÿ“š Indexing a Codebase

redopt index --source ~/redis/src --output ./functions

Flow: Redis Source โ†’ Clang Parser โ†’ Graph Converter โ†’ Graph2Vec โ†’ Redis Database

๐Ÿ”ฅ Indexing Profiling Data

Index real Redis performance profiling data from pprof files:

# Index profiling data with pprof support
redopt profile-index \
  --benchmark sample-inputs/benchmarks/memtier_benchmark-1Mkeys-generic-scan-count-500-pipeline-10.yml \
  --pprof sample-inputs/pprof/generic-scan-count-500-pipeline-10.pb.gz

# This will:
# โœ… Parse benchmark metadata (commands, command groups)
# โœ… Extract function performance data from pprof using 'pprof -top'
# โœ… Store flat and cumulative CPU percentages in SQLite
# โœ… Enable AI agent to answer performance questions

Flow: Benchmark YAML + pprof File โ†’ pprof Parser โ†’ Function Performance Data โ†’ SQLite Database

Real Output:

๐Ÿ”ฅ Starting profiling data indexing...
โœ… Loaded benchmark: memtier_benchmark-1Mkeys-generic-scan-count-500-pipeline-10
โœ… Parsed 50 profile entries from pprof
๐Ÿ“Š Top function: scanGenericCommand (83.01% cum)
โœ… Stored benchmark: generic-scan-count-500-pipeline-10 with 50 profile entries
๐ŸŽ‰ Profiling data indexing completed successfully!

๐Ÿ’ฌ Interactive Analysis

# Interactive chat mode
redopt chat
> Find functions similar to dictScan
> What are the hotspots for sorted-set commands?
> Which functions affect ZRANGE performance?

# Single question mode (NEW!)
redopt chat "What are the Redis functions that take more than 5% of CPU?"
redopt chat "What Redis commands are affected by the listDelNode function?"

Flow: Chat Query โ†’ AI Agent โ†’ Function/Profiling Tools โ†’ Vector/SQLite Search โ†’ Results

Real Examples:

$ redopt chat "What are the Redis functions that take more than 5% of CPU in the benchmark data?"
๐Ÿค– Redis Code Analyzer - Single Question Mode
==================================================
Question: What are the Redis functions that take more than 5% of CPU in the benchmark data?

๐Ÿค– Analyzing...
โœ… SQLite database initialized
โœ… Profiling service connected to SQLite

๐Ÿค– Answer:
The following Redis functions take more than 5% of CPU time based on benchmark data:

1. **dictScanDefragBucket**:
   - Flat CPU %: 11.03
   - Cumulative CPU %: 21.52

2. **_addReplyProtoToList**:
   - Flat CPU %: 6.75
   - Cumulative CPU %: 8.03

3. **[[kernel.kallsyms]_text]**:
   - Flat CPU %: 6.01
   - Cumulative CPU %: 6.67

4. **update_zmalloc_stat_alloc (inline)**:
   - Flat CPU %: 5.83
   - Cumulative CPU %: 6.24

5. **rev (inline)**:
   - Flat CPU %: 5.63
   - Cumulative CPU %: 5.66

6. **_addReplyToBufferOrList.part.0**:
   - Flat CPU %: 5.03
   - Cumulative CPU %: 5.09
$ redopt chat "What Redis commands are affected by the listDelNode function?"
๐Ÿค– Redis Code Analyzer - Single Question Mode
==================================================
Question: What Redis commands are affected by the listDelNode function?

๐Ÿค– Analyzing...
โœ… SQLite database initialized
โœ… Profiling service connected to SQLite

๐Ÿค– Answer:
The `listDelNode` function affects Redis commands in the `scan` command group, with a
performance impact estimated at about 7.53%. Specifically, it is part of the `generic`
command group.

๐Ÿ” Function Analysis

curl -X POST "localhost:8000/analyze" -d '{"code": "int func() {...}"}'

Flow: Function Code โ†’ Clang Parser โ†’ Graph Analysis โ†’ Similarity Search โ†’ JSON Response

๐Ÿ“ˆ Profiling Analysis

Query performance data directly via AI agent or programmatically:

# AI-powered performance analysis
redopt chat "What are the top 3 functions consuming the most CPU?"
redopt chat "Show me functions with more than 10% flat CPU usage"
redopt chat "Which functions are related to scanning operations?"

# Programmatic access via SQLite
sqlite3 profiling.db "SELECT function, flat_percent, cum_percent FROM profile_entries WHERE flat_percent > 5.0 ORDER BY cum_percent DESC"

Flow: Performance Query โ†’ SQLite Database โ†’ Function Data โ†’ CPU Percentages โ†’ Analysis Results

Installation

Prerequisites

  • Python 3.12 or higher
  • OpenAI API key
  • GitHub Personal Access Token

Install from PyPI

# Install redopt
pip install redopt

# Or with pipx for isolated installation
pipx install redopt

Install from Source with Poetry

# Clone the repository
git clone https://github.com/redis/redopt.git
cd redopt

# Install dependencies
poetry install

# Activate the virtual environment
poetry shell

Docker Setup (Recommended)

For the easiest setup, use Docker Compose to run Redis with all required modules:

# Start Redis with RedisJSON and RedisInsight
docker-compose up -d

# Check if Redis is running
docker-compose ps

# View Redis logs
docker-compose logs redis

# Stop Redis
docker-compose down

This will start:

  • Redis Stack on port 6379 (with RedisJSON, RedisSearch, and other modules)
  • RedisInsight web UI on port 8001 for database management

Access RedisInsight at: http://localhost:8001

Configuration

Create a .env file in your project root:

# Required
OPENAI_API_KEY=your_openai_api_key_here
GITHUB_TOKEN=your_github_personal_access_token_here

# Optional
OPENAI_MODEL=gpt-4o
OPENAI_BASE_URL=https://api.openai.com/v1
LOG_LEVEL=INFO
MAX_DIFF_LINES=1000
INCLUDE_COMMENTS=true
INCLUDE_REVIEWS=true

GitHub Token Setup

  1. Go to GitHub Settings โ†’ Developer settings โ†’ Personal access tokens
  2. Generate a new token with the most strict permissions

Usage

1. Codebase Indexing

Index an entire C/C++ codebase (like Redis) to extract and analyze all functions:

# Index Redis source code
redopt index \
  --source ~/redislabs/redis/src \
  --output ./redis_functions \
  --clang-path /usr/bin/clang \
  --include-dirs ~/redislabs/redis/src

# Alternative command
function-analysis-index index \
  --source ~/redislabs/redis/src \
  --output ./redis_functions

# Options:
#   --source: Source directory to index
#   --output: Output directory for JSON files
#   --clang-path: Path to clang executable
#   --include-dirs: Include directories for compilation
#   --extensions: File extensions to process (.c .cpp .h)
#   --no-recursive: Don't search subdirectories
#   --no-redis: Don't store in Redis
#   --no-json: Don't save JSON files
#   --redis-host: Redis host (default: localhost)
#   --redis-port: Redis port (default: 6379)

This will:

  • Parse all C/C++ files using LLVM/Clang
  • Extract function metadata, AST, and complexity
  • Generate Graph2Vec embeddings
  • Store results in Redis and/or JSON files
  • Create a summary with statistics

2. Profiling Data Indexing

Index Redis performance profiling data from pprof files:

# Index profiling data with pprof support
redopt profile-index \
  --benchmark sample-inputs/benchmarks/memtier_benchmark-1Mkeys-generic-scan-count-500-pipeline-10.yml \
  --pprof sample-inputs/pprof/generic-scan-count-500-pipeline-10.pb.gz

# Options:
#   --benchmark: YAML benchmark definition file
#   --pprof: Binary pprof file (.pb.gz format)
#   --output: Output directory (optional)
#   --db-path: SQLite database path (default: profiling.db)

# Batch processing multiple files
redopt profile-index \
  --benchmark-dir ./benchmarks \
  --pprof-dir ./pprof_files \
  --output ./profiling_results

This will:

  • Parse benchmark metadata (commands, command groups, descriptions)
  • Extract function performance data using pprof -top command
  • Store flat and cumulative CPU percentages in SQLite
  • Enable AI agent to answer performance questions
  • Create comprehensive profiling database

Sample Questions After Indexing:

# Performance analysis questions
redopt chat "What are the Redis functions that take more than 5% of CPU in the benchmark data?"
# Expected: "dictScanDefragBucket (11.03% flat, 21.52% cumulative), _addReplyProtoToList (6.75% flat, 8.03% cumulative)..."

redopt chat "What Redis commands are affected by the scanGenericCommand function?"
# Expected: "scanGenericCommand affects the SCAN command with 83.01% performance impact in the 'generic' command group"

redopt chat "Show me the top 3 functions consuming the most CPU"
# Expected: Ranked list of functions with their CPU percentages

redopt chat "What specific Redis command and command group are being tested in this benchmark?"
# Expected: Command and group information from benchmark metadata

3. Interactive AI Chat

Chat with the Redis Code Analyzer AI agent:

# Start interactive chat mode
redopt chat

# Single question mode (NEW!)
redopt chat "What are the Redis functions that take more than 5% of CPU?"
redopt chat "What Redis commands are affected by the scanGenericCommand function?"

# Examples of what you can do:
> Search for Redis functions by name: "find functions related to dict"
> Analyze this Redis function: int dictScan(dict *d, ...) { ... }
> Find functions similar to dictFind
> What Redis commands use the dictFind function?
> What are the performance implications of this code change?
> Show me statistics about the function database
> Analyze GitHub PR: https://github.com/redis/redis/pull/14108
> What are the top 3 functions consuming the most CPU?
> Show me the benchmark database status

The AI agent can:

  • Search the pre-indexed Redis codebase (7,000+ functions)
  • Analyze C/C++ function code automatically using LLVM/Clang
  • Find semantically similar functions using Graph2Vec embeddings
  • Perform call tree analysis to trace function relationships
  • Map functions to Redis commands
  • Analyze real profiling data from pprof files with precise CPU percentages
  • Identify performance hotspots and functions consuming >5% CPU
  • Link functions to Redis commands and command groups with performance impact
  • Query SQLite profiling database for flat and cumulative CPU usage
  • Provide Redis performance insights from real benchmark data
  • Answer questions about the codebase and performance characteristics
  • Analyze GitHub PRs for performance impact

4. GitHub PR Analysis

Run the performance analyzer on a specific PR:

redopt

The tool will analyze GitHub PRs for performance-related changes and can use the indexed function database for enhanced analysis.

5. Slack Notifications

RedOpt AI can send notifications to Slack channels for significant performance impacts:

# Set up Slack webhook token
export PERFORMANCE_WH_TOKEN=T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX

# Analyze a PR with automatic Slack alerts for significant impacts
redopt chat "Assess the impact of https://github.com/redis/redis/pull/14200. If the impact is significant warn us on slack on #perf-ci."

# Send a manual notification
redopt chat "Send a test message to slack saying 'Hello from RedOpt AI'"

Features:

  • Automatic alerts for PRs with >5% performance impact
  • Performance alerts with detailed impact analysis
  • Interactive action buttons (JIRA, GitHub comments, benchmarks)
  • Repository-specific functionality (Redis repos get additional features)
  • Configurable via webhook token
  • Supports custom channels and message formatting

See docs/slack_notifications.md for detailed configuration and usage.

How It Works

The tool uses an OpenAI Agent to:

  1. Fetch GitHub PR data (description, files, comments, reviews)
  2. Analyze the changes for performance impact
  3. Generate a structured analysis including:
    • Performance improvements and regressions
    • Affected Redis commands
    • Significance assessment
    • Summary of changes

Project Structure

src/
โ”œโ”€โ”€ main.py                    # Main application entry point
โ”œโ”€โ”€ config.py                  # Configuration management
โ”œโ”€โ”€ github_client/             # GitHub API client
โ”‚   โ”œโ”€โ”€ client.py              # GitHub client implementation
โ”‚   โ””โ”€โ”€ models.py              # Data models
โ”œโ”€โ”€ function_analysis/         # Function analysis service
โ”‚   โ”œโ”€โ”€ core/                  # Core analysis components
โ”‚   โ”‚   โ”œโ”€โ”€ clang_parser.py    # LLVM/Clang AST parsing
โ”‚   โ”‚   โ”œโ”€โ”€ graph_converter.py # Convert clang AST to networkx graphs
โ”‚   โ”‚   โ”œโ”€โ”€ graph2vec.py       # Graph embedding generation
โ”‚   โ”‚   โ””โ”€โ”€ models.py          # Data models and schemas
โ”‚   โ”œโ”€โ”€ storage/               # Storage layer
โ”‚   โ”‚   โ”œโ”€โ”€ redis_client.py    # Redis integration
โ”‚   โ”‚   โ””โ”€โ”€ vector_search.py   # Similarity search implementation
โ”‚   โ”œโ”€โ”€ interfaces/            # User interfaces
โ”‚   โ”‚   โ”œโ”€โ”€ function_tool.py   # AI agent function tool
โ”‚   โ”‚   โ”œโ”€โ”€ api.py            # FastAPI REST endpoints
โ”‚   โ”‚   โ””โ”€โ”€ chat.py           # Interactive chat interface
โ”‚   โ””โ”€โ”€ cli/                   # Command line tools
โ”‚       โ””โ”€โ”€ indexer.py         # Codebase indexing CLI
โ””โ”€โ”€ profiling/                 # Profiling analysis service
    โ”œโ”€โ”€ models.py              # Profiling data models
    โ”œโ”€โ”€ parsers/               # Data parsers
    โ”‚   โ””โ”€โ”€ perf_parser.py     # Perf script parser
    โ”œโ”€โ”€ storage/               # Storage layer
    โ”‚   โ””โ”€โ”€ profile_storage.py # Redis storage for profiling data
    โ”œโ”€โ”€ queries/               # Query interface
    โ”‚   โ””โ”€โ”€ profile_queries.py # Profiling data queries
    โ””โ”€โ”€ cli/                   # Command line tools
        โ””โ”€โ”€ profile_indexer.py # Profiling data indexing CLI

Publishing to PyPI

Prerequisites for Publishing

  1. PyPI Account: Create accounts on PyPI and TestPyPI
  2. API Tokens: Generate API tokens for both PyPI and TestPyPI
  3. Poetry Configuration: Configure Poetry with your credentials

Configure Poetry for Publishing

# Configure PyPI credentials
poetry config pypi-token.pypi your-pypi-api-token

# Configure TestPyPI for testing (optional)
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry config pypi-token.testpypi your-testpypi-api-token

Publishing Process

# 1. Update version in pyproject.toml
poetry version patch  # or minor, major

# 2. Build the package
poetry build

# 3. Test publish to TestPyPI (optional but recommended)
poetry publish -r testpypi

# 4. Test installation from TestPyPI
pip install --index-url https://test.pypi.org/simple/ redopt

# 5. Publish to PyPI
poetry publish

# 6. Verify installation
pip install redopt
redopt --help

Version Management

# Patch version (0.1.0 -> 0.1.1)
poetry version patch

# Minor version (0.1.0 -> 0.2.0)
poetry version minor

# Major version (0.1.0 -> 1.0.0)
poetry version major

# Pre-release versions
poetry version prerelease  # 0.1.0 -> 0.1.1a0
poetry version prepatch    # 0.1.0 -> 0.1.1a0
poetry version preminor    # 0.1.0 -> 0.2.0a0
poetry version premajor    # 0.1.0 -> 1.0.0a0

Development

This is a Redis AI Week project focused on performance analysis of Redis-related pull requests, combining:

  1. Static Code Analysis: Function-level semantic analysis using LLVM/Clang and Graph2Vec
  2. Runtime Profiling: Performance hotspot analysis from perf script data
  3. Benchmark Integration: Mapping between functions, Redis commands, and performance characteristics
  4. AI-Powered Insights: Conversational interface for exploring code and performance relationships

The system enables developers to:

  • Understand which functions are performance-critical for specific Redis operations
  • Find semantically similar functions that might have similar performance characteristics
  • Analyze the performance impact of code changes through both static analysis and profiling data
  • Get AI-powered insights about Redis performance optimization opportunities

Authors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redopt-0.1.0.tar.gz (80.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

redopt-0.1.0-py3-none-any.whl (93.5 kB view details)

Uploaded Python 3

File details

Details for the file redopt-0.1.0.tar.gz.

File metadata

  • Download URL: redopt-0.1.0.tar.gz
  • Upload date:
  • Size: 80.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.7 Linux/5.19.0-46-generic

File hashes

Hashes for redopt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 78ea0663937d43ade3ac939b7164867d93ab400552b0f8545b1782a229ba1f0d
MD5 131f8487da4ae2d188dcd1c0b0f54795
BLAKE2b-256 83f3539bfa35047d0b9cf370840d04ba70f0ce4096ff2fe2e101365f4e5c1c7b

See more details on using hashes here.

File details

Details for the file redopt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: redopt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 93.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.7 Linux/5.19.0-46-generic

File hashes

Hashes for redopt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 674c1be2b89662f2c45ab281e8634b9a9076fa3763d8d82478123fc72d464706
MD5 fb2f30503a5b5c641375a319cb2b3072
BLAKE2b-256 dbe869460ae131533108938cf3ae9f5a6c373518efc6246abbbaeee98449922a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page