From 9461f88fe20ca63db2ad0706161d46706a5a7df4 Mon Sep 17 00:00:00 2001 From: MauroFab Date: Fri, 24 Jul 2026 12:29:07 -0300 Subject: [PATCH] perf(programs): build the ethrex guest with thin LTO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ethrex guest crate had no [profile.release], so it built with cargo's release defaults (lto = false, codegen-units = 16). Adding thin LTO lowers the number of instructions the VM executes for a real ethrex block, at no runtime cost — execution is priced per executed instruction, so the small ELF-size increase (3.64 MB -> 3.82 MB) is free. Measured on the committed fixtures (same toolchain, same inputs): ethrex_bench_4.bin: 3,841,262 -> 3,750,291 cycles (-90,971, -2.37%) ethrex_bench_16.bin: 11,616,950 -> 11,352,127 cycles (-264,823, -2.28%) Syscall invariants are identical before and after (Keccak 174 / Ecsm 16 for _4, Keccak 356 / Ecsm 64 for _16): the guest does exactly the same work, LTO just compiles it into fewer executed instructions. --- executor/programs/rust/ethrex/Cargo.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/executor/programs/rust/ethrex/Cargo.toml b/executor/programs/rust/ethrex/Cargo.toml index 7d3ed7114..4922712dd 100644 --- a/executor/programs/rust/ethrex/Cargo.toml +++ b/executor/programs/rust/ethrex/Cargo.toml @@ -1,5 +1,12 @@ [workspace] +# Thin LTO measurably lowers executed guest cycles (~2.3% on the committed +# ethrex_bench fixtures) at a small ELF-size cost, which is free in this VM +# (execution is priced per executed instruction, not by ELF size). Cargo's +# release default is lto = false / codegen-units = 16. +[profile.release] +lto = "thin" + [package] name = "ethrex" version = "0.1.0"