[go-nuts] Re: godoc-static - Generate static documentation for your packages

2020-09-11 Thread tapi...@gmail.com
Cool. BTW, there is another docs generator: https://github.com/go101/gold (written by me). On Thursday, February 6, 2020 at 7:56:15 PM UTC-5 Trevor Slocum wrote: > Repository: https://gitlab.com/tslocum/godoc-static > > Demo output: https://docs.rocketnine.space > > Inspired by the recent news

Re: [go-nuts] Proposal: auto return String instead of []byte if requested

2020-09-12 Thread tapi...@gmail.com
There is a prerequisite to transfer ownership: it must be proved that no other values share ownership of the byte slice returned by ioutil.ReadFile. On Saturday, September 12, 2020 at 3:42:14 AM UTC-4 tapi...@gmail.com wrote: > Is it good to introduce owner transfer based string<-&

[go-nuts] Re: add method to interface via reflect

2020-09-11 Thread tapi...@gmail.com
What should happen after the method is added? Will those types implementing the interface still implement it? On Thursday, September 10, 2020 at 6:44:29 PM UTC-4 va...@selfip.ru wrote: > Hi! Does go support adding method to exiting interface via reflect? > Mostly I need to add method to struct

Re: [go-nuts] Proposal: auto return String instead of []byte if requested

2020-09-12 Thread tapi...@gmail.com
Is it good to introduce owner transfer based string<->[]byte conversions? After the conversion, the being converted string/[]byte values mustn't be used any more. Such as tlsCertData, _ = ioutil.ReadFile("/etc/ssl/mycert") var tlsCert string = bultin.ByteSlice2String(tlsCertData) // forbid

[go-nuts] in "_ = debug && mylog.Infof("%s %d", str, n)", will the mylog.Infof call be always not executed if variable debug is false?

2020-10-08 Thread tapi...@gmail.com
. -- 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. To view this discussion on the web visit

[go-nuts] Re: in "_ = debug && mylog.Infof("%s %d", str, n)", will the mylog.Infof call be always not executed if variable debug is false?

2020-10-08 Thread tapi...@gmail.com
ober 8, 2020 at 10:58:48 AM UTC-4 tapi...@gmail.com wrote: > > . -- 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...@goo

[go-nuts] Why is only "if", but not "for" and "switch", allowed to follow "else" keyword?

2020-10-06 Thread tapi...@gmail.com
IMO, the bar function is cleaner and more readable than the foo function. How do you think? func foo() { if vs := f(); len(vs) == 0 { } else { for _, v := range vs { } } if vs := f(); len(vs) == 0 { } else {

Re: [go-nuts] Why is only "if", but not "for" and "switch", allowed to follow "else" keyword?

2020-10-06 Thread tapi...@gmail.com
On Tuesday, October 6, 2020 at 1:54:16 PM UTC-4 Ian Lance Taylor wrote: > On Tue, Oct 6, 2020 at 10:28 AM tapi...@gmail.com > wrote: > > > > IMO, the bar function is cleaner and more readable than the foo > function. > > How do you think? > > > >

Re: [go-nuts] Cloud the current generic draft constraint a type parameter must be exactly some types

2020-09-18 Thread tapi...@gmail.com
%5B%5Dbyte-arguments>. This might be good for some scenarios. On Friday, September 18, 2020 at 1:31:10 PM UTC-4 Ian Lance Taylor wrote: > On Fri, Sep 18, 2020 at 10:07 AM tapi...@gmail.com > wrote: > > > > instead of sharing the same underlying types with some types? > &g

[go-nuts] Should the program print true or false?

2020-09-17 Thread tapi...@gmail.com
package main import ( "fmt" "reflect" ) func main() { f() } func f() { type S []S var a, b S a = S{0: b} b = S{0: a} fmt.Println(reflect.DeepEqual(a, b)) } Now it prints false. But it looks the docs indicates it should print true. -- You received this message because you are

Re: [go-nuts] Should the program print true or false?

2020-09-17 Thread tapi...@gmail.com
gt; fmt.Println(reflect.DeepEqual(a, b)) > > On Thu, Sep 17, 2020 at 6:03 PM Axel Wagner > wrote: > >> I don't think the docs imply that. For one, a[0] is nil, and b[0] isn't. >> >> On Thu, Sep 17, 2020 at 5:58 PM tapi...@gmail.com >> wrote: >> >>

Re: [go-nuts] Should the program print true or false?

2020-09-17 Thread tapi...@gmail.com
gt; fmt.Println(reflect.DeepEqual(a, b)) > > On Thu, Sep 17, 2020 at 6:03 PM Axel Wagner > wrote: > >> I don't think the docs imply that. For one, a[0] is nil, and b[0] isn't. >> >> On Thu, Sep 17, 2020 at 5:58 PM tapi...@gmail.com >> wrote: >> >>

[go-nuts] Cloud the current generic draft constraint a type parameter must be exactly some types

2020-09-18 Thread tapi...@gmail.com
instead of sharing the same underlying types with some types? -- 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. To view

Re: [go-nuts] Is it possible that a hybrid memory management could be implemented?

2020-11-15 Thread tapi...@gmail.com
may be misunderstanding what you're suggesting, but I believe Go already > tries to detect when a value can be placed on the stack. Then, it will be > freed automatically when it falls out of scope. > > On Sun, Nov 15, 2020 at 5:20 PM tapi...@gmail.com > wrote: > >> >&g

[go-nuts] Is it possible that a hybrid memory management could be implemented?

2020-11-15 Thread tapi...@gmail.com
For example, some local memory allocations could be detected no used elsewhere so that they can may be freed immediately when out of reach instead of waiting to be freed in the GC phase. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] Let Go also support manual memory management, a good or bad idea?

2020-11-15 Thread tapi...@gmail.com
For example, by adding two new built-in functions: alloc and free, garbage collector will ignore the memory allocated by alloc. The memory allocated by alloc must be freed by calling the free function manually. This would relieve the burden of GC for some Go programs (such as games). -- You

Re: [go-nuts] Let Go also support manual memory management, a good or bad idea?

2020-11-16 Thread tapi...@gmail.com
Taylor wrote: > On Sun, Nov 15, 2020 at 5:38 PM tapi...@gmail.com > wrote: > > > > For example, by adding two new built-in functions: alloc and free, > garbage collector will ignore the memory allocated by alloc. The memory > allocated by alloc must be freed by calling th

Re: [go-nuts] Re: Is it possible that a hybrid memory management could be implemented?

2020-11-16 Thread tapi...@gmail.com
On Monday, November 16, 2020 at 5:19:59 AM UTC-5 Jan Mercl wrote: > On Mon, Nov 16, 2020 at 11:14 AM 陶青云 wrote: > > > FYI > > https://dgraph.io/blog/post/manual-memory-management-golang-jemalloc/ > > A CGo-free manual memory allocator might be a better fit sometimes: >

Re: [go-nuts] Is it possible that a hybrid memory management could be implemented?

2020-11-16 Thread tapi...@gmail.com
y many goroutines at run time, but at any time point, it is only be used by one goroutine. > > On Nov 15, 2020, at 7:34 PM, tapi...@gmail.com wrote: > >  > > Aha, I forgot this fact. You are totally right. > > It is a bad example. A better example: is it possible to detect

Re: [go-nuts] Is it possible that a hybrid memory management could be implemented?

2020-11-16 Thread tapi...@gmail.com
ve not a clear thought on this yet. > > On Nov 16, 2020, at 8:02 AM, tapi...@gmail.com wrote: > >  > > > > On Sunday, November 15, 2020 at 10:24:05 PM UTC-5 ren...@ix.netcom.com > wrote: > >> It is the same. If it can escape the allocation frame you nee

Re: [go-nuts] [generics] moving the last type parameter to a type outside the square brackets

2021-01-05 Thread tapi...@gmail.com
On Monday, January 4, 2021 at 5:23:06 PM UTC-5 ren...@ix.netcom.com wrote: > Reading > > sync.Map[string]linked.List string > > I have no idea what that represents? > If you can read sync.Map[string]chan string then you can read "sync.Map[string]linked.List string" too. > > What

[go-nuts] Re: [generics] moving the last type parameter to a type outside the square brackets

2021-01-05 Thread tapi...@gmail.com
On Tuesday, January 5, 2021 at 11:31:44 AM UTC-5 Brian Candler wrote: > Are you trying to make user-defined generic maps look more like built-in > ones? > > map[T1]T2 is hard-coded syntax in go. But so is m[k] for accessing > elements - and you can't use that in user-defined types anyway. >

Re: [go-nuts] [generics] moving the last type parameter to a type outside the square brackets

2021-01-05 Thread tapi...@gmail.com
On Tuesday, January 5, 2021 at 8:43:44 AM UTC-5 axel.wa...@googlemail.com wrote: > On Tue, Jan 5, 2021 at 12:03 PM Anonymous AWK fan > wrote: > >> Why does there need to be a delimiter, there isn't one between chan and >> int in chan int, which I think is more readable than chan[int]. >> >

[go-nuts] Re: [generics] moving the last type parameter to a type outside the square brackets

2021-01-06 Thread tapi...@gmail.com
On Tuesday, January 5, 2021 at 1:29:01 PM UTC-5 Brian Candler wrote: > On Tuesday, 5 January 2021 at 18:17:14 UTC tapi...@gmail.com wrote: > >> What about if the custom generic function syntax is consistent with built >> ones? >> For example: >> >> v :=

[go-nuts] Re: [generics] moving the last type parameter to a type outside the square brackets

2021-01-06 Thread tapi...@gmail.com
On Wednesday, January 6, 2021 at 9:40:15 AM UTC-5 Brian Candler wrote: > On Wednesday, 6 January 2021 at 12:40:24 UTC tapi...@gmail.com wrote: > >> func blah[T1]T2 (x T1) T2 { ... } >>> >>> x := blah[int]string(123) >>> >> >> I didn't see

[go-nuts] Re: [generics] moving the last type parameter to a type outside the square brackets

2021-01-06 Thread tapi...@gmail.com
I think OP the "parameter" in title means "argument" actually. OP didn't specify how to declare a generic type. On Wednesday, January 6, 2021 at 9:40:15 AM UTC-5 Brian Candler wrote: > On Wednesday, 6 January 2021 at 12:40:24 UTC tapi...@gmail.com wrote: > &g

[go-nuts] It looks making a slice with size 32768+1 will allocate with one memory page as needed

2021-06-11 Thread tapi...@gmail.com
package allocate import "testing" import "os" import "fmt" func init() { fmt.Println("OS page size:", os.Getpagesize()) } var r1 []byte func BenchmarkCount1(b *testing.B) { for i := 0; i < b.N; i++ { r1 = make([]byte, 32768+1) } } var r2 []byte func BenchmarkCount2(b

[go-nuts] Surprising benchmark result

2021-06-07 Thread tapi...@gmail.com
The code: https://play.golang.org/p/DxUj6kBqf8k The Filter4 function has one more assignment statement than Filter3. But the benchmark result shows Filter4 is faster than Filter3. The result: cpu: Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz BenchmarkFilter3-43575656 980.2 ns/op

[go-nuts] Re: Surprising benchmark result

2021-06-07 Thread tapi...@gmail.com
On Monday, June 7, 2021 at 1:01:49 PM UTC-4 peterGo wrote: > name time/op > Filter3-4 1.38µs ± 0% > Filter4-4 1.39µs ± 0% > > What is your CPU model? > > On Monday, June 7, 2021 at 10:57:19 AM UTC-4 tapi...@gmail.com wrote: > >> >> The code: h

Re: [go-nuts] It looks making a slice with size 32768+1 will allocate with one memory page as needed

2021-06-12 Thread tapi...@gmail.com
4 tapi...@gmail.com wrote: > On Friday, June 11, 2021 at 2:00:03 PM UTC-4 Ian Lance Taylor wrote: > >> On Fri, Jun 11, 2021 at 9:38 AM tapi...@gmail.com >> wrote: >> > >> > package allocate >> > >> > import "testing" >> > impo

Re: [go-nuts] It looks making a slice with size 32768+1 will allocate with one memory page as needed

2021-06-11 Thread tapi...@gmail.com
On Friday, June 11, 2021 at 2:00:03 PM UTC-4 Ian Lance Taylor wrote: > On Fri, Jun 11, 2021 at 9:38 AM tapi...@gmail.com > wrote: > > > > package allocate > > > > import "testing" > > import "os" > > import "fmt"

Re: [go-nuts] It looks making a slice with size 32768+1 will allocate with one memory page as needed

2021-06-12 Thread tapi...@gmail.com
On Saturday, June 12, 2021 at 12:04:21 PM UTC-4 Ian Lance Taylor wrote: > On Fri, Jun 11, 2021 at 11:21 PM tapi...@gmail.com > wrote: > > > > It looks the _PageSize constant used in allocating large memory block is > declared as 8192 in code, but os.Getpa

[go-nuts] Why does one string concatenation escape, but the other not?

2021-06-22 Thread tapi...@gmail.com
package main import "testing" var s33 = []byte{32: 'b'} var a = string(s33) func main() { x := a + a // a + a does not escape println(x) } func Benchmark_e_33(b *testing.B) { var x string for i := 0; i < b.N; i++ { x = a + a // a + a escapes to heap }

[go-nuts] Re: Escape analysis result and benchmark result conflict

2021-06-23 Thread tapi...@gmail.com
Is it possible that gc automatically replaces the "_" with a hidden declared package-level variable? On Wednesday, June 23, 2021 at 1:14:36 AM UTC-4 tapi...@gmail.com wrote: > The code: > > package concat > > import ( > "testing" > ) > >

[go-nuts] Re: Why does one string concatenation escape, but the other not?

2021-06-22 Thread tapi...@gmail.com
Is this to avoid stack growing to fast if there are some stack allocations intervening with each other? On Wednesday, June 23, 2021 at 12:39:17 AM UTC-4 tapi...@gmail.com wrote: > > package main > > import "testing" > > var s33 = []byte{32: 'b'} > > var a = str

[go-nuts] Escape analysis result and benchmark result conflict

2021-06-22 Thread tapi...@gmail.com
The code: package concat import ( "testing" ) var s33 = []byte{32: 'b'} var a = string(s33) func Benchmark_e_33(b *testing.B) { for i := 0; i < b.N; i++ { _ = a + a // a + a does not escape } } "go test -gcflags=-m" shows: a + a does not escape but "go test -bench=.

[go-nuts] string(aByteSlice) will duplicate undrelying bytes on stack if len(aByteSlice) <= 32

2021-06-22 Thread tapi...@gmail.com
The benchmark code: https://play.golang.org/p/qp6wQgqcHKW The result: Benchmark_CompareWithSwitch0Bytes-4328873778 3.619 ns/op 0 B/op 0 allocs/op Benchmark_CompareWithSwitch32Bytes-4 175067815 6.251 ns/op 0 B/op 0

[go-nuts] Re: Why does one string concatenation escape, but the other not?

2021-06-24 Thread tapi...@gmail.com
Filled an issue: https://github.com/golang/go/issues/46908 On Thursday, June 24, 2021 at 10:50:31 PM UTC-4 tapi...@gmail.com wrote: > Now, I think the escape analysis message should be "a + a does not > escapes", > which accurate meaning is "the header part

[go-nuts] Re: Why does one string concatenation escape, but the other not?

2021-06-24 Thread tapi...@gmail.com
cape > x = a + a // does not escape > for i := 0; i < 1; i++ { > > x = a + a // a + a escapes to heap > y := a + a // does not escape > println(y) > println(x) > } > } > > > Only when a variable outside the loo

Re: [go-nuts] Boxing bytes is faster than boxing integers within [0. 255]. Why?

2021-05-10 Thread tapi...@gmail.com
Yes, I'm aware of this optimization. But it looks another optimization is applied for boxing bytes. On Monday, May 10, 2021 at 10:38:39 AM UTC-4 Jan Mercl wrote: > On Mon, May 10, 2021 at 4:30 PM tapi...@gmail.com > wrote: > > > https://github.com/g

[go-nuts] Boxing bytes is faster than boxing integers within [0. 255]. Why?

2021-05-10 Thread tapi...@gmail.com
Different optimizations are applied for them? The benchmark: package main import "testing" func BoxByte(b byte) interface{} { return b } func BoxInt64(i int64) interface{} { return i } var b0, b1, b2 byte = 0, 128, 255 var d, e, f interface{} func Benchmark_BoxByte(b *testing.B) {

[go-nuts] Re: Still "missing" priority or ordered select in go?

2021-05-05 Thread tapi...@gmail.com
older threads: * https://groups.google.com/g/golang-nuts/c/ZrVIhHCrR9o/m/JMJ0fGqhCgAJ * https://groups.google.com/g/golang-nuts/c/lEKehHH7kZY/m/gCjjBviJBwAJ On Thursday, April 29, 2021 at 4:51:43 AM UTC-4 oyvin...@teigfam.net wrote: > I know from some years ago that go did not have any priority

[go-nuts] A little surprising result in clone slices with different ways to clone slices

2021-05-05 Thread tapi...@gmail.com
func MakeCopy(s []int) []int {10% r := make([]int, len(s)) copy(r, s) return r } func MakeAppend(s []int) []int { return append(make([]int, 0, len(s)), s...) } func MakeAppend2(s []int) []int { r := make([]int, 0, len(s)) return append(r, s...) } It looks MakeCopy is

[go-nuts] Re: Strange benchmark results

2021-05-16 Thread tapi...@gmail.com
rtOneline-4, > and both are significantly faster than the others. > > On Friday, 14 May 2021 at 23:49:16 UTC+1 peterGo wrote: > >> My results: >> >> https://play.golang.org/p/o2cGAcpNMkX >> >> I can't reproduce your results. >> >> Peter >>

[go-nuts] Re: Strange benchmark results

2021-05-16 Thread tapi...@gmail.com
1:1 to 2:1 for append versus precise implementations. > > I am unable reproduce your result. > > Peter > > On Thursday, May 13, 2021 at 4:52:32 AM UTC-4 tapi...@gmail.com wrote: > >> >> package main >> >> import "testing" >> >> con

[go-nuts] Strange benchmark results

2021-05-13 Thread tapi...@gmail.com
package main import "testing" const N = 1615119 // It is strange that if N is large enough, // the one line implementations are fast as the others. // And if N is odd number, the InsertOneline_Disassemble // implementation is about 10% faster than the others. func init() {

[go-nuts] Re: Strange benchmark results

2021-05-13 Thread tapi...@gmail.com
Sorry, there is a temp tweak, the N/5 should be N/2. The second conclusion should be: // And if N is odd number, the InsertOneline // implementations are about 10% faster than the others. On Thursday, May 13, 2021 at 4:52:32 AM UTC-4 tapi...@gmail.com wrote: > > package main > > imp

[go-nuts] When will the stack of a goroutine shrink?

2021-05-21 Thread tapi...@gmail.com
>From the outputs of the following program, it looks the stack of a goroutine doesn't shrink immediately. Will it shrink at some point eventually? package main func f(i int) byte { type T int // avoid f being inline var a [1<<20]byte // make stack grow return a[i] } func main(){

[go-nuts] Re: Strange benchmark results

2021-05-16 Thread tapi...@gmail.com
On Sunday, May 16, 2021 at 4:46:44 AM UTC-4 Brian Candler wrote: > On Sunday, 16 May 2021 at 08:07:17 UTC+1 tapi...@gmail.com wrote: > >> > you don't provide memory allocation statistics, >> >> There are no surprises in memory allocation statistics so I didn't >&

Re: [go-nuts] Boxing bytes is faster than boxing integers within [0. 255]. Why?

2021-05-10 Thread tapi...@gmail.com
elp? > > > https://github.com/golang/go/blob/25aff96f4b49842a44253b72472062a6d775231c/src/cmd/compile/internal/gc/walk.go#L841 > > On Mon, May 10, 2021 at 4:46 PM tapi...@gmail.com > wrote: > >> Yes, I'm aware of this optimization. >> But it looks another opti

Re: [go-nuts] parameter name a of fmt package

2021-05-25 Thread tapi...@gmail.com
On Tuesday, May 25, 2021 at 6:14:24 AM UTC-4 Delta Echo wrote: > > It's a parameter name. ...interface{} is the type of that argument, > variadic in this case indicated by the ellipsis. > > You misunderstood my question. > > My question was what does `a` refers to? > > Like, > fd - file

Re: [go-nuts] Re: Value copy costs are not very predictable.

2021-05-31 Thread tapi...@gmail.com
10 0.7755 ns/op >> >> In other words, it looks there is mutual interference between benchmarks. >> >> On Saturday, May 29, 2021 at 11:49:47 PM UTC-4 tapi...@gmail.com wrote: >> >>> The benchmark code: https://play.golang.org/p/bC1zO14eNeh >&g

[go-nuts] Re: The last line makes the variable y escape. But should it?

2021-06-02 Thread tapi...@gmail.com
, 2021 at 9:51:50 AM UTC-4 tapi...@gmail.com wrote: > > package main > > func newIntPtr(n int) *int { > return > } > > func main() { > x := newIntPtr(3) > y := newIntPtr(5) > c := make(chan bool) > go func() { > *y++ > clo

Re: [go-nuts] Re: Value copy costs are not very predictable.

2021-05-31 Thread tapi...@gmail.com
On Monday, May 31, 2021 at 10:07:35 AM UTC-4 axel.wa...@googlemail.com wrote: > On Mon, May 31, 2021 at 3:30 PM tapi...@gmail.com > wrote: > >> On Sunday, May 30, 2021 at 12:54:02 PM UTC-4 axel.wa...@googlemail.com >> wrote: >> >>> That is very norma

Re: [go-nuts] Re: Is the escape analysis reports accurate?

2021-05-23 Thread tapi...@gmail.com
ould be to collect some data on that, showing that for a >>>>> useful corpus of Go programs, the heuristics lead to more adverse effects >>>>> (e.g. slower programs) than an alternative you would suggest. But it's >>>>> not >>>>> productiv

[go-nuts] Re: Is the escape analysis reports accurate?

2021-05-23 Thread tapi...@gmail.com
= ts: > ./tl.2.go:19:18: from return ts (return) at ./tl.2.go:20:5 > ./tl.2.go:19:18: make([]T, N) escapes to heap > > > On Sunday, May 23, 2021 at 5:01:38 AM UTC-4 tapi...@gmail.com wrote: > >> And how to interpret the conflicting messages for the following program? >

Re: [go-nuts] When will the stack of a goroutine shrink?

2021-05-23 Thread tapi...@gmail.com
Thanks for the explanation. On Friday, May 21, 2021 at 4:16:45 PM UTC-4 Ian Lance Taylor wrote: > On Fri, May 21, 2021 at 7:46 AM tapi...@gmail.com > wrote: > > > > From the outputs of the following program, > > it looks the stack of a goroutine doesn't shrink immedia

Re: [go-nuts] Re: Is the escape analysis reports accurate?

2021-05-23 Thread tapi...@gmail.com
On Sunday, May 23, 2021 at 5:04:37 AM UTC-4 axel.wa...@googlemail.com wrote: > On Sun, May 23, 2021 at 11:02 AM tapi...@gmail.com > wrote: > >> And how to interpret the conflicting messages for the following program? >> > > In one case, `g` is inlined, which is s

Re: [go-nuts] Re: Is the escape analysis reports accurate?

2021-05-23 Thread tapi...@gmail.com
maybe you should just try and > collect data and file an issue, if you want this to change. > > On Sun, May 23, 2021 at 12:57 PM tapi...@gmail.com > wrote: > >> I do agree escape analysis is hard and gc is clever enough to handle many >> cases. >> But at this speci

Re: [go-nuts] Re: Is the escape analysis reports accurate?

2021-05-23 Thread tapi...@gmail.com
re other > avenues you can explore. > Yes. I don't expect there must be an answer. I just show some weird things. Maybe the info is helpful for someone. ;D > > >> >> >>> >>> As I said, maybe someone else can. Or maybe you should just try and >>>

[go-nuts] Re: Is the escape analysis reports accurate?

2021-05-23 Thread tapi...@gmail.com
On Sunday, May 23, 2021 at 4:51:30 AM UTC-4 tapi...@gmail.com wrote: > In the following code, "make([]T, n)" is reported as escaped. > But does it really always escape at run time? > Does the report just mean "make([]T, n) possibly escapes to heap"? > > pack

Re: [go-nuts] On tip, arguments of panic escape to heap

2021-05-23 Thread tapi...@gmail.com
got it. On Sunday, May 23, 2021 at 3:50:10 AM UTC-4 cuong.m...@gmail.com wrote: > Hi, > > It's normal, go1.16 and before is just incorrect for not reporting that > escaping. See: https://go-review.googlesource.com/c/go/+/284412 > > Cheers, > Cuong > > On Sun, M

Re: [go-nuts] Is the escape analysis reports accurate?

2021-05-23 Thread tapi...@gmail.com
nstant. It might even just mark > every `make` with a `var` argument as escaping. > > On Sun, May 23, 2021 at 10:51 AM tapi...@gmail.com > wrote: > >> In the following code, "make([]T, n)" is reported as escaped. >> But does it really always escape at run time? >&

Re: [go-nuts] Re: Is the escape analysis reports accurate?

2021-05-23 Thread tapi...@gmail.com
On Sunday, May 23, 2021 at 5:22:23 AM UTC-4 Jan Mercl wrote: > On Sun, May 23, 2021 at 11:11 AM tapi...@gmail.com > wrote: > > > > It says both "make([]T, N) does not escape" and "make([]T, N) escapes to > heap" for the slice allocated by g. &g

[go-nuts] Re: Is the escape analysis reports accurate?

2021-05-23 Thread tapi...@gmail.com
On Sunday, May 23, 2021 at 5:42:41 AM UTC-4 tapi...@gmail.com wrote: > On Sunday, May 23, 2021 at 4:51:30 AM UTC-4 tapi...@gmail.com wrote: > >> In the following code, "make([]T, n)" is reported as escaped. >> But does it really always escape at run time? >> D

[go-nuts] Is the escape analysis reports accurate?

2021-05-23 Thread tapi...@gmail.com
In the following code, "make([]T, n)" is reported as escaped. But does it really always escape at run time? Does the report just mean "make([]T, n) possibly escapes to heap"? package main type T int const K = 1<<13 const N = 1<<12 var n = N var i = n-1 func main() { var r = make([]T, N) //

[go-nuts] Re: Is the escape analysis reports accurate?

2021-05-23 Thread tapi...@gmail.com
n(r1[i]) } func g() []T { var ts = make([]T, N) // make([]T, N) escapes to heap return ts } On Sunday, May 23, 2021 at 4:51:30 AM UTC-4 tapi...@gmail.com wrote: > In the following code, "make([]T, n)" is reported as escaped. > But does it really always escape at run time?

Re: [go-nuts] Re: Is the escape analysis reports accurate?

2021-05-23 Thread tapi...@gmail.com
slower > programs) than an alternative you would suggest. But it's not productive to > just black-box poke at escape analysis using toy examples and derive broad > judgments about the existing heuristics from that. > > On Sun, May 23, 2021 at 11:57 AM tapi...@gmail.com > wrote: &g

[go-nuts] On tip, arguments of panic escape to heap

2021-05-23 Thread tapi...@gmail.com
Go 1.16 doesn't make this. Is it nornal? package main func main(){ panic("abc") // "abc" escapes to heap } -- 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

Re: [go-nuts] Re: Is the escape analysis reports accurate?

2021-05-23 Thread tapi...@gmail.com
It says both "make([]T, N) does not escape" and "make([]T, N) escapes to heap" for the slice allocated by g. On Sunday, May 23, 2021 at 5:05:53 AM UTC-4 Jan Mercl wrote: > On Sun, May 23, 2021 at 11:01 AM tapi...@gmail.com > wrote: > > > And how to

[go-nuts] Re: Strange benchmark results

2021-05-24 Thread tapi...@gmail.com
does move more memory, but this disadvantage is compensated by its advantage of spending less time on memclrNoHeapPointers when N is large. On Thursday, May 13, 2021 at 4:52:32 AM UTC-4 tapi...@gmail.com wrote: > > package main > > import "testing" > > const N

[go-nuts] Re: Strange benchmark results

2021-05-24 Thread tapi...@gmail.com
The profiling results constantly show that more time are spent on memclrNoHeapPointers if N is a big even integer (1615118) than a big odd integer (1615119). On Thursday, May 13, 2021 at 5:07:49 AM UTC-4 tapi...@gmail.com wrote: > Sorry, there is a temp tweak, the N/5 should be

Re: [go-nuts] Re: Is the escape analysis reports accurate?

2021-05-24 Thread tapi...@gmail.com
ting both to either values slows them down, speeds > them up, or leaves them the same. You'll know if it's a good idea then. > > On Sun, May 23, 2021 at 7:05 PM tapi...@gmail.com > wrote: > >> Thanks for the code link. It looks, new(LargeSizeArray) escapes for this >

[go-nuts] Re: Value copy costs are not very predictable.

2021-05-30 Thread tapi...@gmail.com
at 11:49:47 PM UTC-4 tapi...@gmail.com wrote: > The benchmark code: https://play.golang.org/p/bC1zO14eNeh > > The result: > > $ go test -bench=. > goos: linux > goarch: amd64 > pkg: example.com/valuecopy > cpu: Intel(R) Core(TM) i5-3210M CPU @ 2.5

Re: [go-nuts] Value copy costs are not very predictable.

2021-05-30 Thread tapi...@gmail.com
gcflags=-S shows the code of copy 3-field and 4-field structs: // struct{a, b, c int} 0x0034 00052 (valuecopy.go:223)MOVQ$0, "".struct3_0(SB) 0x003f 00063 (valuecopy.go:223)XORPSX0, X0 0x0042 00066 (valuecopy.go:223)MOVUPSX0, "".struct3_0+8(SB) //

[go-nuts] Value copy costs are not very predictable.

2021-05-29 Thread tapi...@gmail.com
The benchmark code: https://play.golang.org/p/bC1zO14eNeh The result: $ go test -bench=. goos: linux goarch: amd64 pkg: example.com/valuecopy cpu: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz Benchmark_CopyBool-410 0.8885 ns/op Benchmark_CopyByte-4

Re: [go-nuts] Value copy costs are not very predictable.

2021-05-29 Thread tapi...@gmail.com
On Sunday, May 30, 2021 at 12:28:55 AM UTC-4 Kurtis Rader wrote: > On Sat, May 29, 2021 at 8:50 PM tapi...@gmail.com > wrote: > >> The benchmark code: https://play.golang.org/p/bC1zO14eNeh >> > ... >> > From the benchmark result, it looks >> * the

Re: [go-nuts] Re: Is this a bug ?

2021-06-03 Thread tapi...@gmail.com
Another runnable example: package main const x = 8 var y = 8 var a byte = 1 << x / 2 var b byte = 1 << y / 2 func main() { println(a) // 128 println(b) // 0 } On Thursday, June 3, 2021 at 10:42:32 AM UTC-4 peterGo wrote: > Jan, > > The untyped constant 1 assumes the type of x, which is

[go-nuts] The last line makes the variable y escape. But should it?

2021-06-01 Thread tapi...@gmail.com
package main func newIntPtr(n int) *int { return } func main() { x := newIntPtr(3) y := newIntPtr(5) c := make(chan bool) go func() { *y++ close(c) }() <-c println(*x, *y) println() //println() // This line makes y escape. } -- You

Re: [go-nuts] The last line makes the variable y escape. But should it?

2021-06-01 Thread tapi...@gmail.com
021 at 10:26:04 AM UTC-4 Jan Mercl wrote: > On Tue, Jun 1, 2021 at 3:52 PM tapi...@gmail.com > wrote: > > By default, any local variable that has its address taken and that > address can outlive the function execution forces the variable to > escape, quite naturally as the st

Re: [go-nuts] Re: Is the escape analysis reports accurate?

2021-06-01 Thread tapi...@gmail.com
at 4:25:18 AM UTC-4 tapi...@gmail.com wrote: > I will if I get enough time and become more familiar with the code. > Meanwhile, I think it is a not a bad idea to post my investigations here. > If some people with relevant experiences could make some explanations > without sp

Re: [go-nuts] Re: Is the escape analysis reports accurate?

2021-06-01 Thread tapi...@gmail.com
On Tuesday, June 1, 2021 at 10:48:22 AM UTC-4 Jan Mercl wrote: > On Tue, Jun 1, 2021 at 4:40 PM tapi...@gmail.com > wrote: > > > The following is a tip to get an array pointer but avoid the array > escaping. > > I don't think so. The pointer to the local array 't'

[go-nuts] Re: Surprising benchmark result

2021-07-07 Thread tapi...@gmail.com
It is found that the test file is not written correctly. The filtered data should be reset in each loop. The corrected one: https://play.golang.org/p/yJMweZLIXAz <https://t.co/dZUGrAQ1cB?amp=1> ;D On Monday, June 7, 2021 at 10:57:19 AM UTC-4 tapi...@gmail.com wrote: > > The

[go-nuts] How to pause/restart timer in a benchmark loop?

2021-07-07 Thread tapi...@gmail.com
For example, I don't want the time consumed for "copy(data2, data)" being counted. How to achieve this? func BenchmarkFilter3(b *testing.B) { data := buildOrginalData() data2 := make([]int, len(data)) b.ResetTimer() for i := 0; i < b.N; i++ { copy(data2, data) _

[go-nuts] Re: How to pause/restart timer in a benchmark loop?

2021-07-07 Thread tapi...@gmail.com
day, July 7, 2021 at 11:28:13 AM UTC-4 tapi...@gmail.com wrote: > > For example, I don't want the time consumed for "copy(data2, data)" being > counted. > How to achieve this? > > func BenchmarkFilter3(b *testing.B) { > data := buildOrginalData() &

[go-nuts] Re: How to pause/restart timer in a benchmark loop?

2021-07-07 Thread tapi...@gmail.com
er's solution exhausted my memory and hang my whole computer, and I have to restart it. > > On Wednesday, July 7, 2021 at 11:29:30 AM UTC-4 tapi...@gmail.com wrote: > >> This doesn't work: >> >> func BenchmarkFilter3(b *testing.B) { >> data := buildOrginalData() >> data2

[go-nuts] Re: How to pause/restart timer in a benchmark loop?

2021-07-07 Thread tapi...@gmail.com
On Wednesday, July 7, 2021 at 8:01:54 PM UTC-4 tapi...@gmail.com wrote: > On Wednesday, July 7, 2021 at 12:32:38 PM UTC-4 jake...@gmail.com wrote: > >> It would be helpful to give more information as to why you say "This >> doesn't work"? >> But, I'm guessing

[go-nuts] Re: Why does one string concatenation escape, but the other not?

2021-06-24 Thread tapi...@gmail.com
side the loop is set inside the loop does it > escape. > Yes, testing is not relevant here. It is the loop make effects here. > > On Wednesday, June 23, 2021 at 12:39:17 AM UTC-4 tapi...@gmail.com wrote: > >> >> package main >> >> import "testing"

[go-nuts] Re: Stack growing is inefficient

2021-06-30 Thread tapi...@gmail.com
70> > > get run?" - is that right? Almost true. Whether or not it should run, growing the stack from 2048 to 512M in 18+ steps looks not right. > > On Wednesday, 30 June 2021 at 14:21:21 UTC+1 tapi...@gmail.com wrote: > >> Sorry, I post the wrong anchor. It is li

Re: [go-nuts] Re: Stack growing is inefficient

2021-06-30 Thread tapi...@gmail.com
On Wednesday, June 30, 2021 at 8:46:19 PM UTC-4 axel.wa...@googlemail.com wrote: > On Thu, Jul 1, 2021 at 2:34 AM tapi...@gmail.com > wrote: > >> >> >> On Wednesday, June 30, 2021 at 11:56:45 AM UTC-4 Brian Candler wrote: >> >>> So I think what y

[go-nuts] Stack growing is inefficient

2021-06-30 Thread tapi...@gmail.com
It looks this line https://github.com/golang/go/blob/master/src/runtime/stack.go#L1078 never gets executed. An example: package main const N = 512 * 1024 * 1024 // 500M var v byte = 123 func main() { var s = []byte{N: 0} for i := range s { s[i] = v } println(s[v]) } I added a

[go-nuts] Re: Stack growing is inefficient

2021-06-30 Thread tapi...@gmail.com
new goroutine still starts from 2048 bytes. On Wednesday, June 30, 2021 at 3:25:59 AM UTC-4 tapi...@gmail.com wrote: > > It looks this line > https://github.com/golang/go/blob/master/src/runtime/stack.go#L1078 never > gets executed. > > An example: > > package main &g

Re: [go-nuts] Re: Stack growing is inefficient

2021-07-01 Thread tapi...@gmail.com
e. > > V. > > On Thursday, 1 July 2021 at 03:03:37 UTC+2 tapi...@gmail.com wrote: > >> On Wednesday, June 30, 2021 at 8:46:19 PM UTC-4 axel.wa...@googlemail.com >> wrote: >> >>> On Thu, Jul 1, 2021 at 2:34 AM tapi...@gmail.com >>> wrote: >>&

Re: [go-nuts] Re: Stack growing is inefficient

2021-07-01 Thread tapi...@gmail.com
ead. With this change, the time needed to build the toolchain is reduced to 2m40.123s (from 3m3.897s). On Thursday, July 1, 2021 at 8:42:41 AM UTC-4 Jan Mercl wrote: > On Thu, Jul 1, 2021 at 2:34 PM tapi...@gmail.com > wrote: > > > It is not rare a function will use 10M+ stack. > > What's

Re: [go-nuts] Re: Stack growing is inefficient

2021-07-01 Thread tapi...@gmail.com
ncing a real problem due to this, you might > want to open an issue. > > On Thu, Jul 1, 2021 at 3:04 AM tapi...@gmail.com > wrote: > >> >> >> On Wednesday, June 30, 2021 at 8:46:19 PM UTC-4 axel.wa...@googlemail.com >> wrote: >> >>> On Thu, Ju

[go-nuts] Re: Stack growing is inefficient

2021-06-30 Thread tapi...@gmail.com
Sorry, I post the wrong anchor. It is line 1068: https://github.com/golang/go/blob/d19a53338fa6272b4fe9c39d66812a79e1464cd2/src/runtime/stack.go#L1068 On Wednesday, June 30, 2021 at 5:08:30 AM UTC-4 Brian Candler wrote: > On Wednesday, 30 June 2021 at 08:25:59 UTC+1 tapi...@gmail.com wr

[go-nuts] gc uses different comparation operators to compare some thredshold values

2021-06-26 Thread tapi...@gmail.com
The code: https://github.com/golang/go/blob/cca23a73733ff166722c69359f0bb45e12ccaa2b/src/cmd/compile/internal/escape/escape.go#L2012-L2025 xxx > ir.MaxStackVarSize xxx >= ir.MaxImplicitStackVarSize This leads to the elements of a slice with size as ir. MaxImplicitStackVarSize will be

[go-nuts] Re: gc uses different comparation operators to compare some thredshold values

2021-06-26 Thread tapi...@gmail.com
Sorry, a typo in title. It should be "comparison". On Saturday, June 26, 2021 at 5:50:55 AM UTC-4 tapi...@gmail.com wrote: > > The code: > https://github.com/golang/go/blob/cca23a73733ff166722c69359f0bb45e12ccaa2b/src/cmd/compile/internal/escape/escape.go#

Re: [go-nuts] Re: gc uses different comparation operators to compare some thredshold values

2021-06-26 Thread tapi...@gmail.com
a bug. And if it's just curiosity, you can always try and > change it and see what breaks. Go has a lot of tests. > > On Sat, Jun 26, 2021 at 11:52 AM tapi...@gmail.com > wrote: > >> Sorry, a typo in title. It should be "comparison". >> >> On Saturday,

[go-nuts] Re: Named types vs not named types

2021-06-27 Thread tapi...@gmail.com
A some weak reason not to support the change. Using unnamed parameter types could avoiding some explicit conversions. package main import "net/http" type MyHandlerFunc func(http.ResponseWriter, *http.Request) func f(http.HandlerFunc) {} func g(MyHandlerFunc) {} func

  1   2   3   >