heshamfs/materials-simulation-skills/performance-profiling
Claude Code and agent skill by heshamfs/materials-simulation-skills
- community
Checking that the SKILL.md file is still in the repository.
Identify computational bottlenecks, analyze parallel scaling, estimate memory requirements, and generate optimization recommendations for materials simulations — parse timing logs to find dominant phases (solver, assembly, I/O), evaluate strong and weak scaling efficiency, profile memory from mesh and field parameters, and detect bottlenecks with actionable fix suggestions. Use when a simulation is running slower than expected, investigating MPI scaling efficiency, planning HPC resource allocation, deciding whether to tune the preconditioner or reduce I/O frequency, or estimating if a problem fits in available RAM, even if the user only says "my simulation is too slow" or "how many nodes do I need."
Install
npx vskill@latest install heshamfs/materials-simulation-skills/performance-profilingSKILL.md
Performance Profiling
Goal
Provide tools to analyze simulation performance, identify bottlenecks, and recommend optimization strategies for computational materials science simulations.
Requirements
- Python 3.10+
- No external dependencies (uses Python standard library only)
- Works on Linux, macOS, and Windows
Inputs to Gather
Before running profiling scripts, collect from the user:
| Input | Description | Example | |
|---|---|---|---|
| Simulation log | Log file with timing information | simulation.log | |
| Scaling data | JSON with multi-run performance data | scaling_data.json | |
| Simulation parameters | JSON with mesh, fields, solver config | params.json | |
| Available memory | System memory in GB (optional) | 16.0 |
Decision Guidance
When to Use Each Script
Choosing Analysis Thresholds
| Metric | Good | Acceptable | Poor | |
|---|---|---|---|---|
| Phase dominance | <30% | 30-50% | >50% | |
| Parallel efficiency | >0.80 | 0.70-0.80 | <0.70 | |
| Memory usage | <60% | 60-80% | >80% |
Script Outputs (JSON Fields)
All scripts wrap their payload in a top-level object with two keys: inputs and results. The fields below live under results.
| Script | Key Outputs (under results) | |
|---|---|---|
timing_analyzer.py | results.phases, results.slowest_phase, results.total_time | |
scaling_analyzer.py | results.results, results.efficiency_threshold_processors, results.average_efficiency, results.baseline | |
memory_profiler.py | results.total_memory_gb, results.per_process_gb, results.field_memory_gb, results.solver_workspace_gb, results.matrix_storage_gb, results.warnings | |
bottleneck_detector.py | results.bottlenecks, results.recommendations |
Workflow
Complete Profiling Workflow
- Analyze timing from simulation logs
- Analyze scaling from multi-run data (if available)
- Profile memory from simulation parameters
- Detect bottlenecks and get recommendations
- Implement optimizations based on recommendations
- Re-profile to verify improvements
Quick Profiling (Timing Only)
- Run timing analyzer on simulation log
- Identify dominant phases (>50% of runtime)
- Apply targeted optimizations to dominant phases
CLI Examples
Timing Analysis
Scaling Analysis
Memory Profiling
Bottleneck Detection
Conversational Workflow Example
User: My simulation is taking too long. Can you help me identify what's slow?
Agent workflow:
- Ask for simulation log file
- Run timing analyzer:
``bash python3 scripts/timing_analyzer.py --log simulation.log --json ``
- Interpret results (the detector flags solver/assembly phases above 50% and I/O phases above 30%; >70% is high severity):
- If solver dominates (>50%, high above 70%): Recommend preconditioner tuning
- If assembly dominates (>50%): Recommend caching or vectorization
- If I/O dominates (>30%): Recommend reducing output frequency
- If user has multi-run data, analyze scaling:
``bash python3 scripts/scaling_analyzer.py --data scaling.json --type strong --json ``
- Generate comprehensive recommendations:
``bash python3 scripts/bottleneck_detector.py --timing timing.json --scaling scaling.json --json ``
Interpretation Guidance
Timing Analysis
The detector applies per-type dominance thresholds: solver/assembly/general phases are flagged above 50% of runtime; I/O phases above 30%. Any flagged phase above 70% is reported as high severity.
| Scenario | Meaning | Action | |
|---|---|---|---|
| Solver >50% (high >70%) | Solver-dominated | Tune preconditioner, check tolerance | |
| Assembly >50% | Assembly-dominated | Cache matrices, vectorize, parallelize | |
| I/O >30% | I/O-dominated | Reduce frequency, use parallel I/O | |
| Balanced (below thresholds) | Well-balanced | Look for algorithmic improvements |
Scaling Analysis
| Efficiency | Meaning | Action | |
|---|---|---|---|
| >0.80 | Excellent scaling | Continue scaling up | |
| 0.70-0.80 | Good scaling | Monitor at larger scales | |
| 0.50-0.70 | Poor scaling | Investigate communication/load balance | |
| <0.50 | Very poor scaling | Reduce processor count or redesign |
Memory Profile
| Usage | Meaning | Action | |
|---|---|---|---|
| <60% available | Safe | No action needed | |
| 60-80% available | Moderate | Monitor, consider optimization | |
| >80% available | High | Reduce resolution or increase processors | |
| >100% available | Exceeds capacity | Must reduce problem size |
The estimate follows the three-term formula Total = Field + Solver Workspace + Matrix Storage (see references/profiling_guide.md). Matrix storage and solver workspace depend on solver.type:
iterative(default): sparse matrix (default 7-point stencil, override viasolver.stencil_nnz) plus workspace vectors.direct: sparse matrix scaled by a conservative fill-in factor (solver.fillin_factor, default 10) to reflect factorization fill-in — a direct solver estimates far more memory than an iterative one for the same mesh.matrix-free: no assembled matrix; workspace vectors only.
The estimate is intentionally conservative so a "will it fit in RAM?" decision does not silently under-estimate.
Error Handling
| Error | Cause | Resolution | |
|---|---|---|---|
Log file not found | Invalid path | Verify log file path | |
No timing data found | Pattern mismatch | Provide custom pattern with --pattern | |
At least 2 runs required | Insufficient data | Provide more scaling runs | |
Missing required parameters | Incomplete params | Add mesh and fields to params file |
Optimization Strategies by Bottleneck Type
Solver Bottlenecks
- Use algebraic multigrid (AMG) preconditioner
- Tighten solver tolerance if over-solving
- Consider direct solver for small problems
- Profile matrix assembly vs solve time
Assembly Bottlenecks
- Cache element matrices if geometry is static
- Use vectorized assembly routines
- Consider matrix-free methods
- Parallelize assembly with coloring
I/O Bottlenecks
- Reduce output frequency
- Use parallel I/O (HDF5, MPI-IO)
- Write to fast scratch storage
- Compress output data
Scaling Bottlenecks
- Investigate communication overhead
- Check for load imbalance
- Reduce synchronization points
- Use asynchronous communication
- Consider hybrid MPI+OpenMP
Memory Bottlenecks
- Reduce mesh resolution
- Use iterative solver (lower memory than direct)
- Enable out-of-core computation
- Increase number of processors
- Use single precision where appropriate
Verification checklist
Before trusting a profiling result or acting on a recommendation, record the concrete evidence below:
- [ ] Confirmed
timing_analyzer.pyactually matched entries —results.phasesis non-empty andresults.total_time> 0; if a custom--patternwas used andresults.message/suggested_patternsappeared, the pattern was fixed and re-run (an emptyphaseslist silently looks like a fast simulation). - [ ] Cross-checked that the sum of
phases[].percentageis ~100% and that named phases cover the wall-clock time — unaccounted-for time means missing log lines, not a balanced run. - [ ] For scaling claims, used >=2 runs spanning a real processor range and recorded
results.average_efficiencyandresults.efficiency_threshold_processorsfromscaling_analyzer.py; verified the--type(strong vs weak) matches how the runs were generated (fixed total size vs fixed work-per-rank). - [ ] Recorded the memory breakdown from
memory_profiler.py(field_memory_gb,solver_workspace_gb,matrix_storage_gb,total_memory_gb) and confirmedsolver.type(iterative / direct / matrix-free) matches the real solver — a direct solve carries the ~10x fill-in factor and a wrong type makes the "fits in RAM?" answer unsafe. - [ ] Checked
results.warningsand comparedtotal_memory_gb(andper_process_gb) against the actual--available-gb; treated >80% as the documented "high" band, not a pass. - [ ] For each
bottleneck_detector.pyrecommendation, confirmed the drivingbottleneck(itscategory,value, andthreshold) is consistent with the timing/scaling/memory inputs that were actually supplied — recommendations only reflect the JSON files passed via--timing/--scaling/--memory. - [ ] After implementing an optimization, re-ran the relevant analyzer and recorded the before/after
valueto confirm the bottleneck actually moved (re-profile step of the workflow).
Common pitfalls & rationalizations
| Tempting shortcut | Why it's wrong / what to do | |
|---|---|---|
"timing_analyzer.py returned no bottlenecks, so the run is balanced." | An empty/low result is often a pattern mismatch — phases may be empty or partial. Verify total_time matches wall-clock and that phase percentages sum to ~100% before concluding "balanced". | |
| "Two runs scaled fine, so it scales." | Two points only give an average efficiency; they cannot reveal where efficiency falls off. Add more processor counts and check efficiency_threshold_processors, and confirm you used the correct --type (strong vs weak). | |
| "Iterative vs direct is just a flag; memory is about the same." | memory_profiler.py applies a conservative ~10x fill-in factor for direct and stores no matrix for matrix-free. Setting the wrong solver.type can under-estimate RAM by an order of magnitude — set it to the real solver. | |
"It fits in --available-gb total, so we're fine." | The relevant number for an MPI run is per_process_gb against per-node/per-rank RAM, and >80% of total already triggers a warning. Check the per-process figure and the warnings list, not just the total. | |
| "I/O is under 50%, so I/O isn't the bottleneck." | I/O is flagged at the lower 30% threshold, not 50%. A 30-50% I/O phase is a real bottleneck the detector reports — reduce output frequency or use parallel I/O. | |
| "The recommendation says tune the preconditioner, so the solver is the problem." | Recommendations are only as complete as the JSON you passed in. If --scaling/--memory were omitted, those bottlenecks are simply invisible — feed all available analyses before trusting the priority ranking. |
Security
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/simulation-workflow/performance-profiling/SKILL.md
Popularity
- Repository stars
- 57
- Repository forks
- 4
- 7-day trend score
- 20
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 15 Jul 2026, 3 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/heshamfs/materials-simulation-skills/performance-profiling)