1
0
Fork 0
forked from forks/go-ethereum
go-ethereum-modded-tocallarg/eth/tracers/js
Satoshi Is Here 0db99f4e40
core/types: reduce allocations in tx.EffectiveGasTip (#31598)
This PR introduces an allocation-free version of the
Transaction.EffectiveGasTip method to improve performance by reducing
memory allocations.

## Changes
- Added a new `EffectiveGasTipInto` method that accepts a destination
parameter to avoid memory allocations
- Refactored the existing `EffectiveGasTip` method to use the new
allocation-free implementation
- Updated related methods (`EffectiveGasTipValue`, `EffectiveGasTipCmp`,
`EffectiveGasTipIntCmp`) to use the allocation-free approach
- Added tests and benchmarks to verify correctness and measure
performance improvements

## Motivation
In high-transaction-volume environments, the `EffectiveGasTip` method is
called frequently. Reducing memory allocations in this method decreases
garbage collection pressure and improves overall system performance.

## Benchmark Results

As-Is
BenchmarkEffectiveGasTip/Original-10 42089140 27.45 ns/op 8 B/op 1
allocs/op

To-Be
BenchmarkEffectiveGasTip/IntoMethod-10 72353263 16.73 ns/op 0 B/op 0
allocs/op


## Summary of Improvements
- **Performance**: ~39% faster execution (27.45 ns/op → 16.73 ns/op)
- **Memory**: Eliminated all allocations (8 B/op → 0 B/op)
- **Allocation count**: Reduced from 1 to 0 allocations per operation

This optimization follows the same pattern successfully applied to other
methods in the codebase, maintaining API compatibility while improving
performance.

## Safety & Compatibility
This optimization has no side effects or adverse impacts because:
- It maintains functional equivalence as confirmed by comprehensive
tests
- It preserves API compatibility with existing callers
- It follows clear memory ownership patterns with the destination
parameter
- It maintains thread safety by only modifying the caller-provided
destination parameter

This optimization follows the same pattern successfully applied to other
methods in the codebase, providing better performance without
compromising stability or correctness.

---------

Co-authored-by: lightclient <lightclient@protonmail.com>
2025-05-09 12:56:00 +02:00
..
internal/tracers all: fix typos in comments (#28881) 2024-02-05 22:16:32 +01:00
bigint.go eth/tracers: package restructuring (#23857) 2021-11-09 12:09:35 +01:00
goja.go core/types: reduce allocations in tx.EffectiveGasTip (#31598) 2025-05-09 12:56:00 +02:00
tracer_test.go core/vm: clean up EVM environmental structure (#31061) 2025-02-18 21:53:33 +08:00