gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + Gno.land: a blockchain for timeless code and fair open-source.
https://gno.land/
Other
880 stars 364 forks source link

Add capability to check memory usage within the code #2070

Open Kouteki opened 4 months ago

Kouteki commented 4 months ago
          If it's possible to pull various data from the `Machine`, how about creating a package like `runtime`? I think it would be useful if we could directly check the memory usage by using `Alloc` field including gas usage, within the code.

https://github.com/gnolang/gno/blob/de2fc456c1cdf141def2a4ac77d5d0d5bf757a2d/gnovm/pkg/gnolang/alloc.go#L9-L12

Originally posted by @notJoon in https://github.com/gnolang/gno/issues/1998#issuecomment-2084697255

thinhnx-var commented 4 months ago

Can I assume that you suggests a feature that realm developers are able to check the amount that will be allocated in memory of the data, and how much it does cost in gas ? If I was right I will implement this feat as I am currently doing the GasUsed() funtions ✋ @notJoon

notJoon commented 4 months ago

Can I assume that you suggests a feature that realm developers are able to check the amount that will be allocated in memory of the data, and how much it does cost in gas ? If I was right I will implement this feat as I am currently doing the GasUsed() funtions ✋ @notJoon

Yes, I think it would be good to show them together because the gas usage has some correlation with memory usage and vice versa. However, my intention was to make the foundation for measuring code performence like Go's pprof and prove better metrics to optimize code efficiently. So in my opinion it would better to implement them individually.

thinhnx-var commented 4 months ago

Ok I understand your intention. I gonna implement this good idea within std package first. Many thanks @notJoon