perf: cache proxy detection misses#2786
Open
banteg wants to merge 3 commits into
Open
Conversation
0eb95f9 to
d2ee438
Compare
d2ee438 to
0a7f154
Compare
|
This pull request is considered stale because it has been open 30 days with no activity. Remove stale label, add a comment, or make a new commit, otherwise this PR will be closed in 5 days. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
proxy_infodisk cache by writing JSONnullfor addresses confirmed not to be proxies.ProxyInfoAPI | Noneresults.ecosystem.get_proxy_info()whenproxy_info/<address>.jsonalready exists, whether it contains proxy info ornull.ProxyInfoAPI | None, so a negative marker never becomes fake proxy info.Performance implications
This removes repeat proxy-detection work for contracts already known not to be proxies. That matters on the contract lookup hot path because a miss currently still re-enters
get_proxy_info()every time when no contract type is cached.For bytecode with no storage-backed proxy shape, the improvement is mostly CPU/cache lookup overhead. For non-proxy bytecode that contains
DELEGATECALL, thenullmarker also avoids repeated storage probes.Live local Reth mainnet archive-node check from the previous implementation of the same no-hit behavior:
Benchmark setup used 20 repeated
chain.contracts.get(..., fetch_from_explorer=False, fetch_from_disk=False)calls withChainManagercode cache pre-warmed. The "before" case clears the negative marker between calls to simulate current behavior; the "after" case keeps it.Tests
uv run ruff check src/ape/managers/_contractscache.py src/ape/utils/os.py tests/functional/test_contracts_cache.pyuv run ruff format --check src/ape/managers/_contractscache.py src/ape/utils/os.py tests/functional/test_contracts_cache.pyuv run mypy src/ape/managers/_contractscache.py src/ape/utils/os.pyuv run pytest tests/functional/test_contracts_cache.pyCommit hook note: full-repo
mypystill fails on unrelated existing errors insrc/ape/cli/choices.py,src/ape/api/config.py, andsrc/ape_ethereum/ecosystem.py.