Skip to content

feat(gnovm): fill in 3779, the gc PR #3789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

ltzmaxwell
Copy link
Contributor

@ltzmaxwell ltzmaxwell commented Feb 19, 2025

This PR is trying to complete the work outlined in #3779 .

It completes the visit logic and introduces benchmarking and gas consumption tracking.

@github-actions github-actions bot added 📦 🤖 gnovm Issues or PRs gnovm related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Feb 19, 2025
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Feb 19, 2025

🛠 PR Checks Summary

All Automated Checks passed. ✅

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):

No automated checks match this pull request.

☑️ 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
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

@Kouteki Kouteki added this to the 🚀 Mainnet beta launch milestone Feb 24, 2025
@Kouteki Kouteki requested a review from jaekwon February 25, 2025 13:39
@ltzmaxwell ltzmaxwell marked this pull request as draft February 25, 2025 15:20
@ltzmaxwell ltzmaxwell changed the title WIP: feat(gnovm): fill in gc feat(gnovm): fill in 3779, the gc PR Mar 3, 2025
@ltzmaxwell ltzmaxwell marked this pull request as ready for review March 3, 2025 09:01
@Kouteki Kouteki removed the request for review from petar-dambovaliev April 7, 2025 09:47
func (fv *FuncValue) VisitAssociated(vis Visitor) (stop bool) {
// visit captures
for _, tv := range fv.Captures {
stop = vis(tv.V)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think closure should be visited even if it's likely redundant.
in the heap PR it is called Parent or ParentBlock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes i think it's redundant, but will add it for integrity.

Copy link
Contributor Author

@ltzmaxwell ltzmaxwell Apr 14, 2025

Choose a reason for hiding this comment

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

it introduces a closure -> parent -> closure cycle. it's easy just not visit it, or make a recurse guard? thinking.

jaekwon and others added 2 commits April 11, 2025 16:14
make it work

save

debug

fixup

save

add todo

package value size

metric shallowly

naive gas comsumption

gc benchmark init

fixup

fixup

fixup

simplify

fixup

fixup

txtar gas consumption

fixup

fmt

fixup

save

save

fixup

revert benchmark change

remove unused

fix test

add comment;update const;fix test

fmt

fixup

revert

clean

fixup

fixup

fixup

fixup

string value based

revert to array base

clean

fixup

fixup

correct string allocation

fixup

fix comment

clear unused store

gc callback

revert string value
@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 📦 🌐 tendermint v2 Issues or PRs tm2 related labels Apr 11, 2025
@ltzmaxwell ltzmaxwell changed the base branch from dev/jae/gc to heapitems_for_3693 April 11, 2025 08:44
// -----------------------------------------------

func (pv *PackageValue) GetShallowSize() int64 {
return allocPackage
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these should account for all typedvalues as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

That is, the TypedValue array size should be included in the block, even if each value itself might have its own allocation on top.

}

func (b *Block) GetShallowSize() int64 {
return allocBlock
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, see AllocateBlock.

if av.Data != nil {
return allocArray + int64(len(av.Data))
} else {
return allocArray
Copy link
Contributor

Choose a reason for hiding this comment

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

same here for the else clause.

}

func (sv *StructValue) GetShallowSize() int64 {
return allocStruct
Copy link
Contributor

Choose a reason for hiding this comment

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

and so on...

func (fv *FuncValue) GetShallowSize() int64 {
if fv.IsClosure {
return allocFunc
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems wrong, should be allocFunc no matter what I think.

@jaekwon
Copy link
Contributor

jaekwon commented Apr 19, 2025

This PR because it implements GetShallowSize, we should correctly allocate upon GetObject().

store.go:477: ds.alloc.AllocateAmino(int64(len(bz))) should be replaced with the shallow size of the unmarshalled object from line 450, 'amino.MustUnmarshal(bz, &oo)' so the shallow size of oo.

The garbage collector should also iterate over al objects in cacheObjects and remove items that do not have the updated gc cycle, because these objects are no longer reachable.

@jaekwon jaekwon deleted the branch gnolang:heapitems_for_3693 April 20, 2025 11:17
@jaekwon jaekwon closed this Apr 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Development

Successfully merging this pull request may close these issues.

4 participants