Re: [go-nuts] The program stucked on __vdso_clock_gettime (x86_64)

2022-07-05 Thread Konstantin Khomoutov
On Mon, Jul 04, 2022 at 01:57:06AM -0700, Chenhong Liu wrote: [...] > After profiling the process with perf command, the perf data shows the > program looped to call __vdso_clock_gettime . > > 64.20% controllerd [vdso] [.] __vdso_clock_gettime > 8.82% controllerd controllerd [.] runtime.procyie

[go-nuts] Do I need a reentrant locks?

2022-07-05 Thread atd...@gmail.com
Hi, I have a tree datastructure where mutating some nodes *may *trigger a mutation on some other tree nodes. This tree should be accessible by multiple goroutines but mutated by only one at a time. As such, I wanted to have a global lock on the tree such that mutatiing node methods should acq

[go-nuts] Re: Do I need a reentrant locks?

2022-07-05 Thread Brian Candler
Have a public Set() that does the lock and then calls a private internal function, which assumes it's already running under the lock. https://go.dev/play/p/M1XuC8bxCxL On Tuesday, 5 July 2022 at 13:32:26 UTC+1 atd...@gmail.com wrote: > Hi, > > I have a tree datastructure where mutating some node

Re: [go-nuts] The program stucked on __vdso_clock_gettime (x86_64)

2022-07-05 Thread Neo Liu
> > > For me, this looks like the program is merely idling, and what you're > observing is reading current time by the scheduler implemented by the Go > runtime. > I didn't try it. The environment located in customer's data center, not allowed to try this kind of things on it. > > [...] > >

[go-nuts] Re: Do I need a reentrant locks?

2022-07-05 Thread atd...@gmail.com
:) That's what the asterisked note was for in the original question. I don't think I can do that in the real code because the real code is much more complex. Each node actually triggers a callback that may modify another node. That callback is user-created, not framework created so I have no wa

Re: [go-nuts] Re: Do I need a reentrant locks?

2022-07-05 Thread Marvin Renich
* Brian Candler [220705 09:48]: > Have a public Set() that does the lock and then calls a private internal > function, which assumes it's already running under the lock. > https://go.dev/play/p/M1XuC8bxCxL > > On Tuesday, 5 July 2022 at 13:32:26 UTC+1 atd...@gmail.com wrote: > > > Hi, > > > > I

Re: [go-nuts] Re: Do I need a reentrant locks?

2022-07-05 Thread Marvin Renich
* atd...@gmail.com [220705 10:03]: > :) That's what the asterisked note was for in the original question. I > don't think I can do that in the real code because the real code is much > more complex. Each node actually triggers a callback that may modify > another node. That callback is user-cre

Re: [go-nuts] Re: Do I need a reentrant locks?

2022-07-05 Thread atd...@gmail.com
You're absolutely right. (I wrote the simplified example a bit too fast and missed that in a few places https://go.dev/play/p/9fk_yt0vkHD) To add the general motivation, I have a reactive UI tree and need to introduce concurrency (for when async data fetching is done and the data is reintroduc

Re: [go-nuts] Do I need a reentrant locks?

2022-07-05 Thread robert engels
This is a recipe for bad bugs. Use defensive programming - grab the lock in the top-level functions, have private functions like ‘doWithLock()’ as a signal to the developer that they must be holding the lock. Allowing callbacks to call back into a concurrent safe structure is very difficult

Re: [go-nuts] Do I need a reentrant locks?

2022-07-05 Thread robert engels
I would put all of the mutations on a queue so they are single threaded. > On Jul 5, 2022, at 9:51 AM, robert engels wrote: > > This is a recipe for bad bugs. Use defensive programming - grab the lock in > the top-level functions, have private functions like ‘doWithLock()’ as a > signal to

[go-nuts] Re: fmt package documentation

2022-07-05 Thread ben...@gmail.com
At the default URL https://pkg.go.dev/fmt the same thing happens for me too. However, at https://pkg.go.dev/fmt@master it formats correctly (pre-formatted block like in the source). So I assume this has been fixed and the default will be updated soon (when 1.19 comes out?). -Ben On Tuesday, Ju

[go-nuts] gopacket get index of IP layer dynamically

2022-07-05 Thread Hakan SARIMAN
Hi Folks, I have a go program that reads some network packets from an interface (not using pcap). Some of packets has 802.1Q encapsulation and some of them has not. I’m searching a way to figure out index of IP layer dynamically from whole packet.(gopacket.Packet.Bytes()) e.g. IP layer starts fr

[go-nuts] Re: fmt package documentation

2022-07-05 Thread peterGo
Other flags is fixed in Go 1.19: https://pkg.go.dev/fmt@go1.19beta1 Peter On Tuesday, July 5, 2022 at 5:47:55 PM UTC-4 ben...@gmail.com wrote: > At the default URL https://pkg.go.dev/fmt the same thing happens for me > too. However, at https://pkg.go.dev/fmt@master it formats correctly > (pre-