News for hackers. Stuff that matters.
Re:Go’s march to low-latency GC by zamalek on Wednesday July 06, 2016 @11:44AM (#12043815)
> wouldn't something like C be better?

Jim is an intermediate-level coder, by and far the average guy that you are going to get. He writes his IRC server in C. It performs acceptably and can be scaled horizontally. There are a few threading bugs and exploits (buffer overflows etc.).

Sally is an advanced coder, it took a year of recruitment to find her. She also writes her server in C. It's blazingly fast. Virtually nobody else understands how it works. She's a human, so it's still littered with the same types of bugs that Jim's server has.

Jack is at the same level as Jim. He starts off in Go 1.4. While his server is nowhere as fast as Sally's, its much faster than Jim's. Race conditions and exploits tend toward zero. Everyone on the team can approach the code and maintain it.

Go 1.6 is installed on prod and suddenly Jack's server is now negligibly slower than Sally's. Jim notices this and has to spend a few weeks on his to catch it up. Sally is stuck debugging a race condition that occurs once a month. Jack is adding more emoticons, more features and decommissioning servers in the cluster.

Edit: IRC is a simple problem and that begets a simple solution. While C may be significantly simpler than C++, Go requires far less cognitive effort: it is actually simpler than C.

Re:Go’s march to low-latency GC by nitwit005 on Wednesday July 06, 2016 @06:55PM (#12046402)
"Simpler" obviously didn't happen here. They had to debug the garbage collector, which included looking at traces that went into the OS. They effectively debugged a Go and C mix.

I'm afraid the truth of these things is that if you try to squeeze maximum performance out of some of these more sophisticated languages, you have to be able to understand and debug the runtimes that come with them. Not that many people are up to that, which means the hurdle can be higher.

Re:Go’s march to low-latency GC by zamalek on Thursday July 07, 2016 @02:10PM (#12051092)
I'm not implying that C is objectively inferior. Quite the contrary: there are tools that suite a specific problem. Maybe Twitch did spend money tuning Go, maybe that was a waste. Point is: they go a free performance boost thanks to a language the prioritizes what you want to do instead of how you do it.

I'm a big believer in early performance optimization, premature if you will. Though, ultimately, what I can crack out in a day with C# is worth months of C. Iterate, even with languages. If, after profiling, you find that your expressive (as opposed to explicit) language is wanting it's time to iterate into a different language. Get something competent out of the door, spend more money on it only if you have to. Right now our socket library consumes less than 1% of the CPU (GC and all), until everything else catches up there is no benefit to getting any closer to the metal.

Re:Go’s march to low-latency GC by DanWaterworth on Wednesday July 06, 2016 @03:18PM (#12045211)
I find it hard to believe Sally is so advanced if she writes code that others have difficultly reading.

It shouldn't take a year to find someone who writes unmaintainable soup.

Re:Go’s march to low-latency GC by zamalek on Wednesday July 06, 2016 @03:35PM (#12045301)
If you had me on an IRC server that had to service the numbers that Twitch is talking about; I would use every single server coding practice I am aware of. Someone else comes along. Maybe his first refactor would be to remove the buffer pooling. Maybe he'd change a data structure specifically designed to prevent false sharing, cutting throughput.

Good code doesn't always mean approachable code, writing a decent socket server in C assumes a ton of advanced knowledge.

If Sally had to write, say, a C logging library it would be a masterpiece of simplicity. These days your code has an audience, and those audiences can vary quite greatly.

Re:Go’s march to low-latency GC by DanWaterworth on Wednesday July 06, 2016 @04:05PM (#12045502)
I consider myself an "advanced coder", whatever that means and so I know that an IRC server is likely to be IO bound. I also know to avoid C, especially multithreaded C. Not because I would be unable to write correct multithreaded C, but because I probably don't have to to solve the problem adequately.

My experience means I know to pick my battles.

Re:Go’s march to low-latency GC by zamalek on Thursday July 07, 2016 @01:59PM (#12051019)
Disclaimer: despite all my praises for Go, I don't actually use it for real problems. Would I like to use Go? Definitely! Is there a problem that I'm trying to solve that needs Go? Certainly not. In many cases I'd objectively pick Rust over Go, but when it comes to threading primitives, Go is somewhat unmatched.

> pick my battles

Exactly my point. A good coder will choose the tool that expresses the solution correctly. C is a very good choice, it always will be, there are sometimes better choices. Ultimately it seems as though we are in agreement; cheers!

Re:Go’s march to low-latency GC by DanWaterworth on Friday July 08, 2016 @03:27AM (#12054044)
Go's threading primitives are not unmatched. You can do the same in Rust [1], but the gold standard in my eyes is STM in Haskell which allows you to block on arbitrary conditions.

[1] https://doc.rust-lang.org/std/macro.select!.html#examples

Re:Go’s march to low-latency GC by rantanplan on Wednesday July 06, 2016 @05:52PM (#12046119)
OT: why is an IRC server I/O bound? That really piqued my interest.
Re:Go’s march to low-latency GC by Terribledactyl on Wednesday July 06, 2016 @06:58PM (#12046417)
I've never made an IRC server but I share a similar feel for I/O (Network) being the limiting factor. Have one user write a message and then you need to send out potentially hundreds of thousands of messages. (At twitch scale)

The actual CPU computation going on per event is minimal (process maybe a few kb of text), and if we're only dealing with text, probably not memory (capacity or throughput) bound and certainly not disk bound.

Re:Go’s march to low-latency GC by kctess5 on Wednesday July 06, 2016 @03:34PM (#12045298)
Correct, fast, and maintainable C code is a very tall order. Good luck finding ANYONE who can do that consistently for a reasonable paycheck.
Re:Go’s march to low-latency GC by vvanders on Wednesday July 06, 2016 @04:02PM (#12045479)
Huh, it's almost as if the foundation of all the devices we use on a daily basis are written in some language that apparently isn't possible to write correctly.
Re:Go’s march to low-latency GC by pshc on Wednesday July 06, 2016 @04:16PM (#12045590)
They are mostly reliable (though probably still full of security holes) despite C—made possible by the millions of person-hours thrown at the problem of maintaining large C codebases.

Back then, we had no choice. We can do better.

Re:Go’s march to low-latency GC by DanWaterworth on Wednesday July 06, 2016 @05:22PM (#12045979)
Essentially all but the most used code-paths with be bug riddled. This paper [1] on finding bugs in C compilers by fuzzing is an interesting case-study.

[1] http://lambda-the-ultimate.org/node/4241

Re:Go’s march to low-latency GC by astrange on Wednesday July 06, 2016 @04:24PM (#12045651)
Server programming isn't even that hard. You could do it in C all day. (Just have good sandboxing for when someone finds an exploit...)

Millions of people have been writing C for games, firmware, computer systems without Internet since the 80s on, and they didn't even get software updates. If your server crashes you get a coredump and you can update anytime you want.

Re:Go’s march to low-latency GC by ssalazar on Wednesday July 06, 2016 @04:50PM (#12045816)
s/isn't possible to write correctly/is difficult to write correctly cheaply in non-trivial applications/

and you pretty much have it. Building higher-level abstractions has historically been a good thing, unless your day job is punching in opcodes.

Re:Go’s march to low-latency GC by vvanders on Wednesday July 06, 2016 @04:56PM (#12045844)
I was more poking fun at the hyperbole that it's not possible to hire anyone who writes C at a reasonable rate.
Re:Go’s march to low-latency GC by DanWaterworth on Wednesday July 06, 2016 @04:15PM (#12045576)
That's basically true.
Re:Go’s march to low-latency GC by DanWaterworth on Wednesday July 06, 2016 @03:53PM (#12045414)
Apparently it didn't have to be C or blazing fast.
Re:Go’s march to low-latency GC by justicezyx on Wednesday July 06, 2016 @04:19PM (#12045613)
I think this is why 'advanced' is used of 'better'. :)
Re:Go’s march to low-latency GC by DanWaterworth on Wednesday July 06, 2016 @04:51PM (#12045823)
I think that's true, but I don't like that it's true. What does that say about programming as a profession? Yuck.