Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
homercles
Feb 14, 2010

I'm building a tool that does a lot of computation through lots of goroutines, and pipelining chunks of work in N:M relations. Before I start optimising, I want to know, for each goroutine:
  • How much time it is waiting on channels to return data
  • How much time it is running
  • How much time it is pending to run because other goroutines are currently running
Is it possible to get these goroutine stats in a concise manner?

Adbot
ADBOT LOVES YOU

homercles
Feb 14, 2010

@hadlock, I do use go-torch already but, while useful, it's not the right tool for showing the lifecycle of a goroutine
@Eela6, those links are extremely my poo poo

homercles
Feb 14, 2010

canis minor posted:

I'm beginning with Go, and I can't find a simple, generic way to achieve what I'm after, with people advocating approach no 1

For when you can't be arsed: https://github.com/jmoiron/jsonq

homercles
Feb 14, 2010

Convert it to a number with unsafe.Pointer, or stringise it with fmt.Sprint and compare the strings?

homercles
Feb 14, 2010

Yeah it's safe, eg net.TCPConn.Close -> net.conn.Close -> net.netFD.Close -> internal.poll.FD.Close, which itself wraps each close operation in a call to fd.fdmu.increfAndClose which safely guards against multiple closes of the same FD.

You can navigate this stuff fairly easily in just godoc source view mode if you run it with godoc -analysis type -http :7070. strace this example code and you get this output, demonstrating closes on the old socket struct don't impact the newly allocated socket despite it reusing fd 3.

I can't speak for your websocket library, but the core library socket impl looks safe.

homercles
Feb 14, 2010

Does building your code with the race detector shed any light?

Adbot
ADBOT LOVES YOU

homercles
Feb 14, 2010

Ignoring the "compile struct to parsing code" alternatives, some dynamic stuff:

1. https://github.com/jmoiron/jsonq
2. https://github.com/valyala/fastjson
3. https://github.com/stretchr/objx
4. https://github.com/yalp/jsonpath

Ranked in order of interestingness.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply