perf(gnovm): skip store probe for synthetic package paths#5900
Open
omarsy wants to merge 1 commit into
Open
Conversation
Collaborator
🛠 PR Checks Summary🔴 Pending initial approval by a review team member, or review from tech-staff Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
bb945cf to
1bc3fa0
Compare
Every transaction's preprocessing calls evalConst, which creates a throwaway machine with the compiler-internal PkgPath ".dontcare". NewMachineWithOptions then asked the store for that package: a guaranteed backend miss charged as a full I/O read (59,000 gas), once per transaction. Synthetic (dot-prefixed) packages are never persisted, so GetPackage now consults only the per-tx object cache for them, skipping the backend read and the pkgGetter. Adds the IsSyntheticPath predicate alongside the other path predicates. Every tx gets exactly 59,000 gas cheaper; txtar gas goldens updated accordingly (verified each delta is exactly -59,000).
1bc3fa0 to
69be9a6
Compare
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
Every transaction's preprocessing calls
evalConst, which spins up a throwawayMachinewith the compiler-internalPkgPath == ".dontcare".NewMachineWithOptionsthen callsstore.GetPackage(".dontcare", …), which fell through the per-tx object cache to a backend store read — a guaranteed miss, charged as a full I/O read of 59,000 gas, once per transaction.Synthetic (dot-prefixed) package paths (
.uverse,.dontcare, …) are never persisted and cannot appear in user source, so there is nothing in the backend to find.GetPackagenow consults only the per-tx object cache for them and returns early, skipping both the backend read and thepkgGetter.A named
IsSyntheticPathpredicate is added alongside the existing path predicates (IsRealmPath,IsEphemeralPath, …) inmempackage.goso the convention is named rather than an inline byte check.Impact
Every transaction is exactly 59,000 gas cheaper. Measured on the
gnokey_gasfeeintegration flow:call Hello()addpkg r/helloEach affected gas golden was verified to shift by exactly −59,000 (a single avoided flat store read), confirming no other behavior changed.
Ephemeral
/e/…/runpaths (MsgRun) do not flow throughGetPackage, so they are out of scope here.Changed files
gnovm/pkg/gnolang/store.go(early-exit inGetPackage),gnovm/pkg/gnolang/mempackage.go(newIsSyntheticPathpredicate).gno.land/pkg/integration/testdata/{gnokey_gasfee,gc,restart_gas,simulate_gas,stdlib_ibc_crypto_determinism,stdlib_restart_compare}.txtar, each −59,000 gas.Verification
go test ./gno.land/pkg/sdk/vm/ -run Gas✅go test ./gno.land/pkg/integration/ -run TestTestdata✅ (goldens regenerated)go test ./gnovm/pkg/gnolang/ -run Files -test.short✅🤖 Generated with Claude Code