[go-nuts] Re: go analysis memory mallocs

2016-09-29 Thread
package main import "runtime" func main() { m := new(runtime.MemStats) runtime.ReadMemStats(m) cap := 1024 println("debug0") s := make([]byte, cap) println("debug1") _ = s runtime.ReadMemStats(m) println("memstats:", m.Alloc, m.Mallocs) } I use go1.4.2 and In

[go-nuts] Re: go analysis memory mallocs

2016-09-29 Thread
e, "kind=", typ.kind, "needzero=", needzero) 在 2016年9月29日星期四 UTC+8下午9:04:58,Dave Cheney写道: > > You should use Go 1.7.1 or later. > > On Thursday, 29 September 2016 23:00:25 UTC+10, 刘桂祥 wrote: >> >> package main >> >> import "runtime&quo

Re: [go-nuts] Re: go escape analysis

2016-09-29 Thread
ich means the make operation escapes its scope and > subsequently, is heap allocated. If you want more information about why > something escapes, try compiling with -gcflags "-m -m" for an explanation > of the escape analysis information. > > On Wed, Sep 28, 2016 at 7:

Re: [go-nuts] go closure escape analysis

2016-10-05 Thread
to escape to the heap. > > On Wed, Oct 5, 2016 at 4:46 PM, 刘桂祥 <liuguix...@gmail.com > > wrote: > >> 1: In example2_modified.go (y=x line should be *y=x ?) and that is the >> same as example1.go ??? >>but in example1.go y is escapted and example2.go

Re: [go-nuts] go closure escape analysis

2016-10-05 Thread
sformed into something like > > // example2_modified.go > > package main > > func main() { > var y int > func(y *int, x int) { > y = x > }(, 42) > } > > and then the same analysis from above is applied. y should not escape to > the heap here, similar to exam

[go-nuts] golang memory allocation

2016-10-05 Thread
package main import ( "fmt" _ "net/http/pprof" "testing" ) // 8 Bytes/op 1 allocs/op func BenchmarkFmt1(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { fmt.Println(100) } } // 16 Bytes/op 1 allocs/op func BenchmarkFmt2(b *testing.B) {

Re: [go-nuts] go closure escape analysis

2016-10-05 Thread
ing/closing over a non-pointer value would cause it to escape. > > It's a bit confusing, but to restate, in example1, y should not escape > even though it currently does. > > On Mon, Oct 3, 2016 at 11:09 PM, 刘桂祥 <liuguix...@gmail.com > > wrote: > >> // example1.go >

[go-nuts] when the runtime decide to threadcreate

2016-10-05 Thread
package main import ( "bufio" "net/http" _ "net/http/pprof" "os" "time" ) func main() { go func() { http.ListenAndServe(":8080", nil) }() reader := bufio.NewReader(os.Stdin) for i := 0; i < 100; i++ { go func(id int) { for {

[go-nuts] go analysis memory mallocs

2016-09-29 Thread
// example1.go package main import "runtime" func main() { m := new(runtime.MemStats) runtime.ReadMemStats(m) println(m.Alloc, m.Mallocs) cap := 1024 * 1024 * 3 s := make([]byte, cap) _ = s runtime.ReadMemStats(m) println(m.Alloc, m.Mallocs) } go run

[go-nuts] Re: go analysis memory mallocs

2016-09-29 Thread
package main import "runtime" func init() { runtime.MemProfileRate = 1 } func main() { m := new(runtime.MemStats) runtime.ReadMemStats(m) println(m.Alloc, m.Mallocs) cap := 1024 * 1024 * 4 s := make([]byte, cap) _ = s runtime.ReadMemStats(m) println(m.Alloc,

[go-nuts] Re: go analysis memory mallocs

2016-09-29 Thread
package main import "runtime" func init() { runtime.MemProfileRate = 1 } func main() { m := new(runtime.MemStats) runtime.ReadMemStats(m) println(m.Alloc, m.Mallocs) cap := 1024 * 1024 * 4 s := make([]byte, cap) _ = s runtime.ReadMemStats(m) println(m.Alloc,

[go-nuts] Re: go compile for memory allocation

2016-09-29 Thread
https://github.com/golang/go/issues/17275 在 2016年9月29日星期四 UTC+8下午2:57:08,Dave Cheney写道: > > Don't forget to log that issue. -- 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

[go-nuts] Re: go analysis memory mallocs

2016-09-29 Thread
In my two examples, I use variable in makeslice that it will all escape to the heap , But I just want to use runtime.ReadMemStats to lookup it and find strange

Re: [go-nuts] Re: go escape analysis

2016-09-29 Thread
the scope > of the for statement, which means the make operation escapes its scope and > subsequently, is heap allocated. If you want more information about why > something escapes, try compiling with -gcflags "-m -m" for an explanation > of the escape analysis information. > > On Wed,

[go-nuts] go compile for memory allocation

2016-09-28 Thread
// example1.go packge main func main() { s := make([]byte, 1024, 1024) _ = s } s will be allocated in stack and lookup assembl e code

[go-nuts] go escape analysis

2016-09-28 Thread
// example1.go package main func main() { for i := 0; i < 2; i++ { m := make(map[int]int) m[1] = 100 } } main

[go-nuts] about interface data pointer

2016-10-02 Thread
package main import ( "fmt" ) func main() { a := interface{}(100) println(, a) fmt.Sprint(a) } go run x.go the output: 0xc42003bf18 (0x89040,0xc42000a2c0) I just want to ask 0xc42000a2c0 as the a (interface{}) 's data pointer is point to where ? heap ? also I test this:

Re: [go-nuts] Re: go escape analysis

2016-10-02 Thread
>> analysis. >> If you are convinced that something doesn't escape and that the compiler >> should be able to figure it out, you can try filing an issue about that >> with the code and output of -gcflags=-m. >> >> > On Fri, Sep 30, 2016 at 5:20 AM,

[go-nuts] Re: go escape analysis

2016-09-28 Thread
go 1.7 在 2016年9月28日星期三 UTC+8下午10:41:09,Dave Cheney写道: > > Which version of Go? > > On Thursday, 29 September 2016 00:18:29 UTC+10, 刘桂祥 wrote: >> >> // example1.go >> package main >> >> >> func main() { >> >>

[go-nuts] golang too many json unmarshal trigger gc frequency to many

2016-10-26 Thread
In my server many requests need to handle a loop to unmarshal json strings and I find gc is very frequency -- 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

Re: [go-nuts] Multiple-reader single-writer map access is safe ?

2016-11-06 Thread
Taylor写道: > > On Thu, Nov 3, 2016 at 11:30 PM, 刘桂祥 <liuguix...@gmail.com > > wrote: > > > >very thanks , I am unfamiliar with the cpu out-of-order execution , > but > > I doubt if my three line code is related ,it will reorder it ?? > > I want to

Re: [go-nuts] golang closure variable

2016-11-03 Thread
0091 (main.go:11) PCDATA $0, $1 0x005b 00091 (main.go:11) CALL time.Sleep(SB) 0x0060 00096 (main.go:12) MOVQ 48(SP), BP 0x0065 00101 (main.go:12) ADDQ $56, SP 0x0069 00105 (main.go:12) RET 0x006a 00106 (main.go:12) NOP 0x006a 00106 (main.go:5) CALL runtime.morestack_noctxt(SB) 0x006f 00111

Re: [go-nuts] golang closure variable

2016-11-03 Thread
7 00231 (main.go:5) CALL runtime.morestack_noctxt(SB) 0x00ec 00236 (main.go:5) JMP 0 在 2016年11月3日星期四 UTC+8下午2:56:10,Ian Lance Taylor写道: > > On Wed, Nov 2, 2016 at 11:48 PM, 刘桂祥 <liuguix...@gmail.com > > wrote: > > I just want to look what variable datastructure is passe

[go-nuts] golang closure variable

2016-11-02 Thread
In golang closure func ,the needed outer variable is passed by reference but when the variable self is a reference in example.go , the closure func

[go-nuts] Multiple-reader single-writer map access is safe ?

2016-11-03 Thread
// example.go package main var gMap = make(map[int]int) func w() { temp := make(map[int]int) temp[1] = 100 temp[2] = 200 gMap = temp// Does the compiler or cpu will reorder temp[1]=100, temp[2]=200, gMap=temp ?? } func r() { local := gMap println(local[1],

Re: [go-nuts] Multiple-reader single-writer map access is safe ?

2016-11-03 Thread
In my write goroutine I don't modify the map key (data structure) but set the variable point to another map address ,this is a pointer assignment and is atomic 在 2016年11月4日星期五 UTC+8下午1:22:20,Ian Lance Taylor写道: > > On Thu, Nov 3, 2016 at 10:19 PM, 刘桂祥 <liuguix...@gmail.com &

Re: [go-nuts] Multiple-reader single-writer map access - is this lockless workaround safe?

2016-11-03 Thread
sorry could you provide a complete example ? I try this but not find question package main import "time" type T struct{ x int } var global *T func f() { p := new(T) p.x = 1 global = p // "publish" the new T (racy!) } func g() { p := global if p != nil { // println(p.x) // may

Re: [go-nuts] Multiple-reader single-writer map access is safe ?

2016-11-03 Thread
can you explain why whis ? 在 2016年11月4日星期五 UTC+8下午1:16:39,Ian Lance Taylor写道: > > On Thu, Nov 3, 2016 at 8:37 PM, 刘桂祥 <liuguix...@gmail.com > > wrote: > > // example.go > > > > package main > > > > var gMap = make(map[int]int) > >

Re: [go-nuts] Multiple-reader single-writer map access is safe ?

2016-11-04 Thread
very thanks , I am unfamiliar with the cpu *out-of-order execution , but I doubt if my three line code is related ,it will reorder it ??* 在 2016年11月4日星期五 UTC+8下午1:38:12,Ian Lance Taylor写道: > > On Thu, Nov 3, 2016 at 10:28 PM, 刘桂祥 <liuguix...@gmail.com > > wrote: > &

[go-nuts] Re: golang cpu usage question

2017-03-28 Thread
e. Assist mode causes goroutines to > "pay" for their allocation by doing some mark and sweep work each time they > allocate. > > The execution trace can show this more clearly. > > On Tuesday, 28 March 2017 17:59:19 UTC+11, 刘桂祥 wrote: >> >> my production p

[go-nuts] Re: golang cpu usage question

2017-03-28 Thread
my production program data: ... gc 149 @91.330s 6%: 6.8+557+0.50+1.0+10 ms clock, 20+557+0+1841/0/1304+31 ms cpu, 3694->3793->2016 MB, 3789 MB goal, 48 P gc 150 @92.012s 6%: 2.9+505+0.32+0.58+9.5 ms clock, 11+505+0+1756/0.014/1574+38 ms cpu, 3739->3805->1987 MB, 3835 MB goal, 48 P gc 151

[go-nuts] Re: golang cpu usage question

2017-03-27 Thread
Hi Dave: very thanks your timely response two more question 1. GODEBUG=gctrace=1 Do have some method get these quota from runtime package apis ? 2. In go1.7 the concurent gc could occupy all cpu core ?? does it have cpu usgae limit ? 在

[go-nuts] golang cpu usage question

2017-03-27 Thread
As we know go have optimise its gc stw-pause-time ,but it has some trade-off ; it implements concurent gc and will grab cpu resources with your application In some high CPU usage application, there are long time request case caused by gc I want to know How to monitor my application in CPU

[go-nuts] golang precise gc

2017-03-30 Thread
package main import ( "fmt" "runtime" "unsafe" ) func main() { var m runtime.MemStats runtime.ReadMemStats() println(m.HeapObjects, m.Mallocs) runtime.GC() runtime.ReadMemStats() println(m.HeapObjects, m.Mallocs) runtime.GC() runtime.ReadMemStats() println(m.HeapObjects, m.Mallocs) p :=

[go-nuts] Re: golang cpu usage question

2017-03-27 Thread
now In my application 48 core set GODEBUG=gctrace=1 the gc CPU percent is 17% but my server request have many long time case want to know the CPU percent in witch percentage is hight?? 在 2017年3月27日星期一 UTC+8下午6:55:47,Dave Cheney写道: > > > > On Monday, 27 March 2017 21:12:44 UTC+1

[go-nuts] Re: golang cpu usage question

2017-03-27 Thread
package main import ( "fmt" "time" ) func foo() { str := "" for i := 0; i < 1000; i++ { str += "aa" } } func main() { for i := 0; i < 200; i++ { go func() { for {

Re: [go-nuts] go build -gcflags '-N -l' don't work

2017-04-15 Thread
Taylor写道: > > On Thu, Apr 13, 2017 at 10:45 PM, 刘桂祥 <liuguix...@gmail.com > > wrote: > > go1.7.1 > > > > go run -gcflags '-N -l -m' example.go > > It is the -m flag that is generating the output you see. > > If there is some other bug, please let us

[go-nuts] Re: Large GC pauses with large map

2017-04-20 Thread
try use value type example: map[string]*struct => map[[20]byte]struct 在 2017年4月20日星期四 UTC+8下午9:49:49,Lee Armstrong写道: > > See attached graph which shows the GC pauses of an application we have. > > I am frequently seeing pauses of 1-1.5 seconds. This is using Go 1.8.1 and > have a large map

[go-nuts] go build -gcflags '-N -l' don't work

2017-04-13 Thread
// example.go package main import "runtime" type S struct{} func main() { var stats runtime.MemStats runtime.ReadMemStats() println(stats.Mallocs) var x S runtime.ReadMemStats() println(stats.Mallocs) _ = *ref(x) runtime.ReadMemStats() println(stats.Mallocs) } func ref(z S) *S {

Re: [go-nuts] go build -gcflags '-N -l' don't work

2017-04-13 Thread
go1.7.1 go run -gcflags '-N -l -m' example.go 在 2017年4月14日星期五 UTC+8下午1:18:26,Ian Lance Taylor写道: > > On Thu, Apr 13, 2017 at 8:33 PM, 刘桂祥 <liuguix...@gmail.com > > wrote: > > // example.go > > package main > > > > > > import "runtime"

Re: [go-nuts] go build -gcflags '-N -l' don't work

2017-04-16 Thread
gt; # command-line-arguments > ./example.go:27:9: escapes to heap > ./example.go:26:16: moved to heap: z > ./example.go:14:23: main does not escape > ./example.go:17:23: main does not escape > ./example.go:20:23: main does not escape > 83 > 83 > 84 > 1 > $ > &g

Re: [go-nuts] golang thrift server 28k/s request client many dial tcp timeout ,why??

2017-06-08 Thread
client: dial tcp 100.70.186.38:9783: i/o timeout when I modify the server /proc/sys/net/core/netdev_max_backlog16384 /proc/sys/net/core/somaxconn 16384 the client dial timeout decrease some percent 在 2017年6月9日星期五 UTC+8上午12:10:15,Shawn Milochik写道: > > What error are you

[go-nuts] golang thrift server 28k/s request client many dial tcp timeout ,why??

2017-06-08 Thread
I have a very simple golang thrift server. the handle is very easy just to return But when I use another machine to benchmark the server ,when the qps to 28K/s , client have many dial tcp io/timeout I don't konw the reason ? is the client or server's problem? -- You

Re: [go-nuts] golang thrift server 28k/s request client many dial tcp timeout ,why??

2017-06-10 Thread
I just want to bench the simple server accept new connection now I create a new simple tcp server and use tcp short connection to bench it the result is also that client have many dial i/o timeout does it is client's question ?? 在 2017年6月9日星期五 UTC+8下午9:28:55,Shawn

[go-nuts] Re: dial io timeout and tcp short connection performance bottleneck

2017-06-11 Thread
check output of netstat to confirm that. > > On Sunday, June 11, 2017 at 9:48:30 AM UTC+8, 刘桂祥 wrote: >> >> //question >> > I write a simple golang tcp server >> > and use tcp short connect client to bench it. >> > when qps up to 28K, cli

[go-nuts] dial io timeout and tcp short connection performance bottleneck

2017-06-10 Thread
> I write a simple tcp server with golang > and use tcp short connect client to bench it. > when qps to 28K, client have many dial io timeout > > I don't know what is the performance bottleneck?? > > I modify the server: > cat

[go-nuts] Re: dial io timeout and tcp short connection performance bottleneck

2017-06-11 Thread
HI Matthew: Because I don't konw the performance bottleneck; do you mean the tcp syn queue (half open queue) is full ??but I don't see the syn flood warn message in /var/log/messages 在 2017年6月11日星期日 UTC+8下午7:03:58,Matthew Stevenson写道: > > Are you exhausting the local TCP sockets?

Re: [go-nuts] golang thrift server 28k/s request client many dial tcp timeout ,why??

2017-06-11 Thread
ry time you have a request, you pay the session setup > time on every request. You could maybe look into batch-framing some of them > which will improve the TCP window and likely increase throughput. > > On Sat, Jun 10, 2017 at 11:51 AM 刘桂祥 <liuguix...@gmail.com > > wrote:

[go-nuts] dial io timeout and tcp short connection performance bottleneck

2017-06-10 Thread
//question > I write a simple golang tcp server > and use tcp short connect client to bench it. > when qps up to 28K, client have many dial i/o timeout > > I don't know what is the performance bottleneck?? > > I modify the server: > cat

Re: [go-nuts] golang preempt schedule how work ?

2017-09-08 Thread
Thanks a lot! 在 2017年9月8日星期五 UTC+8下午8:23:39,Ian Lance Taylor写道: > > On Mon, Sep 4, 2017 at 10:02 PM, 刘桂祥 <liuguix...@gmail.com > > wrote: > > > > I have a question about golang preempt schedule, here is my example > code; > > > > I doubt why the

[go-nuts] golang preempt schedule how work ?

2017-09-04 Thread
I have a question about golang preempt schedule, here is my example code; I doubt why the bar groutine don't happen preempt schedule? (I build with -gcflags “-N -l” to stop func inline) More if my server with one or two cpu bound worker goroutine runing, when the gc need stop the world,

Re: [go-nuts] golang gc stop the world how to stop cpu busy goroutine?

2017-09-04 Thread
But I build with -gcflags "-N -l" here is gdb code: (gdb) Dump of assembler code for function main.main: 0x2100 <+0>: mov%gs:0x8a0,%rcx 0x2109 <+9>: cmp0x10(%rcx),%rsp 0x210d <+13>: jbe0x216c 0x210f <+15>:

[go-nuts] golang gc stop the world how to stop cpu busy goroutine?

2017-09-03 Thread
when have one or two cpu busy goroutine in my server (example for loop empty), the gc stop the world how to stop the goroutine ? -- 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,

Re: [go-nuts] golang gc stop the world how to stop cpu busy goroutine?

2017-09-04 Thread
Yes, I just want to let the bar func goroutine run first or replace runtime.Gosched() with time.Sleep, But I still doubt why add1 in bar func don't happen preempt schedule ? 在 2017年9月4日星期一 UTC+8下午3:25:04,John Souvestre写道: > > I think that you put the call to runtime.Gosched() in the wrong

[go-nuts] Re: about golang escape analysis

2017-12-03 Thread
very very thanks! cannot inline copyIface1: has ... args from *a[0].(string) (indirection) key escapes to heap 在 2017年12月3日星期日 UTC+8下午4:08:41,Dave Cheney写道: > > Add -gcflags=“-m -m” will tell you. -- You received this message because you are subscribed to the Google Groups "golang-nuts"

[go-nuts] about golang escape analysis

2017-12-02 Thread
package main import "testing" var gbuf []byte var gi int func BenchmarkCopy1(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { m := make(map[string]int, 5) for i := 0; i < 5; i++ { m["100"] = i } for key := range m { copyIface1(key, key) } } } func BenchmarkCopy2(b *testing.B) {

[go-nuts] golang gc time STW1=>Mark=>STW2

2017-12-27 Thread
package main import ( "runtime" _ "net/http/pprof" "net/http" "time" ) var ch = make(chan struct{},1) func printMem() { var mem runtime.MemStats runtime.ReadMemStats() println(mem.HeapObjects) } func easy() { <-ch } func bussy() { sum := 0 for

[go-nuts] Re: golang gc time STW1=>Mark=>STW2

2017-12-27 Thread
195+0.26+0.025 ms 0.065+0.82+0.041 ms 242+0.32+0.016 ms 0.010+0.37+0.039 ms 233+0.33+0.014 ms version go1.9.2 I want to ask why the third phrase mark-termination time is always short, it also need STW ?? 在 2017年12月27日星期三 UTC+8下午5:14:52,Dave Cheney写道: > > I’m sorry I don’t understand the