[go-nuts] Attaching a Finalizer to a struct field holding a slice or the slice's underlying array

2019-12-28 Thread John
Looking for a little insight on if it is possible to do something: Given this type: type Blah struct { Payload []byte } What I'm looking for is to kick off a finalizer when a slice and all other slices backed by the same array get GC'd. In lieu of that, whenver the pointer to the array ba

Re: [go-nuts] Simple worker pool in golnag

2019-12-28 Thread Agniva De Sarker
Perhaps I wasn't clear, but I am not suggesting to use one goroutine per table. You can limit the no. of goroutines running (say 25 at a time) by just spawning them and wait for the entire task to complete, without creating a worker pool of 25 goroutines. It is basically a counting semaphore with a

[go-nuts] Help em if e else em Go

2019-12-28 Thread Everton Marques
Existe esse grupo em Português: https://groups.google.com/forum/m/#!forum/golang-brasil -- 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...@g

[go-nuts] Re: Simple worker pool in golnag

2019-12-28 Thread Jake Montgomery
The high level design discussions are great. But I want to point out that the code, as written, has a race related bug. When this line is called, the workerWg has a 0 count. go kafkaProducerWorkers(autoCancelChan, workerWg) It is entirely possible for the workerWg.Wait() line to be called be

Re: [go-nuts] Simple worker pool in golnag

2019-12-28 Thread Chris Burkert
I needed a way to let the database complete a few tables (max 25) at a time without the need for the database to handle other tables in between. A worker pool which reads one table after the other does that perfectly. That also means that if all workers wait for the database then my whole program w

Re: [go-nuts] Simple worker pool in golnag

2019-12-28 Thread Michael Jones
I often choose worker pools when there is working storage to be allocated as part of the work to be done. This way means that such data and processing structures are naturally built and torn down right there before and after the work-channel loop in the worker, with no repeated allocations during r

[go-nuts] Re: net.conn TCP connection

2019-12-28 Thread Jake Montgomery
On Friday, December 27, 2019 at 10:36:28 PM UTC-5, Ron Wahler wrote: > > I did look at ReadAll, but it won't return until it sees EOF. I am trying > to find something that would return when the standard read would return. I > get the memory part and would manage that. Any other ideas ? > Its un

Re: [go-nuts] Simple worker pool in golnag

2019-12-28 Thread Ian Lance Taylor
On Sat, Dec 28, 2019 at 6:11 AM Robert Engels wrote: > > Spinning up a Go routine when for each piece of work may be idiomatic but it > is far from the best practice for many situations - mainly because of cpu > cache invalidation. Most HPC systems create worker pools by type and then > isolate

[go-nuts] how to reuse http client connection by different proxy host in golang

2019-12-28 Thread tim0991s
Here is my code https://goplay.space/#z5J6i_EPWmx I want use the code to check the availability of the proxies After set ulimit -n 256 and run for a while i got the error socket too many open files ll /proc/$(ps aux|grep -v "grep"|grep './main'|awk '{print $2}'|head)/fd|grep -v '\.\.'|gre

Re: [go-nuts] Simple worker pool in golnag

2019-12-28 Thread Robert Engels
Spinning up a Go routine when for each piece of work may be idiomatic but it is far from the best practice for many situations - mainly because of cpu cache invalidation. Most HPC systems create worker pools by type and then isolate them to cpus/cores - something you can’t do in Go. I believe t

Re: [go-nuts] Simple worker pool in golnag

2019-12-28 Thread Agniva De Sarker
> (the task was to limit the whole thing to about 10% of cores) I still don't think you needed a worker pool here. Like OP mentioned above, you could just limit the number of goroutines executed to 10% of total cores. On Saturday, 28 December 2019 18:02:08 UTC+5:30, Chris Burkert wrote: > > Th

Re: [go-nuts] Simple worker pool in golnag

2019-12-28 Thread Brian Candler
Certainly it's important to limit the concurrency, and in your case you need to process the larger tasks first. However, to me, the defining characteristic of a "worker pool" are: 1. workers are created before any tasks need to be done 2. the same worker handles multiple tasks sequentially 3. wor

Re: [go-nuts] Simple worker pool in golnag

2019-12-28 Thread Chris Burkert
There are Pros and Cons for everything in life. Some time ago I wrote a database tool which does something per table where the runtime largely depends on the table size. I started with one goroutine per table because it was easy. But that put a high load on the database (the task was to limit the w

Re: [go-nuts] Simple worker pool in golnag

2019-12-28 Thread Brian Candler
On Friday, 27 December 2019 16:30:48 UTC, Bruno Albuquerque wrote: > > This might be useful too you, in any case: > > https://git.bug-br.org.br/bga/workerpool > > I think the point from Bryan Mills' video is, "worker pool" is something of an anti-pattern in go. goroutines are so cheap that you mi

[go-nuts] Re: Help get me started on a project

2019-12-28 Thread Jason E. Aten
also https://github.com/peterh/liner -- 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