Skip to content

perf(gnovm): skip store probe for synthetic package paths#5900

Open
omarsy wants to merge 1 commit into
gnolang:masterfrom
omarsy:pr/skip-synthetic-path-probe
Open

perf(gnovm): skip store probe for synthetic package paths#5900
omarsy wants to merge 1 commit into
gnolang:masterfrom
omarsy:pr/skip-synthetic-path-probe

Conversation

@omarsy

@omarsy omarsy commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

Every transaction's preprocessing calls evalConst, which spins up a throwaway Machine with the compiler-internal PkgPath == ".dontcare". NewMachineWithOptions then calls store.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. GetPackage now consults only the per-tx object cache for them and returns early, skipping both the backend read and the pkgGetter.

oid := ObjectIDFromPkgPath(pkgPath)
// Synthetic packages are never persisted: check only the cache — a
// backend read would be a guaranteed miss charged as a full I/O
// read, and the pkgGetter cannot resolve them either.
if IsSyntheticPath(pkgPath) {
    if oo, exists := ds.cacheObjects[oid]; exists {
        return oo.(*PackageValue)
    }
    return nil
}

A named IsSyntheticPath predicate is added alongside the existing path predicates (IsRealmPath, IsEphemeralPath, …) in mempackage.go so the convention is named rather than an inline byte check.

Impact

Every transaction is exactly 59,000 gas cheaper. Measured on the gnokey_gasfee integration flow:

tx before after
call Hello() 1,270,991 1,211,991
addpkg r/hello 2,815,572 2,756,572

Each affected gas golden was verified to shift by exactly −59,000 (a single avoided flat store read), confirming no other behavior changed.

Ephemeral /e/…/run paths (MsgRun) do not flow through GetPackage, so they are out of scope here.

Changed files

  • Codegnovm/pkg/gnolang/store.go (early-exit in GetPackage), gnovm/pkg/gnolang/mempackage.go (new IsSyntheticPath predicate).
  • Test goldensgno.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

@github-actions github-actions Bot added 📦 🤖 gnovm Issues or PRs gnovm related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Jul 3, 2026
@Gno2D2 Gno2D2 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jul 3, 2026
@Gno2D2

Gno2D2 commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

🛠 PR Checks Summary

🔴 Pending initial approval by a review team member, or review from tech-staff

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
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)
🔴 Pending initial approval by a review team member, or review from tech-staff

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: omarsy/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Pending initial approval by a review team member, or review from tech-staff

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🔴 Requirement not satisfied
└── 🔴 If
    ├── 🔴 Condition
    │   └── 🔴 Or
    │       ├── 🔴 At least one of these user(s) reviewed the pull request: [aronpark1007 davd-gzl jefft0 notJoon omarsy MikaelVallenet] (with state "APPROVED")
    │       ├── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request
    │       └── 🔴 This pull request is a draft
    └── 🔴 Else
        └── 🔴 And
            ├── 🟢 This label is applied to pull request: review/triage-pending
            └── 🔴 On no pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

@omarsy omarsy requested review from a team, ltzmaxwell and thehowl July 3, 2026 18:04
@omarsy omarsy force-pushed the pr/skip-synthetic-path-probe branch from bb945cf to 1bc3fa0 Compare July 3, 2026 18:19
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).
@omarsy omarsy force-pushed the pr/skip-synthetic-path-probe branch from 1bc3fa0 to 69be9a6 Compare July 3, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related review/triage-pending PRs opened by external contributors that are waiting for the 1st review

Projects

Development

Successfully merging this pull request may close these issues.

2 participants