CLAUDE.md · plasma-umass/scalene
CLAUDE.md from plasma-umass/scalene: 634 lines covering Project Overview, Build & Test Commands, Project Structure, Key Patterns and more.
Template by plasma-umass
Chalk Labs
Need help deploying CLAUDE.md · plasma-umass/scalene?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code. Read the repository before you give any tool access to your data.
curl -fsSL https://raw.githubusercontent.com/plasma-umass/scalene/master/CLAUDE.md -o CLAUDE.md
Read it and adapt it to your project before use.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: prompt-engineering, code-generation
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
What's in it
A CLAUDE.md file: project memory Claude Code loads at the start of every session.
- For
- Claude Code
- Length
- 634 lines
- File
CLAUDE.md
Sections
- Project Overview
- Build & Test Commands
- Project Structure
- Key Patterns
- Testing
- CI/CD (.github/workflows/)
- Common Tasks
- Dependencies
- CLI Structure
- Signal Handling
- Native Extension Build Issues
- Profiling Guide
- Debugging Guide
- GUI Development Guide
First lines (shown under the repo's Apache-2.0 license)
# Scalene Development Guide ## Project Overview Scalene is a high-performance CPU, GPU, and memory profiler for Python with AI-powered optimization proposals. It runs significantly faster than other Python profilers while providing detailed performance information. See the paper `docs/osdi23-berger.pdf` for technical details on Scalene's design. **Key features:** - CPU, GPU (NVIDIA/Apple), and memory profiling - AI-powered optimization suggestions (OpenAI, Anthropic, Azure, Amazon Bedrock, Gemini, Ollama) - Web-based GUI and CLI interfaces - Jupyter notebook support via magic commands (`%scrun`, `%%scalene`) - Line-by-line profiling with low overhead - Separates Python time from native/C time **Platform support:** Linux, macOS, WSL 2 (full support); Windows (partial support) ## Build & Test Commands ```bash # Install in development mode pip install -e . # Run all tests python3 -m pytest tests/ # Run tests for a specific Python version python3.X -m pytest tests/ # Run linters mypy scalene ruff check scalene # Run a single test file python3 -m pytest tests/test_coverup_83.py -v ``` ## Project Structure ### Core Profiler Components (`scalene/`) - **`scalene_profiler.py`** - Main profiler class (`Scalene`). Entry point for profiling. Uses signal-based sampling for CPU profiling. Coordinates all profiling subsystems. - **`scalene_statistics.py`** - `ScaleneStatistics` class. Collects and aggregates profiling data. Key types: `ProfilingSample`, `MemcpyProfilingSample`. Uses `RunningStats` for statistical aggregation. - **`scalene_output.py`** - Profile output formatting for CLI/HTML - **`scalene_json.py`** - `ScaleneJSON` class for JSON output format - **`scalene_analysis.py`** - Profile analysis logic ### Entry Points - **`__main__.py`** - Entry point for `python -m scalene` - **`profile.py`** - Entry point for `--on`/`--off` control of background profiling ### Configuration & Arguments - **`scalene_config.py`** - Version info (`scalene_version`, `scalene_date`) and constants: - `SCALENE_PORT = 11235` - Default port for web UI - `NEWLINE_TRIGGER_LENGTH` - Must match `src/include/sampleheap.hpp` - **`scalene_arguments.py`** - `ScaleneArguments` class (extends `argparse.Namespace`) with all profiler options and their defaults defined in `ScaleneArgumentsDict` - **`scalene_parseargs.py`** - `ScaleneParseArgs.parse_args()` builds the argument parser. `RichArgParser` provides colored help output (uses Rich on Python < 3.14, native argparse colors on 3.14+) ### Signal Handling - **`scalene_signals.py`** - Signal definitions for CPU sampling - **`scalene_signal_manager.py`** - Manages signal handlers - **`scalene_sigqueue.py`** - Signal queue management - **`scalene_client_timer.py`** - Timer for periodic profiling ### GPU Support - **`scalene_nvidia_gpu.py`** - NVIDIA GPU profiling via `pynvml` - **`scalene_apple_gpu.py`** - Apple GPU profiling (Metal) - **`scalene_accelerator.py`** - Generic accelerator interface - **`scalene_neuron.py`** - AWS Neuron support ### Memory Profiling - **`scalene_memory_profiler.py`** - Memory profiling logic - **`scalene_leak_analysis.py`** - Memory leak detection (experimental, `--memory-leak-detector`) - **`scalene_mapfile.py`** - `ScaleneMapFile` for memory-mapped communication with native extension - **`scalene_preload.py`** - Sets up `LD_PRELOAD`/`DYLD_INSERT_LIBRARIES` for native memory tracking ### Jupyter Integration - **`scalene_magics.py`** - Jupyter magic commands (`%scrun` for line mode, `%%scalene` for cell mode) - **`scalene_jupyter.py`** - Jupyter notebook support utilities ### Replacement Modules (`replacement_*.py`) These modules monkey-patch standard library functions to capture profiling data during blocking operations: - **`replacement_fork.py`** - Tracks `os.fork()` - **`replacement_exit.py`** - Tracks `sys.exit()` - **`replacement_lock.py`**, **`replacement_mp_lock.py`**, **`replacement_sem_lock.py`** - Lock acquisition timing - **`replacement_thread_join.py`**, **`replacement_pjoin.py`** - Thread/process join timing - **`replacement_signal_fns.py`** - Signal function replacements - **`replacement_poll_selector.py`** - I/O polling timing - **`replacement_get_context.py`** - Multiprocessing context ### Utilities - **`runningstats.py`** - `RunningStats` class for online statistical calculations (mean, variance) - **`scalene_funcutils.py`** - Function utilities - **`scalene_utility.py`** - General utilities - **`sparkline.py`** - Sparkline generation for memory visualization - **`syntaxline.py`** - Syntax-highlighted source code lines - **`adaptive.py`** - Adaptive sampling logic - **`time_info.py`** - Time measurement utilities - **`sorted_reservoir.py`** - Reservoir sampling for bounded-size sample collection ### GUI (`scalene/scalene-gui/`) Web-based GUI built with TypeScript, bundled with esbuild. **Core Files:** - **`index.html.template`** - Jinja2 template for main GUI page (rendered by `scalene_utility.py`) - **`scalene-gui.ts`** - Main TypeScript entry point, UI event handlers, initialization - **`scalene-gui-bundle.js`** - Bundled JavaScript output (generated, do not edit directly) **AI Provider Modules:** - **`openai.ts`** - OpenAI API integration (`sendPromptToOpenAI`, `fetchOpenAIModels`) - **`anthropic.ts`** - Anthropic Claude API integration - **`gemini.ts`** - Google Gemini API integration (`sendPromptToGemini`, `fetchGeminiModels`) - **`optimizations.ts`** - Provider dispatch logic, prompt generation - **`persistence.ts`** - localStorage persistence with environment variable fallbacks **Support Files:** - **`launchbrowser.py`** - Opens browser to GUI (default port 11235) - **`find_browser.py`** - Cross-platform browser detection **Vendored Assets (for offline support):** - **`jquery-3.6.0.slim.min.js`** - jQuery (vendored locally, not loaded from CDN) - **`bootstrap.min.css`** - Bootstrap 5.1.3 CSS - **`bootstrap.bundle.min.js`** - Bootstrap 5.1.3 JS with Popper - **`prism.css`** - Syntax highlighting styles - **`favicon.ico`** - Scalene favicon - **`scalene-image.png`** - Scalene logo These assets are copied, with the page, into a fresh private (0700) temp directory that `launchbrowser.py` serves and deletes on exit, enabling the GUI to work in air-gapped/offline environments. Never serve the shared system temp dir itself. **Building the GUI:** ```bash npm --prefix scalene/scalene-gui run build ``` The `build` script in `scalene/scalene-gui/package.json` invokes esbuild with `--minify --sourcemap --target=es2020`. The minified bundle is what gets checked in (≈1.1 MB vs ≈2.5 MB unminified). A `build:dev` variant (no minification) is available for debugging. ### Native Extensions (`src/`) C++ code for low-overhead memory allocation tracking: **Headers (`src/include/`):** - **`sampleheap.hpp`** - Sampling heap allocator. Key constant `NEWLINE` must match Python config. - **`memcpysampler.hpp`** - Intercepts `memcpy` to track copy volume - **`pywhere.hpp`** - Tracks Python file/line info for allocations - **`samplefile.hpp`** - File-based communication with Python - **`sampler.hpp`**, **`poissonsampler.hpp`**, **`thresholdsampler.hpp`** - Sampling strategies - **`scaleneheader.hpp`** - Common header definitions **Sources (`src/source/`):** - **`libscalene.cpp`** - Main native library (loaded via `LD_PRELOAD`)
Signals
- Stars
- 13,530
- Forks
- 443
- Open issues
- 151
- Last commit (this folder)
- Sep 27, 2026 (1 month ago)
- Last release
- Oct 23, 2026 (7 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- Apache-2.0
- Repository
- github.com/plasma-umass/scalene
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get CLAUDE.md · plasma-umass/scalene running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
CLAUDE.md · plasma-umass/scalene. Agent Mart. https://agentmart.dev/templates/plasma-umass-scalene-claude-md (last updated 2026-10-24)