Back to list
antonykamp

detecting-deoptimizations

by antonykamp

A Claude plugin for analyzing and optimizing Truffle performance

0🍴 0📅 Jan 22, 2026

SKILL.md


name: detecting-deoptimizations description: Traces deoptimization events where execution falls back from compiled code to interpreter. Use to detect deoptimization loops, unstable assumptions, and type instability. Zero transfers in steady-state is the goal. Many transfers indicate severe performance problems. Critical for diagnosing compilation instability.

Detecting Deoptimizations

Traces every deoptimization event where execution falls back from compiled code to interpreter. Critical for finding the most severe performance problems.

Why Deoptimizations Are Catastrophic

  • Single transfer cost: Hundreds of nanoseconds (vs ~5ns for normal call)
  • Deoptimization loops: 10-100x slower than pure interpreter!
  • Wasted compilation: Compile → deoptimize → recompile → deoptimize = disaster

Goal: Zero transfers in steady-state execution!

When to Use This Skill

  • Investigate poor performance despite successful compilation
  • Profile shows methods in interpreted mode
  • Debug why compiled code keeps falling back
  • Verify benchmarks have properly warmed up

Quick Start

# Basic deoptimization trace
<launcher> --experimental-options \
  --engine.TraceTransferToInterpreter <program>

# Combined with compilation trace (HIGHLY RECOMMENDED)
<launcher> --experimental-options \
  --engine.TraceTransferToInterpreter \
  --engine.TraceCompilation \
  <program> 2>&1 | tee transfers.log

# Focus on specific function
<launcher> --experimental-options \
  --engine.TraceTransferToInterpreter \
  --engine.CompileOnly=functionName \
  <program>

⚠️ REQUIRED: Fermi Verification (Every Tool Invocation)

Before running:

  • Pre-calculate: Expected transfers (0-50 during warmup, 0 in steady-state)
  • Smoke test: <launcher> --experimental-options --engine.TraceTransferToInterpreter -c 'print 1;' → Verify no false transfers

After running:

  • Validate: Transfer count within expectation? YES / NO
  • If >100 transfers: CRITICAL - Deoptimization loop, analyze repeated locations
  • Save output: tool-outputs/trace-transfers-[benchmark].txt

Gate: All boxes checked? → Proceed to analysis

Key Options

OptionDescription
--engine.TraceTransferToInterpreterTrace all deoptimizations
--engine.TraceCompilationCombine for full picture
--engine.CompileOnly=<name>Filter to specific function
--engine.TraceStackTraceLimit=<n>Stack trace depth (default 20)

Understanding Output

Transfer Event

[engine] transferToInterpreter at
problemFunction(<source>:42:123-456)
callerFunction(<source>:18:78-90)
topLevelFunction(<source>:5:10-50)

Problem Patterns

Pattern 1: Deoptimization Loop (CRITICAL!)

[engine] transferToInterpreter at MyNode.execute(<source>:42)
[engine] transferToInterpreter at MyNode.execute(<source>:42)
[engine] transferToInterpreter at MyNode.execute(<source>:42)
...dozens more at same location...

🚨 This is catastrophic! Often worse than never compiling.

Cause: Unstable type assumptions Fix: Implement proper type specializations, avoid mixing types

Pattern 2: Warmup Transfers (Normal)

[First 5 seconds]
...many transfers...
[After 10+ seconds]
[No more transfers]  ✅

Acceptable: Decreases over time, stops after warmup

Pattern 3: Rare Path Transfers (Acceptable)

[During entire execution]
[engine] transferToInterpreter at errorHandler(<source>:250)

Acceptable: Infrequent, from error handling or validation

Transfer Count Guidelines

CountStatusAction
0✅ PerfectIdeal state
1-10✅ OKLikely warmup or rare paths
10-100⚠️ InvestigateMay have issues
100+❌ CriticalDeoptimization loop likely

Analysis Commands

# Count total transfers
grep -c "transferToInterpreter" transfers.log

# Count unique locations
grep "transferToInterpreter at" transfers.log | sort -u | wc -l

# Find repeated locations (deoptimization loops)
grep "transferToInterpreter at" transfers.log | sort | uniq -c | sort -rn

Integration with Other Skills

FindingNext Skill
Deopt loopsFix type stability, add specializations
Property access deoptsStabilize object shapes
Unclear causeanalyzing-compiler-graphs
  • tracing-compilation-events - See compilation cycles
  • profiling-with-cpu-sampler - Measure impact
  • detecting-performance-warnings - Find barriers
  • analyzing-compiler-graphs - Deep analysis

Reference

<launcher> --help:engine | grep -i transfer

See PATTERNS.md for detailed problem patterns and solutions.

Score

Total Score

55/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

0/5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon