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 <-
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
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
> 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.
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
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.,
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
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
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
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+
10 matches
Mail list logo