1
0
Fork 0
forked from forks/go-ethereum
go-ethereum-modded-tocallarg/eth/tracers
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 eth/tracers: refactor block context in test runner (#29450) 2025-02-20 15:04:35 +01:00
js core/types: reduce allocations in tx.EffectiveGasTip (#31598) 2025-05-09 12:56:00 +02:00
live core/tracing: state journal wrapper (#30441) 2025-02-05 13:58:25 +01:00
logger internal/ethapi: exclude 7702 authorities from result in eth_createAccessList (#31336) 2025-03-25 15:01:21 +01:00
native all: update license comments and AUTHORS (#31133) 2025-02-05 23:01:17 +01:00
api.go eth/tracers: fix standardTraceBlockToFile (#31763) 2025-05-05 16:15:59 +02:00
api_test.go eth/tracers: fix standardTraceBlockToFile (#31763) 2025-05-05 16:15:59 +02:00
dir.go all: update license comments and AUTHORS (#31133) 2025-02-05 23:01:17 +01:00
live.go eth/tracers: various fixes (#30540) 2024-10-17 06:51:47 +02:00
tracers_test.go cmd/evm: consolidate evm output switches (#30849) 2024-12-10 09:43:24 +01:00
tracker.go eth/traces: add state limit (#25812) 2022-10-06 10:48:04 +02:00
tracker_test.go all: update license comments and AUTHORS (#31133) 2025-02-05 23:01:17 +01:00