On Saturday, October 1, 2016 at 3:47:09 PM UTC+8, bronze man wrote:
>
> When I call `fmt.Println(1,2) `, I expect all the interfaces of the 
> arguments should alloc on stack so that the garbage collection part will 
> use less cpu time, but currently it is alloc on heap.Because I found that I 
> do not need that alloced valuable (interface{})(1) is not used after this 
> function call.
>
> Do you guys have any plan on improving those stuff?
>
> Is this kind of problem too hard to be solved in linear time?
>
> Or is there any plan that the developer of package "fmt" can add 
> "//go:noescape" and "unsafe" to mark that all the interfaces of the 
> arguments should alloc on stack?("//go:noescape" can only add to asm 
> function right now.)
>

Do you use "go build -gcflags=-m" to check if the arguments are alloced on 
heap or stack?

I guess the result of "go build -gcflags=-m" may be not accurate.
For your simple example, `fmt.Println(1,2) `, I think the compiler does 
alloc the interfaces of the arguments on stack.
The reason is the real data in the interfaces can be represented with one 
word.
If the real data must be represented with more than one word, than real 
data part of the interface values will be alloced on heap (but the two 
pointer fields of the interfaces should be still alloced on stack). 

This is just my understanding, it may be not right.


 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to