Hi, 

I've been looking into why some of our code wasn't resulting in the memclr 
optimization originally introduced in response 
to https://github.com/golang/go/issues/5373. I'm still a bit unclear on why 
this happens. Here is the code that triggers the issue for me:


package foo


import (

  "testing"

)


type Foo struct {

   H string

   A int64

   B int64

   C int64

}



func BenchmarkClear4(b *testing.B) {


  b.RunParallel(func(pb *testing.PB) {

    testFoo := make([]Foo, 100)

    for pb.Next() {

          for i := range testFoo {

              testFoo[i] = Foo{}

          }

    }

  })

}

For me (go 1.8) the above snippet results in asm that doesn't make use of 
memclr. On the other hand, when I comment out field C in the struct above 
then the code does make use of the optimization. Similarly, when I change 
the first field from string to int64, it also works. Is this expected? If 
so, is there some documentation for the criteria for the optimization?

/Sam

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