Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/changes/2026-03-24-relax-jit-fallback-thresholds/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Change: Relax JIT fallback thresholds for benchmark corpus

- **Status**: Implemented
- **Date**: 2026-03-24
- **Tier**: Light

## Overview

Relax EVM JIT precompile fallback MIR/RA thresholds to keep the current evmone benchmark corpus (including micro/signextend) on the JIT path. Bytecode-size cap is unchanged.

## Motivation

Some benchmark contracts were falling back to the interpreter due to conservative MIR/RA thresholds, preventing accurate JIT performance measurement. The thresholds were overly conservative for contracts that the JIT can handle efficiently.

## Impact

- Module: `docs/modules/compiler/` (JIT fallback thresholds only)
- 1 file changed, +8/-6 lines
Comment thread
abmcar marked this conversation as resolved.
- Benchmark geomean: +0.28%, sum ratio: +0.69%
- Former fallback-heavy cases (memory_grow_mstore) improve; signextend/snailtracer regress slightly
- EVM semantic behavior is unchanged; execution strategy (JIT vs interpreter path selection) may differ for contracts near the old thresholds.

Comment thread
abmcar marked this conversation as resolved.
## Checklist

- [x] Implementation complete
- [x] Tests added/updated (static analyzer sweep: fallback_contracts=0)
- [x] Module specs in `docs/modules/` updated (if affected)
- [x] Build and tests pass
Comment thread
abmcar marked this conversation as resolved.
14 changes: 8 additions & 6 deletions docs/changes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ Typical triggers:

## Current Proposals

| Date | Name | Status | Tier | Description |
|------|------|--------|------|-------------|
| 2026-03-10 | [evm-stack-ssa-lifting](2026-03-10-evm-stack-ssa-lifting/README.md) | Implemented | Full | True-SSA stack lifting for EVM multipass JIT |
Each active proposal lives in its own subdirectory. Browse `docs/changes/*/README.md`
to see all current proposals, or use:

```bash
ls docs/changes/*/README.md
```

## Workflow

1. Copy the appropriate template into a new `YYYY-MM-DD-<slug>/` directory
2. Fill in the change document
3. Update the table above with the new entry
4. Follow the `dev-workflow` skill for implementation
5. After merging, move the completed change to `docs/_archive/`
3. Follow the `dev-workflow` skill for implementation
4. After merging, move the completed change to `docs/_archive/`
8 changes: 4 additions & 4 deletions docs/modules/compiler/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Used for `DenseSet` deduplication of `MFunctionType`, `MPointerType` key and has
| Constant | Value |
|------|-----|
| `MAX_JIT_BYTECODE_SIZE` | 0x6000 |
| `MAX_JIT_MIR_ESTIMATE` | 50000 |
| `MAX_CONSECUTIVE_RA_EXPENSIVE` | 128 |
| `MAX_BLOCK_RA_EXPENSIVE` | 256 |
| `MAX_DUP_FEEDBACK_PATTERN` | 64 |
| `MAX_JIT_MIR_ESTIMATE` | 0x50000 |
| `MAX_CONSECUTIVE_RA_EXPENSIVE` | 0x3000 |
| `MAX_BLOCK_RA_EXPENSIVE` | 0x3000 |
| `MAX_DUP_FEEDBACK_PATTERN` | 0x3000 |
8 changes: 4 additions & 4 deletions docs/modules/compiler/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ From `common/errors.h`, used by the compiler module:
| Threshold | Description |
|------|------|
| `MAX_JIT_BYTECODE_SIZE` (0x6000) | Bytecode size exceeds limit |
| `MAX_JIT_MIR_ESTIMATE` (50000) | Linear MIR estimate exceeds limit |
| `MAX_CONSECUTIVE_RA_EXPENSIVE` (128) | Consecutive RA-expensive opcodes exceed limit |
| `MAX_BLOCK_RA_EXPENSIVE` (256) | RA-expensive count in a single basic block exceeds limit |
| `MAX_DUP_FEEDBACK_PATTERN` (64) | DUPn + RA-expensive pattern exceeds limit |
| `MAX_JIT_MIR_ESTIMATE` (0x50000) | Linear MIR estimate exceeds limit |
| `MAX_CONSECUTIVE_RA_EXPENSIVE` (0x3000) | Consecutive RA-expensive opcodes exceed limit |
| `MAX_BLOCK_RA_EXPENSIVE` (0x3000) | RA-expensive count in a single basic block exceeds limit |
| `MAX_DUP_FEEDBACK_PATTERN` (0x3000) | DUPn + RA-expensive pattern exceeds limit |

**RA-expensive opcode classification**: SHL (0x1b), SHR (0x1c), SAR (0x1d), MUL (0x02), SIGNEXTEND (0x0b).

Expand Down
14 changes: 8 additions & 6 deletions src/compiler/evm_frontend/evm_analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,15 @@ struct JITSuitabilityResult {
size_t DupFeedbackPatternCount = 0; // DUPn immediately before RA-expensive
};

/// Thresholds for JIT suitability fallback. Normal contracts have <20
/// RA-expensive ops per block; these values are conservatively high.
/// Thresholds for JIT suitability fallback. These limits bound bytecode size
/// and estimated MIR / RA complexity to avoid pathological JIT compile-time
/// blowups (e.g., superlinear register allocation on dense RA-expensive
/// instruction patterns), while keeping typical contracts on the JIT path.
static constexpr size_t MAX_JIT_BYTECODE_SIZE = 0x6000;
static constexpr size_t MAX_JIT_MIR_ESTIMATE = 50000;
static constexpr size_t MAX_CONSECUTIVE_RA_EXPENSIVE = 128;
static constexpr size_t MAX_BLOCK_RA_EXPENSIVE = 256;
static constexpr size_t MAX_DUP_FEEDBACK_PATTERN = 64;
static constexpr size_t MAX_JIT_MIR_ESTIMATE = 0x50000; // 327,680
static constexpr size_t MAX_CONSECUTIVE_RA_EXPENSIVE = 0x3000; // 12,288
static constexpr size_t MAX_BLOCK_RA_EXPENSIVE = 0x3000; // 12,288
static constexpr size_t MAX_DUP_FEEDBACK_PATTERN = 0x3000; // 12,288

class EVMAnalyzer {
using Byte = zen::common::Byte;
Expand Down
Loading