schedcp
CLAUDE.md117 starsChanged 14 months agoMITView on GitHub
schedcp is a Linux scheduler optimization project that uses the sched-ext (scx) framework to implement and test various BPF-based kernel schedulers. The project includes multiple scheduler implementations in both C and Rust, along with benchmarking tools, workloads, and an MCP (Model Context Protocol) server for AI-assisted scheduler management. MCP Server Architecture: The heart of the project is the MCP server (mcp/src/) which provides AI-assisted scheduler management. Key integration points: Scheduler Framework Integration: The project embeds all sched-ext schedulers as resources,…
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
17 rules. About 0 are common, 9 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 135
Workload Profiling: Create detailed workload profiles from natural language descriptions
- Distinctive: line 137
Custom Scheduler Creation: Create, compile, and verify custom BPF schedulers from source code
- Distinctive: line 138
Automated Testing: Run systematic comparisons across multiple schedulers with optimal configurations
- Very specific: line 162
Update scheduler/schedulers.json with metadata, algorithm type, and tuning parameters
- Distinctive: line 163
Add performance characteristics and optimal use cases
- Very specific: line 164
Run make install to copy to ~/.schedcp/scxbin/
- Distinctive: line 165
Test with existing workloads and update MCP server scheduler database
- Very specific: line 168
Use create_and_verify_scheduler tool with BPF C source code
- Very specific: line 182
Stop command uses pkill for custom schedulers, ProcessManager for built-in
- Very specific: line 185
Create workload in appropriate workloads/ subdirectory
- Distinctive: line 187
Ensure output can be captured for metrics analysis
- Distinctive: line 188
Add workload profile creation support in the MCP server
- Very specific: line 189
Use system_monitor tool to collect metrics during execution
- Distinctive: line 193
Use JSON output format for consistent metrics capture
- Very specific: line 195
Use system_monitor to collect CPU, memory, and scheduler metrics
- Distinctive: line 250
Consider passwordless sudo configuration for production deployments
- Very specific: line 251
All scheduler operations are logged to schedcp.log for audit trails
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
schedcp is a Linux scheduler optimization project that uses the sched-ext (scx) framework to implement and test various BPF-based kernel schedulers. The project includes multiple scheduler implementations in both C and Rust, along with benchmarking tools, workloads, and an MCP (Model Context Protocol) server for AI-assisted scheduler management.
Essential Build Commands
Building the MCP Server and CLI
# Build the schedcp MCP server and CLI tool
cd mcp
cargo build --release
# Binaries will be available at:
# - mcp/target/release/schedcp (MCP server)
# - mcp/target/release/schedcp-cli (CLI tool)Building Schedulers
# Install dependencies first (one-time setup)
cd scheduler
make deps
# Build all schedulers (C and Rust) - outputs to sche_bin/
make
# Build specific types
make build-c # Build only C schedulers
make build-rust # Build only Rust schedulers
make build-tools # Build tools (scx_loader, scxctl, scxtop) - outputs to tools/
# Generate scheduler documentation
make doc
# Clean build artifacts
make clean
# Update scx submodule
make update
# Install schedulers to ~/.schedcp/scxbin/
make installRunning Tests
# Unit tests for sched-ext framework
cd scheduler/scx
meson setup build
meson test -v -C build
# Run specific benchmark workloads
python workloads/basic/scheduler_test/schbench_bench_start.py
python workloads/llama.cpp/llamacpp_bench_start.py
python workloads/cxl-micro/cxl_micro_bench_start.pyHigh-Level Architecture
Core Components Integration
MCP Server Architecture: The heart of the project is the MCP server (mcp/src/) which provides AI-assisted scheduler management. Key integration points:
- scheduler_manager.rs: Manages the lifecycle of kernel schedulers, interfaces with embedded scheduler binaries, handles both built-in and custom schedulers
- scheduler_generator.rs: Creates, compiles, and verifies custom BPF schedulers from source code (private module accessed through manager)
- system_monitor.rs: Collects real-time CPU, memory, and scheduler metrics from
/procfor performance analysis - workload_profile.rs: Creates natural language workload descriptions and tracks performance history across different schedulers
- storage.rs: Persists workload data in
schedcp_workloads.json, enabling learning from past optimizations
Scheduler Framework Integration: The project embeds all sched-ext schedulers as resources, enabling standalone operation without requiring local builds. The embedded approach allows the MCP server to manage any scheduler configuration programmatically.
Workload-Scheduler Optimization Loop: The architecture enables a closed-loop optimization system where:
- Workloads are described in natural language and classified
- Multiple schedulers are tested automatically with optimal configurations
- Performance history is tracked and used for future recommendations
- AI assistants can make data-driven scheduler selections
Directory Structure and Data Flow
schedcp/
├── mcp/ # MCP server for AI-assisted optimization
│ ├── src/
│ │ ├── scheduler_manager.rs # Scheduler lifecycle management
│ │ ├── scheduler_generator.rs # Custom scheduler creation/compilation
│ │ ├── system_monitor.rs # Real-time metrics collection
│ │ ├── workload_profile.rs # Workload classification and history
│ │ ├── storage.rs # Persistent performance data
│ │ ├── main.rs # MCP server entry point
│ │ ├── lib.rs # Core MCP implementation
│ │ └── cli.rs # CLI tool implementation
│ ├── new_sched/ # Custom scheduler working directory
│ │ ├── loader # BPF loader for custom schedulers
│ │ └── *.bpf.{c,o} # Custom scheduler sources and objects
│ └── schedcp_workloads.json # Performance history database
├── scheduler/ # Scheduler build system and metadata
│ ├── scx/ # sched-ext framework (submodule)
│ ├── sche_bin/ # Compiled scheduler binaries
│ ├── scheduler_runner.py # Python scheduler interface
│ └── schedulers.json # Scheduler metadata and capabilities
└── workloads/ # Benchmark workloads for testing
├── basic/schbench/ # Scheduler latency benchmark
├── llama.cpp/ # LLM inference workload
└── cxl-micro/ # Memory subsystem benchmarkCritical Integration Points:
schedulers.jsoncontains metadata about each scheduler's algorithm, tuning parameters, and use casesscheduler_runner.pyprovides a Python interface that the MCP server uses to control schedulers- The MCP server embeds all scheduler binaries, making it self-contained for deployment
Scheduler Selection and Optimization Logic
The project implements an intelligent scheduler selection system:
Workload Analysis: Natural language descriptions are analyzed to identify workload characteristics (latency-sensitive, throughput-focused, interactive, etc.)
Scheduler Matching: Each scheduler in schedulers.json has detailed metadata including:
- Algorithm type (vruntime-based, EDF, multi-domain, etc.)
- Performance profile (low latency, balanced, throughput-optimized)
- Optimal use cases and tuning parameters
- Production readiness status
Automated Testing: The system can automatically test multiple schedulers with workload-specific configurations and compare results across metrics like wakeup latency, request latency, and throughput.
MCP Server Integration
AI-Assisted Workflow
The MCP server enables Claude to perform complete scheduler optimization workflows:
- Workload Profiling: Create detailed workload profiles from natural language descriptions
- Scheduler Analysis: Automatically identify optimal scheduler candidates based on workload characteristics
- Custom Scheduler Creation: Create, compile, and verify custom BPF schedulers from source code
- Automated Testing: Run systematic comparisons across multiple schedulers with optimal configurations
- Performance Monitoring: Collect real-time CPU, memory, and scheduler metrics during execution
- Performance Tracking: Maintain persistent history of scheduler performance for different workloads
- Data-Driven Recommendations: Make scheduler recommendations based on historical performance data
Key MCP Commands
list_schedulers: Get comprehensive scheduler information including algorithms and tuning parametersrun_scheduler: Start schedulers with specific configurations (works for both built-in and custom schedulers)stop_scheduler: Stop running schedulers by execution IDget_execution_status: Monitor running scheduler performance and outputcreate_and_verify_scheduler: Create, compile, and verify custom BPF schedulerssystem_monitor: Collect CPU, memory, and scheduler metrics (start/stop commands)workload: Unified command for workload profile management (create/list/get_history/add_history)
Key CLI Commands
schedcp-cli list [--name NAME] [--production]: List available schedulers with detailed informationschedcp-cli run SCHEDULER [ARGS...]: Run a scheduler with optional argumentsschedcp-cli create-and-run SOURCE.bpf.c: Create and run a custom scheduler from sourceschedcp-cli monitor [--duration SECS]: Monitor system metrics for specified duration (default: 10s)
Development Patterns
Adding Built-in Schedulers
- Implement scheduler in
scheduler/scx/scheds/c/orscheduler/scx/scheds/rust/ - Update
scheduler/schedulers.jsonwith metadata, algorithm type, and tuning parameters - Add performance characteristics and optimal use cases
- Run
make installto copy to~/.schedcp/scxbin/ - Test with existing workloads and update MCP server scheduler database
Creating Custom Schedulers via MCP
- Use
create_and_verify_schedulertool with BPF C source code - Scheduler is automatically compiled using clang with appropriate flags
- Verification loads the scheduler in kernel for 10 seconds to test
- Compiled scheduler stored in
mcp/new_sched/directory - Custom schedulers can be run via
run_schedulerlike built-in schedulers
Custom Scheduler Architecture
- SchedulerGenerator (private): Handles compilation and verification
- Uses clang with BPF target and scx includes from
scheduler/scx/scheds/include - Compiles
.bpf.cto.bpf.oinmcp/new_sched/directory - Uses loader binary for kernel verification
- Uses clang with BPF target and scx includes from
- SchedulerManager (public): Provides unified API for both built-in and custom schedulers
create_execution()automatically detects scheduler type (built-in vs custom)- Custom schedulers tracked in execution map with
"custom:"prefix - Stop command uses
pkillfor custom schedulers, ProcessManager for built-in
Workload Development
- Create workload in appropriate
workloads/subdirectory - Implement using the patterns from
schbench(message/worker thread model for scheduling-sensitive workloads) - Ensure output can be captured for metrics analysis
- Add workload profile creation support in the MCP server
- Use
system_monitortool to collect metrics during execution
Performance Analysis Integration
The project emphasizes automated performance analysis:
- Use JSON output format for consistent metrics capture
- Implement workload-specific metrics (latency percentiles, throughput, scheduling delay)
- Use
system_monitorto collect CPU, memory, and scheduler metrics - Store results in persistent workload history for trend analysis
- Enable Claude to analyze performance patterns and make optimization recommendations
System Monitoring
The system_monitor module collects real-time metrics:
- CPU metrics from
/proc/stat: user, system, idle, iowait times → utilization % - Memory metrics from
/proc/meminfo: total, free, available, buffers, cached → usage % - Scheduler metrics from
/proc/schedstat: run time, wait time, timeslices - Samples collected every 1 second with async task-based collection
- Summary includes averages, maximums, and totals for analysis
Requirements and Environment
- Linux kernel 6.12+ with sched-ext support
- Clang/LLVM >= 16 (17 recommended)
- Rust toolchain >= 1.82
- Meson >= 1.2.0, libbpf >= 1.2.2
- Root privileges required for scheduler loading (configure sudo access)
Testing and Verification
CLI Testing
# Test listing schedulers
./target/release/schedcp-cli list --production
# Test system monitoring
./target/release/schedcp-cli monitor --duration 5
# Test custom scheduler creation
./target/release/schedcp-cli create-and-run test_scheduler.bpf.cMCP Integration Testing
# Build and test
cargo build --release
cargo test
# The MCP server can be tested via Claude Desktop or programmatically
# Custom scheduler workflow is fully integratedVerification Steps for Custom Schedulers
- Source validation: Check for required BPF operations (select_cpu, enqueue, dispatch, init, exit)
- Compilation: Clang compiles with BPF target and scx includes
- Kernel verification: Loader loads scheduler in kernel for 10 seconds
- Execution tracking: Both built-in and custom schedulers tracked in execution map
- Output capture: Stdout/stderr captured for debugging and analysis
Security and Deployment Notes
Schedulers require root privileges to load. For AI-assisted operation:
- Set
SCHEDCP_SUDO_PASSWORDenvironment variable for MCP server - Consider passwordless sudo configuration for production deployments
- All scheduler operations are logged to
schedcp.logfor audit trails - Custom schedulers compiled with standard BPF security restrictions
- Verification step ensures custom schedulers can load before persistent use
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

