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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ are provided with different values, using input as per the execution-apis spec i
- Performance improvements on MOD variant instructions while converting from byte[] to longs [#9976](https://github.com/besu-eth/besu/pull/9976)
- Implement DIV and SDIV with long limbs [#9923](https://github.com/besu-eth/besu/pull/9923)
- Improve MULMOD worst cases [#10088](https://github.com/besu-eth/besu/pull/10088)
- Optimized MUL and SUB to use UInt256 [#10030](https://github.com/besu-eth/besu/pull/10030)
- Use cache locality to improve Shift opcodes [#9878](https://github.com/besu-eth/besu/pull/9878)
- Defer Snappy decompression of inbound P2P messages from the Netty I/O thread to the worker thread, reducing memory held in the transaction worker queue to compressed size [#10048](https://github.com/besu-eth/besu/pull/10048)
- Dispatch snap server request processing (GET_ACCOUNT_RANGE, GET_STORAGE_RANGE, GET_BYTECODES, GET_TRIE_NODES, GET_BLOCK_ACCESS_LISTS) off the Netty event loop to prevent heavy trie/DB work from blocking ETH protocol message handling [#10083](https://github.com/besu-eth/besu/pull/10083)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright contributors to Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.vm.operations;

import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.operation.MulOperationOptimized;
import org.hyperledger.besu.evm.operation.Operation;

public class MulOperationOptimizedBenchmark extends BinaryOperationBenchmark {

@Override
protected Operation.OperationResult invoke(final MessageFrame frame) {
return MulOperationOptimized.staticOperation(frame);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright contributors to Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.vm.operations;

import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.operation.Operation;
import org.hyperledger.besu.evm.operation.SubOperationOptimized;

public class SubOperationOptimizedBenchmark extends BinaryOperationBenchmark {

@Override
protected Operation.OperationResult invoke(final MessageFrame frame) {
return SubOperationOptimized.staticOperation(frame);
}
}
12 changes: 10 additions & 2 deletions evm/src/main/java/org/hyperledger/besu/evm/EVM.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.hyperledger.besu.evm.operation.MulModOperation;
import org.hyperledger.besu.evm.operation.MulModOperationOptimized;
import org.hyperledger.besu.evm.operation.MulOperation;
import org.hyperledger.besu.evm.operation.MulOperationOptimized;
import org.hyperledger.besu.evm.operation.NotOperation;
import org.hyperledger.besu.evm.operation.NotOperationOptimized;
import org.hyperledger.besu.evm.operation.Operation;
Expand All @@ -79,6 +80,7 @@
import org.hyperledger.besu.evm.operation.SignExtendOperation;
import org.hyperledger.besu.evm.operation.StopOperation;
import org.hyperledger.besu.evm.operation.SubOperation;
import org.hyperledger.besu.evm.operation.SubOperationOptimized;
import org.hyperledger.besu.evm.operation.SwapNOperation;
import org.hyperledger.besu.evm.operation.SwapOperation;
import org.hyperledger.besu.evm.operation.VirtualOperation;
Expand Down Expand Up @@ -251,8 +253,14 @@ public void runToHalt(final MessageFrame frame, final OperationTracer tracing) {
evmConfiguration.enableOptimizedOpcodes()
? AddOperationOptimized.staticOperation(frame)
: AddOperation.staticOperation(frame);
case 0x02 -> MulOperation.staticOperation(frame);
case 0x03 -> SubOperation.staticOperation(frame);
case 0x02 ->
evmConfiguration.enableOptimizedOpcodes()
? MulOperationOptimized.staticOperation(frame)
: MulOperation.staticOperation(frame);
case 0x03 ->
evmConfiguration.enableOptimizedOpcodes()
? SubOperationOptimized.staticOperation(frame)
: SubOperation.staticOperation(frame);
Comment on lines +256 to +263
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runToHalt is on a hot path, and these new cases add more repeated calls to evmConfiguration.enableOptimizedOpcodes() during opcode dispatch. Consider caching the flag once (e.g., a local final boolean optimized = evmConfiguration.enableOptimizedOpcodes();) and using that in the switch cases to avoid repeated virtual/interface calls during interpretation.

Copilot uses AI. Check for mistakes.
case 0x04 ->
evmConfiguration.enableOptimizedOpcodes()
? DivOperationOptimized.staticOperation(frame)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright ConsenSys AG.
/*
* Copyright contributors to Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -32,7 +32,7 @@ public class MulOperationOptimized extends AbstractFixedCostOperation {
*
* @param gasCalculator the gas calculator
*/
public MulOperation(final GasCalculator gasCalculator) {
public MulOperationOptimized(final GasCalculator gasCalculator) {
super(0x02, "MUL", 2, 1, gasCalculator, gasCalculator.getLowTierGasCost());
}

Expand All @@ -57,6 +57,6 @@ public static OperationResult staticOperation(final MessageFrame frame) {
Bytes resultBytes = Bytes.wrap(u0.mul(u1).toBytesBE());

frame.pushStackItem(resultBytes);
return mulModSuccess;
return mulSuccess;
}
}
Loading