[go-nuts] Re: goroutine benchmark results interpretation for anonymous func?

2022-06-12 Thread Const V
All valid questions. Still my original question remains - the timing I've got is inuntitive. On Sunday, June 12, 2022 at 9:49:50 PM UTC-7 Tamás Gulácsi wrote: > ch <- bytes.Contains(b.Bytes()[start:end], find) >select { >case <-quit: > quit <-

[go-nuts] Re: goroutine benchmark results interpretation for anonymous func?

2022-06-12 Thread Tamás Gulácsi
ch <- bytes.Contains(b.Bytes()[start:end], find) select { case <-quit: quit <- "bye" return } Don't you want a "default:" case in there? This way all your goroutines are kept alive and waiting for that quit - wh

[go-nuts] Re: goroutine benchmark results interpretation for anonymous func?

2022-06-12 Thread Const V
The way I'm using is "b" is a large buffer - hundreds of MB. I want to stop processing after the string is found using "quit". for i := 0; i < cores; i++ { go func(start, end, i int, quit chan string) { ch <- bytes.Contains(b.Bytes()[start:end], find) select

Re: [go-nuts] Re: Go 1.19 Beta 1 is released

2022-06-12 Thread Eric Hubbard
> debug.SetMemoryLimit will be useful (for me at least). Me too! :) I need to read up more about it though. It seems to be a soft limit, not a hard limit. We run in a container that has limited memory.. and anything we can do to make the GC aware of that limit would be nice.. -Eric http://www.

[go-nuts] Re: goroutine benchmark results interpretation for anonymous func?

2022-06-12 Thread Brian Candler
No: I'm suggesting exactly what I wrote. Starting a goroutine looks like this: go () It doesn't have to be an anonymous function, it can be a "real" function. Hence this is perfectly valid: go BytesContainsCh1(b.Bytes(), start, end, find, ch) On Sunday, 12 June 2022 at 18:17:23 UTC+2 Const

Re: [go-nuts] Re: Go 1.19 Beta 1 is released

2022-06-12 Thread Amnon
debug.SetMemoryLimit will be useful (for me at least). But a bit disappointed not to see a fix for https://github.com/golang/go/issues/50603. On Sunday, 12 June 2022 at 05:51:23 UTC+1 ben...@gmail.com wrote: > I'm quite looking forward to the performance improvements we'll get for > free (i.e.,

[go-nuts] Re: goroutine benchmark results interpretation for anonymous func?

2022-06-12 Thread Const V
I already have a go routine on the anonymous function: go func(start, end, i int, quit chan string) { You are suggesting doing this? go func(start, end, i int, quit chan string) { go BytesContainsCh1(b.Bytes(), start, end, find, ch) }(start, end, i, quit) On Sunday, June 12, 2022 at 2:54

[go-nuts] Re: goroutine benchmark results interpretation for anonymous func?

2022-06-12 Thread Brian Candler
On Sunday, 12 June 2022 at 09:16:30 UTC+1 Const V wrote: > go func(start, end, i int, quit chan string) { > BytesContainsCh1(b.Bytes(), start, end, find, ch) >}(start, end, i, quit) > I note that this could be further simplified to: go BytesContainsCh1(b.Bytes(), start, end, find, ch

Re: [go-nuts] Help with sync.Cond failing to signal

2022-06-12 Thread Brian Candler
And just as an aside, I think you would be interested in the talk "Rethinking Classical Concurrency Patterns" by Bryan C. Mills https://www.youtube.com/watch?v=5zXAHh5tJqQ On Sunday, 12 June 2022 at 05:06:47 UTC+1 ke...@burke.dev wrote: > That's a very clear explanation, it's obvious what the pr

[go-nuts] goroutine benchmark results interpretation for anonymous func?

2022-06-12 Thread Const V
I'm implementing the following algorithm - sending result from bytes.Contains - true or false to 1) channel directly and 2) via func. I'm expecting 1)to be faster but actually 2) is faster: 4.99s vs 6.47s 1) via channel: for i := 0; i < cores; i++ { start := i * chunksize end := min(start+