News for hackers. Stuff that matters.
Re:Building a high performance JSON parser by masklinn on Sunday June 28, 2020 @06:16AM (#23667824)
[in Go] seems relevant enough to be added to the title as other languages could reasonably easily bind to existing high-performance JSON parsers like sajson or simdjson but doing so from Go incurs all the usual cgo issues.
Re:Building a high performance JSON parser by tych0 on Sunday June 28, 2020 @09:59AM (#23668716)
What are the usual cgo issues? I've used it a fair bit and haven't had any general problems.

There are specific problems like you can't use syscalls which must be single threaded (a royal pain for container managers, since setns() is), but binding to a library like simdjson wouldn't have this problem.

Re:Building a high performance JSON parser by masklinn on Sunday June 28, 2020 @11:33AM (#23669440)
> What are the usual cgo issues? I've used it a fair bit and haven't had any general problems.

1. cgo calls have much higher overhead than regular function calls, so for small documents you'd likely lose performance rather than gain, and even for large ones depending how you read from the parser it might also be terrible, callback-based libraries are even worse as calling Go from C is even slower

2. concurrency can suffer a lot as a Ccall will prevent switching out the corresponding goroutine, locking out a scheduler thread

3. cgo complicates builds, especially cross-compilation

4. it also makes deployments more complicated if you were relying on just synching a statically linked binary

5. might have improved since, but used to be most of the built-in Go development tools couldn't cross the cgo barrier, and non-go devtools generally don't support go

Re:Building a high performance JSON parser by sk0g on Sunday June 28, 2020 @11:07AM (#23669208)
There's a latency overhead to cgo calls that isn't really on the list of things to be optimised. Renders the language unusable for wrapping around OpenGL and the likes, in a (complex) gaming context.

See issues like this: https://github.com/golang/go/issues/19574