baseline: Weight the computed goto with the opcode frequencies
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- cpp
- Área
- backend, performance
Línea de trabajo
Start with baseline_execution.cpp, dispatch_cgoto, and cgoto_table to understand how the computed goto maps targets to opcodes. The issue proposes adding opcode frequency weights to the indirectbr, then lists benchmarks, mainnet frequency counts, AArch64 and switch dispatch checks, and Clang build integration as open work. Done means benchmarked weights based on mainnet blocks and verified the affected dispatch paths and build integration.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
The register allocator decides which values of the Baseline dispatch loop stay in registers and which are reloaded from the stack. Without a profile, LLVM's block frequency estimate gives every target of the computed goto the same weight: in dispatch_cgoto (Clang 21) all 149 non-terminating handlers get 0.583 × the function entry, so ADD weighs as much as BLOBHASH. Changes that shift liveness in the loop then move reloads into hot handlers by chance, e.g. #1779 on AArch64 with Clang 21: +1 stack load in 52 handlers, including ADD, LT, EQ, JUMPI and DUP2.
Regular PGO does not fix this:
- Front-end instrumentation (
-fprofile-instr-use) leaves theindirectbrwithout weights. - IR instrumentation (
-fprofile-use) weights it, but restructures the whole loop. With a profile from snailtracer, sha1_shifts and swap_math, these benchmarks got 5–8% slower: the checks materialize a status code and each handler reloads 4 values before the indirect jump (ADD 18 → 26 instructions). - The IR profile is keyed by the CFG hash of
dispatch_cgoto, which contains all inlined handlers, so it goes stale with almost every change to the loop. GCC cannot reuse profiles across commits at all.
Idea
Give the compiler only the opcode frequencies, as branch_weights on the computed goto's indirectbr, and leave everything else as without a profile. The weights depend only on the opcode distribution, not on the code, so a checked-in table stays valid. The frequencies should come from mainnet blocks.
Prototype
Clang 21, x86-64: compile baseline_execution.cpp to -O3 IR, map each indirectbr target to its opcodes through cgoto_table, add the weights, then run only the code generation (-Xclang -disable-llvm-passes; without weights this gives the same object as the normal build). The weights are the opcode counts of the profile above.
Shortest success paths of the 149 handlers (instructions / stack loads):
| weights | all handlers | POP, SWAP1, JUMPI, DUP1, DUP2, AND, ADD, JUMP, SUB | SHL, SHR |
|---|---|---|---|
| none | 3152 / 180 | 1 load each | 23/1, 24/1 |
| measured counts | 3485 / 419 | no loads, same length | 25/1, 26/1 |
| 3 tiers | 3316 / 252 | no loads, same length | 27/2, 28/2 |
The tiers are 1000 for opcodes with at least 1% of the executed instructions, 30 for at least 0.01%, and 1 for the rest. MLOAD and MSTORE also lose a load. The reloads move into the cold handlers.
TODO
- Benchmark the variants.
- Count the opcode frequencies on mainnet blocks.
- Check AArch64 and the switch-based
dispatch<false>loop. - Build integration (Clang only): an extra IR step for
baseline_execution.cpp, or a pass plugin.
- Lenguaje dominante
- C++
- Estrellas
- 979
- Forks
- 340
- Merge medio
- 12 h 16 min
- PR fusionados (30 d)
- 25
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ipsilon/evmone
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 56/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 57/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 12/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
Los mantenedores suelen responder en 1 día
Todos los issues de ipsilon/evmone
Issues similares
-
Reference check: findingsAbiertoaudit-reference-check
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
schrodinger/pymol-open-source#532 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
xlnt-community/xlnt#174 ·
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
sleepyviper1213/redis#30 ·