Skip to content

perf(limit): cache net_usage in FrameLimitTracker#298

Merged
RealiCZ merged 3 commits into
mainfrom
wanglang/perf/cache-net-usage-in-frame-tracker
May 22, 2026
Merged

perf(limit): cache net_usage in FrameLimitTracker#298
RealiCZ merged 3 commits into
mainfrom
wanglang/perf/cache-net-usage-in-frame-tracker

Conversation

@WonderLawrence
Copy link
Copy Markdown
Contributor

@WonderLawrence WonderLawrence commented May 20, 2026

Summary

  • AdditionalLimit::check_limit runs on every opcode and fans out to four sub-trackers, each previously walking the full frame stack inside FrameLimitTracker::net_usage — making the hot path O(depth) per tracker per opcode even when only compute_gas actually mutated state.
  • Maintain Σ(persistent + discardable) and Σ refund incrementally on FrameLimitTracker via cached_total_used / cached_total_refund, so net_usage() becomes a single saturating_sub.
  • All mutations now go through cache-aware helpers (add_tx_persistent, add_frame_persistent, add_frame_discardable, add_frame_refund) and the existing pop_frame, which on revert subtracts the child's discardable_usage and refund from the cache (those values vanish rather than being merged into the parent). The four sub-trackers (compute_gas, data_size, kv_update, state_growth) are updated to call the helpers instead of touching FrameLimitEntry fields directly. The unused tx_mut accessor is removed.

Behavior

  • No semantic change. net_usage() still uses saturating_sub, so the transient refund > used state observed in state_growth continues to clamp to zero externally.
  • All four resource dimensions (compute gas / data size / KV updates / state growth) follow the same cache invariant; revert paths are unwound through pop_frame as before.

Test plan

  • cargo fmt --all --check
  • cargo clippy --workspace --lib --examples --tests --benches --all-features --locked
  • Existing crates/mega-evm/tests/ suites covering frame revert / refund accounting (relied on in CI)
  • Benchmark sanity check on transact to confirm the hot-path improvement is realized

The per-opcode hot path runs AdditionalLimit::check_limit on every
instruction, which in turn invokes each of the four sub-trackers'
check_limit -> tx_usage -> FrameLimitTracker::net_usage. The previous
implementation recomputed net_usage by walking the entire frame stack
and calling FrameLimitEntry::used() (checked_add + expect) on every
entry, making it O(depth) per tracker per opcode -- even though only
compute_gas mutates its state on a typical arithmetic/stack/control
opcode.

Maintain Σ(persistent + discardable) and Σ refund incrementally on
FrameLimitTracker, so net_usage() is a single saturating_sub. All
mutations now go through four cache-aware helpers (add_tx_persistent,
add_frame_persistent, add_frame_discardable, add_frame_refund) and the
existing pop_frame, which subtracts the child's discardable_usage and
refund from the cache on revert (those values vanish rather than being
merged into the parent). The four sub-trackers are updated to call the
helpers instead of touching FrameLimitEntry fields directly.

Behavior is unchanged: net_usage uses saturating_sub as before, so the
transient negative state (refund > used) observed in state_growth still
clamps to zero externally. The unused tx_mut accessor is removed.
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 20, 2026

Labels comp:core, spec:unchanged, and api:unchanged have been applied — thank you. One label from the original suggestion is still missing:

  • rust — only Rust source files are modified in this PR

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.7%. Comparing base (ab851be) to head (7e15aa5).

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 20, 2026

The cache invariant is correctly maintained across all paths:

  • All mutations to persistent_usage, discardable_usage, and refund are funnelled through the four new helpers — no surviving frame_mut() call touches those fields directly.
  • pop_frame on revert correctly subtracts child.discardable_usage and child.refund from the respective cache totals; the successful-merge path requires no cache adjustment since values are just relocated between entries.
  • reset and frame-push (zero-initialised entries) both preserve the invariant.

One gap against CLAUDE.md policy: the benchmark checkbox is explicitly unchecked. The guideline requires hot-path changes to be validated locally with cargo bench -p mega-evm --bench transact before merging. Please run it and confirm the expected speedup (and no panics) before this lands.

@RealiCZ
Copy link
Copy Markdown
Collaborator

RealiCZ commented May 20, 2026

/benchmark

@github-actions
Copy link
Copy Markdown

Criterion Benchmark Comparison

Comparing baselinefeature

147 benchmarks total, 72 with >5% change
Benchmark Baseline Feature Delta
add/mini_rex 17.1 us 15.3 us -10.8% 🚀
address/mini_rex 8.6 us 7.6 us -11.5% 🚀
analysis/equivalence 21.8 us 20.4 us -6.4%
analysis/mini_rex 29.0 us 26.6 us -8.4%
analysis/rex4 30.5 us 26.5 us -12.8% 🚀
batch_transfer_high_complexity_1x1/equivalence 245.5 us 245.4 us -0.1%
batch_transfer_high_complexity_1x1/mini_rex 758.5 us 470.7 us -37.9% 🚀
batch_transfer_high_contention_10x10/equivalence 442.8 us 463.4 us +4.6%
batch_transfer_high_contention_10x10/mini_rex 1382.2 us 972.5 us -29.6% 🚀
batch_transfer_little_complexity_1x1/equivalence 29.7 us 31.3 us +5.4%
batch_transfer_little_complexity_1x1/mini_rex 82.6 us 57.0 us -31.1% 🚀
batch_transfer_low_contention_1x1/equivalence 17.1 us 18.2 us +6.3%
batch_transfer_low_contention_1x1/mini_rex 46.9 us 33.9 us -27.6% 🚀
batch_transfer_medium_complexity_1x1/equivalence 131.4 us 132.9 us +1.2%
batch_transfer_medium_complexity_1x1/mini_rex 404.7 us 251.6 us -37.8% 🚀
batch_transfer_medium_contention_5x5/equivalence 131.9 us 140.8 us +6.7%
batch_transfer_medium_contention_5x5/mini_rex 395.9 us 281.6 us -28.9% 🚀
batch_transfer_some_complexity_5x5/equivalence 807.4 us 817.2 us +1.2%
batch_transfer_some_complexity_5x5/mini_rex 2477.7 us 1569.9 us -36.6% 🚀
block_executor_deploy/rex4/deploy_1 27.4 us 27.4 us -0.0%
block_executor_empty_txs/rex4/10_txs 71.3 us 69.5 us -2.5%
block_executor_empty_txs/rex4/1_txs 27.0 us 26.7 us -1.1%
block_executor_empty_txs/rex4/50_txs 267.2 us 258.5 us -3.3%
block_executor_mixed_txs/rex4/10_txs 229.8 us 213.4 us -7.2%
block_executor_mixed_txs/rex4/1_txs 49.9 us 48.2 us -3.4%
block_executor_spec_comparison/equivalence/5_mixed_txs 89.3 us 89.6 us +0.3%
block_executor_spec_comparison/mini_rex/5_mixed_txs 69.0 us 68.5 us -0.7%
block_executor_spec_comparison/rex4/5_mixed_txs 130.0 us 122.1 us -6.1%
block_executor_spec_comparison/rex5/5_mixed_txs 130.4 us 122.8 us -5.9%
call_value_empty_account/equivalence/empty_account_50 36.1 us 34.4 us -4.7%
call_value_empty_account/equivalence/existing_account_50 35.0 us 34.6 us -1.0%
call_value_empty_account/mini_rex/empty_account_50 53.3 us 48.3 us -9.5%
call_value_empty_account/mini_rex/existing_account_50 52.1 us 47.9 us -8.1%
call_value_empty_account/rex4/empty_account_50 55.1 us 50.4 us -8.5%
call_value_empty_account/rex4/existing_account_50 55.1 us 50.3 us -8.8%
create_deploy/equivalence/create2_10 23.8 us 24.3 us +2.0%
create_deploy/equivalence/create_10 19.3 us 19.5 us +1.0%
create_deploy/mini_rex/create2_10 36.9 us 35.3 us -4.1%
create_deploy/mini_rex/create_10 27.9 us 26.3 us -5.8%
create_deploy/rex4/create2_10 37.4 us 36.1 us -3.6%
create_deploy/rex4/create_10 28.3 us 26.5 us -6.2%
delegatecall_system_contract/rex4/delegatecall_not_intercepted 5.9 us 5.9 us -0.7%
delegatecall_system_contract/rex4/staticcall_intercepted 6.2 us 6.2 us -0.5%
empty_transaction/equivalence 3.3 us 3.3 us -1.9%
empty_transaction/mini_rex 3.8 us 3.5 us -6.9%
exp_256bit/mini_rex 280.9 us 279.1 us -0.7%
gas_detention_computation/equivalence/compute_only_500 40.6 us 40.2 us -0.9%
gas_detention_computation/equivalence/volatile_then_compute_500 43.8 us 43.6 us -0.5%
gas_detention_computation/mini_rex/compute_only_500 69.6 us 57.2 us -17.9% 🚀
gas_detention_computation/mini_rex/volatile_then_compute_500 69.8 us 56.8 us -18.5% 🚀
gas_detention_computation/rex4/compute_only_500 74.9 us 62.4 us -16.8% 🚀
gas_detention_computation/rex4/volatile_then_compute_500 75.0 us 62.5 us -16.6% 🚀
keccak256_1KB/mini_rex 331.3 us 328.8 us -0.7%
keccak256_32B/mini_rex 58.7 us 56.7 us -3.3%
log_opcodes/equivalence/log0_256b 10.0 us 10.1 us +0.3%
log_opcodes/equivalence/log0_32b 10.1 us 10.1 us -0.3%
log_opcodes/equivalence/log2_32b 15.5 us 15.4 us -0.9%
log_opcodes/equivalence/log4_256b 19.1 us 19.0 us -0.5%
log_opcodes/equivalence/log4_32b 19.1 us 18.9 us -1.2%
log_opcodes/mini_rex/log0_256b 13.6 us 12.3 us -9.9%
log_opcodes/mini_rex/log0_32b 13.6 us 12.5 us -8.6%
log_opcodes/mini_rex/log2_32b 21.7 us 18.9 us -12.9% 🚀
log_opcodes/mini_rex/log4_256b 26.7 us 24.0 us -10.3% 🚀
log_opcodes/mini_rex/log4_32b 26.7 us 24.1 us -9.5%
log_opcodes/rex4/log0_256b 14.3 us 13.0 us -9.3%
log_opcodes/rex4/log0_32b 14.1 us 12.9 us -8.9%
log_opcodes/rex4/log2_32b 22.2 us 19.7 us -11.2% 🚀
log_opcodes/rex4/log4_256b 27.7 us 25.0 us -9.7%
log_opcodes/rex4/log4_32b 27.7 us 25.1 us -9.4%
mixed_workload/equivalence 16.4 us 16.6 us +1.1%
mixed_workload/mini_rex 28.0 us 26.3 us -6.0%
mixed_workload/rex4 27.9 us 26.4 us -5.7%
oracle_sload/equivalence/oracle_sload_50 15.1 us 15.1 us -0.5%
oracle_sload/equivalence/regular_sload_50 15.0 us 15.1 us +0.5%
oracle_sload/mini_rex/oracle_sload_50 17.6 us 16.7 us -5.1%
oracle_sload/mini_rex/regular_sload_50 17.6 us 16.7 us -4.7%
oracle_sload/rex4/oracle_sload_50 18.6 us 17.7 us -4.8%
oracle_sload/rex4/regular_sload_50 18.1 us 17.6 us -2.9%
precompile_blake2f_1round/mini_rex 123.3 us 109.3 us -11.3% 🚀
precompile_bls12_381_g1add/mini_rex 555.6 us 543.2 us -2.2%
precompile_bls12_381_g1msm/mini_rex 19998.3 us 20022.4 us +0.1%
precompile_bls12_381_g2add/mini_rex 785.4 us 767.7 us -2.3%
precompile_bls12_381_g2msm/mini_rex 38572.9 us 38526.8 us -0.1%
precompile_bls12_381_map_fp2_to_g2/mini_rex 17709.3 us 17681.2 us -0.2%
precompile_bls12_381_map_fp_to_g1/mini_rex 5531.7 us 5537.1 us +0.1%
precompile_bls12_381_pairing/mini_rex 121639.3 us 121453.0 us -0.2%
precompile_ecadd/mini_rex 489.8 us 474.8 us -3.0%
precompile_ecmul/mini_rex 502.7 us 489.5 us -2.6%
precompile_ecpairing/mini_rex 142881.9 us 143224.3 us +0.2%
precompile_ecrecover/mini_rex 4634.9 us 4628.2 us -0.1%
precompile_kzg_point_evaluation/mini_rex 143550.1 us 142822.6 us -0.5%
precompile_modexp_32B/mini_rex 3261.1 us 3275.5 us +0.4%
precompile_ripemd160_1KB/mini_rex 506.7 us 493.8 us -2.5%
precompile_ripemd160_32B/mini_rex 144.5 us 132.8 us -8.1%
precompile_sha256_1KB/mini_rex 194.7 us 183.8 us -5.6%
precompile_sha256_32B/mini_rex 125.2 us 114.7 us -8.4%
rex5_pre_block/bootstrap 18.8 us 18.6 us -1.0%
rex5_pre_block/no_change 12.2 us 12.0 us -1.2%
selfdestruct/equivalence 4.5 us 4.6 us +1.2%
selfdestruct/rex2 5.0 us 5.0 us +0.1%
selfdestruct/rex4 5.0 us 5.1 us +1.3%
simple_ether_transfer/equivalence 3.5 us 3.4 us -5.3%
simple_ether_transfer/mini_rex 4.0 us 3.6 us -8.5%
snailtracer/equivalence 56200.6 us 58685.3 us +4.4%
snailtracer/mini_rex 195588.4 us 137943.4 us -29.5% 🚀
snailtracer/rex4 211702.6 us 157693.5 us -25.5% 🚀
sstore_heavy/equivalence/sload_100 24.9 us 25.0 us +0.5%
sstore_heavy/equivalence/sstore_100 33.5 us 33.8 us +0.8%
sstore_heavy/equivalence/sstore_sload_100 44.2 us 44.9 us +1.6%
sstore_heavy/mini_rex/sload_100 29.3 us 27.6 us -5.8%
sstore_heavy/mini_rex/sstore_100 69.4 us 67.6 us -2.5%
sstore_heavy/mini_rex/sstore_sload_100 84.0 us 80.1 us -4.6%
sstore_heavy/rex4/sload_100 30.6 us 29.3 us -4.2%
sstore_heavy/rex4/sstore_100 68.0 us 65.9 us -3.1%
sstore_heavy/rex4/sstore_sload_100 83.0 us 79.4 us -4.3%
subcall_1000_nested/equivalence 1154.8 us 1026.3 us -11.1% 🚀
subcall_1000_nested/mini_rex 2076.9 us 1693.8 us -18.4% 🚀
subcall_1000_nested/rex4 2147.3 us 1793.6 us -16.5% 🚀
subcall_1000_no_value/equivalence 599.7 us 530.1 us -11.6% 🚀
subcall_1000_no_value/mini_rex 1108.5 us 864.3 us -22.0% 🚀
subcall_1000_no_value/rex4 1152.6 us 917.7 us -20.4% 🚀
subcall_1000_transfer_1wei/equivalence 416.2 us 384.0 us -7.7%
subcall_1000_transfer_1wei/mini_rex 883.9 us 727.6 us -17.7% 🚀
subcall_1000_transfer_1wei/rex4 933.9 us 755.6 us -19.1% 🚀
system_contract_100x/rex4/access_control 116.5 us 104.6 us -10.2% 🚀
system_contract_100x/rex4/limit_control 109.4 us 99.5 us -9.0%
system_contract_100x/rex4/regular_contract 124.0 us 110.5 us -10.9% 🚀
system_contract_single/rex4/access_control 6.2 us 6.1 us -1.1%
system_contract_single/rex4/limit_control 6.1 us 6.1 us -0.6%
system_contract_single/rex4/regular_contract 6.8 us 6.7 us -1.5%
transfer_multi_1000/equivalence 1680.5 us 1638.6 us -2.5%
transfer_multi_1000/mini_rex 1944.3 us 1903.1 us -2.1%
transfer_multi_1000/rex4 2027.0 us 1952.3 us -3.7%
volatile_data/equivalence/baseline_add 11.4 us 11.5 us +0.8%
volatile_data/equivalence/coinbase 5.6 us 5.7 us +2.3%
volatile_data/equivalence/number 5.6 us 5.7 us +0.5%
volatile_data/equivalence/timestamp 5.6 us 5.6 us +0.6%
volatile_data/mini_rex/baseline_add 17.6 us 15.2 us -13.8% 🚀
volatile_data/mini_rex/coinbase 9.4 us 8.0 us -14.7% 🚀
volatile_data/mini_rex/number 9.2 us 8.0 us -12.7% 🚀
volatile_data/mini_rex/timestamp 9.2 us 7.8 us -14.7% 🚀
volatile_data/rex4/baseline_add 18.8 us 16.3 us -13.3% 🚀
volatile_data/rex4/coinbase 10.0 us 8.6 us -14.1% 🚀
volatile_data/rex4/number 9.8 us 8.4 us -14.2% 🚀
volatile_data/rex4/timestamp 9.9 us 8.4 us -14.5% 🚀
weth9_transfer/equivalence 18.4 us 18.2 us -0.6%
weth9_transfer/mini_rex 24.6 us 22.2 us -9.8%

Significant changes (>5%):

Benchmark Baseline Feature Delta
add/mini_rex 17.1 us 15.3 us -10.8% 🚀
address/mini_rex 8.6 us 7.6 us -11.5% 🚀
analysis/equivalence 21.8 us 20.4 us -6.4%
analysis/mini_rex 29.0 us 26.6 us -8.4%
analysis/rex4 30.5 us 26.5 us -12.8% 🚀
batch_transfer_high_complexity_1x1/mini_rex 758.5 us 470.7 us -37.9% 🚀
batch_transfer_high_contention_10x10/mini_rex 1382.2 us 972.5 us -29.6% 🚀
batch_transfer_little_complexity_1x1/equivalence 29.7 us 31.3 us +5.4%
batch_transfer_little_complexity_1x1/mini_rex 82.6 us 57.0 us -31.1% 🚀
batch_transfer_low_contention_1x1/equivalence 17.1 us 18.2 us +6.3%
batch_transfer_low_contention_1x1/mini_rex 46.9 us 33.9 us -27.6% 🚀
batch_transfer_medium_complexity_1x1/mini_rex 404.7 us 251.6 us -37.8% 🚀
batch_transfer_medium_contention_5x5/equivalence 131.9 us 140.8 us +6.7%
batch_transfer_medium_contention_5x5/mini_rex 395.9 us 281.6 us -28.9% 🚀
batch_transfer_some_complexity_5x5/mini_rex 2477.7 us 1569.9 us -36.6% 🚀
block_executor_mixed_txs/rex4/10_txs 229.8 us 213.4 us -7.2%
block_executor_spec_comparison/rex4/5_mixed_txs 130.0 us 122.1 us -6.1%
block_executor_spec_comparison/rex5/5_mixed_txs 130.4 us 122.8 us -5.9%
call_value_empty_account/mini_rex/empty_account_50 53.3 us 48.3 us -9.5%
call_value_empty_account/mini_rex/existing_account_50 52.1 us 47.9 us -8.1%
call_value_empty_account/rex4/empty_account_50 55.1 us 50.4 us -8.5%
call_value_empty_account/rex4/existing_account_50 55.1 us 50.3 us -8.8%
create_deploy/mini_rex/create_10 27.9 us 26.3 us -5.8%
create_deploy/rex4/create_10 28.3 us 26.5 us -6.2%
empty_transaction/mini_rex 3.8 us 3.5 us -6.9%
gas_detention_computation/mini_rex/compute_only_500 69.6 us 57.2 us -17.9% 🚀
gas_detention_computation/mini_rex/volatile_then_compute_500 69.8 us 56.8 us -18.5% 🚀
gas_detention_computation/rex4/compute_only_500 74.9 us 62.4 us -16.8% 🚀
gas_detention_computation/rex4/volatile_then_compute_500 75.0 us 62.5 us -16.6% 🚀
log_opcodes/mini_rex/log0_256b 13.6 us 12.3 us -9.9%
log_opcodes/mini_rex/log0_32b 13.6 us 12.5 us -8.6%
log_opcodes/mini_rex/log2_32b 21.7 us 18.9 us -12.9% 🚀
log_opcodes/mini_rex/log4_256b 26.7 us 24.0 us -10.3% 🚀
log_opcodes/mini_rex/log4_32b 26.7 us 24.1 us -9.5%
log_opcodes/rex4/log0_256b 14.3 us 13.0 us -9.3%
log_opcodes/rex4/log0_32b 14.1 us 12.9 us -8.9%
log_opcodes/rex4/log2_32b 22.2 us 19.7 us -11.2% 🚀
log_opcodes/rex4/log4_256b 27.7 us 25.0 us -9.7%
log_opcodes/rex4/log4_32b 27.7 us 25.1 us -9.4%
mixed_workload/mini_rex 28.0 us 26.3 us -6.0%
mixed_workload/rex4 27.9 us 26.4 us -5.7%
oracle_sload/mini_rex/oracle_sload_50 17.6 us 16.7 us -5.1%
precompile_blake2f_1round/mini_rex 123.3 us 109.3 us -11.3% 🚀
precompile_ripemd160_32B/mini_rex 144.5 us 132.8 us -8.1%
precompile_sha256_1KB/mini_rex 194.7 us 183.8 us -5.6%
precompile_sha256_32B/mini_rex 125.2 us 114.7 us -8.4%
simple_ether_transfer/equivalence 3.5 us 3.4 us -5.3%
simple_ether_transfer/mini_rex 4.0 us 3.6 us -8.5%
snailtracer/mini_rex 195588.4 us 137943.4 us -29.5% 🚀
snailtracer/rex4 211702.6 us 157693.5 us -25.5% 🚀
sstore_heavy/mini_rex/sload_100 29.3 us 27.6 us -5.8%
subcall_1000_nested/equivalence 1154.8 us 1026.3 us -11.1% 🚀
subcall_1000_nested/mini_rex 2076.9 us 1693.8 us -18.4% 🚀
subcall_1000_nested/rex4 2147.3 us 1793.6 us -16.5% 🚀
subcall_1000_no_value/equivalence 599.7 us 530.1 us -11.6% 🚀
subcall_1000_no_value/mini_rex 1108.5 us 864.3 us -22.0% 🚀
subcall_1000_no_value/rex4 1152.6 us 917.7 us -20.4% 🚀
subcall_1000_transfer_1wei/equivalence 416.2 us 384.0 us -7.7%
subcall_1000_transfer_1wei/mini_rex 883.9 us 727.6 us -17.7% 🚀
subcall_1000_transfer_1wei/rex4 933.9 us 755.6 us -19.1% 🚀
system_contract_100x/rex4/access_control 116.5 us 104.6 us -10.2% 🚀
system_contract_100x/rex4/limit_control 109.4 us 99.5 us -9.0%
system_contract_100x/rex4/regular_contract 124.0 us 110.5 us -10.9% 🚀
volatile_data/mini_rex/baseline_add 17.6 us 15.2 us -13.8% 🚀
volatile_data/mini_rex/coinbase 9.4 us 8.0 us -14.7% 🚀
volatile_data/mini_rex/number 9.2 us 8.0 us -12.7% 🚀
volatile_data/mini_rex/timestamp 9.2 us 7.8 us -14.7% 🚀
volatile_data/rex4/baseline_add 18.8 us 16.3 us -13.3% 🚀
volatile_data/rex4/coinbase 10.0 us 8.6 us -14.1% 🚀
volatile_data/rex4/number 9.8 us 8.4 us -14.2% 🚀
volatile_data/rex4/timestamp 9.9 us 8.4 us -14.5% 🚀
weth9_transfer/mini_rex 24.6 us 22.2 us -9.8%

147 benchmarks: 0 regressions, 0 warnings, 38 improvements

Make FrameLimitEntry budget fields module-private so the cache invariant
is type-system enforced. Add a debug-only net_usage_uncached() reference
walk and assert per-call equivalence so any future mutation bypassing a
helper trips on every opcode in debug/test builds. Add a focused unit
test exercising push/mutate/pop sequences across success and revert.
Copy link
Copy Markdown
Collaborator

@Troublor Troublor left a comment

Choose a reason for hiding this comment

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

LGTM

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 22, 2026

LGTM. The cache invariant is correctly maintained across every mutation path — helpers update both the entry and the cache atomically, and pop_frame on revert subtracts the child's discardable/refund from the totals without touching persistent (which just relocates). The debug-mode assertion in net_usage() against net_usage_uncached() is a strong guard. Benchmark results confirm the expected speedup (up to 38% on call-heavy workloads, 25-30% on snailtracer).

lychee >=0.24 changed `include_fragments` from bool to enum.
Use "full" to preserve the previous behavior (anchor + text fragments).
@Troublor Troublor added spec:unchanged No change to any `mega-evm`'s behavior comp:core Changes to the `mega-evm` core crate api:unchanged No change to the public interface or API labels May 22, 2026
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 22, 2026

LGTM. All prior feedback addressed — benchmarks ran and confirmed (up to 38% improvement on call-heavy workloads, no regressions). Cache invariant is sound: helpers atomically update both the entry and the cached totals, pop_frame correctly subtracts only the child's discardable/refund on revert (persistent just relocates so no cache delta needed), and the debug-mode assertion in net_usage() guards against future mutation sites that bypass the helpers.

@RealiCZ RealiCZ merged commit 9c7300d into main May 22, 2026
23 checks passed
@RealiCZ RealiCZ deleted the wanglang/perf/cache-net-usage-in-frame-tracker branch May 22, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api:unchanged No change to the public interface or API comp:core Changes to the `mega-evm` core crate spec:unchanged No change to any `mega-evm`'s behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants