-
Notifications
You must be signed in to change notification settings - Fork 397
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
feat(gnovm): fill in 3779, the gc PR #3789
base: dev/jae/gc
Are you sure you want to change the base?
Conversation
🛠 PR Checks SummaryAll Automated Checks passed. ✅ 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):No automated checks match this pull request. ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
// stop metric before next visit. | ||
if bm.GCEnabled { | ||
bm.StopGCCode() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to stop it before the next visit?
isn't it all just visits, all continuously GC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed benchmark and planned for future.
// Add object size to alloc. | ||
size := o.GetShallowSize() | ||
alloc.visitCount++ // count for gas calculation | ||
|
||
alloc.Allocate(size) | ||
// Stop if alloc max exceeded. | ||
maxBytes, curBytes := alloc.Status() | ||
if maxBytes < curBytes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this really happen? GC usually occurs at a critical point, meaning that before this allocation, the total number of bytes hasn’t exceeded maxBytes. So during the recalculation process, the calculated result should not exceed the last crossing point, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment.
gnovm/pkg/gnolang/values.go
Outdated
type StringValue struct { | ||
isNewBase bool // if the underlying data is new allocated or not. | ||
Base *SliceValue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This provides a method for handling string memory reuse and reallocation
e.g..
// MAXALLOC: 100000000
package main
import "runtime"
var s = "hello world" // allocated in preprocess.
func main() {
s += "!" // underlying array re-allocated in runtime
s1 := s // another string value, underlying array stays unchanged.
runtime.GC()
println("MemStats: ", runtime.MemStats())
}
This PR is trying to complete the work outlined in #3779 .
It completes the
visit
logic and introduces benchmarking and gas consumption tracking.