News for hackers. Stuff that matters.
Re:Go memory ballast: How I learnt to stop worrying and love... by brian-armstrong on Monday December 02, 2019 @12:16AM (#21679989)
So, isn't this a strong argument against Go? At the point that you need to start devising clever workarounds to stop bad behavior from your runtime, it's time to find a new language.
Re:Go memory ballast: How I learnt to stop worrying and love... by wrs on Monday December 02, 2019 @12:25AM (#21680034)
If you know of a language that has absolutely no unexpected behavior in its runtime under any workload, please let us know what it is!
Re:Go memory ballast: How I learnt to stop worrying and love... by Dylan16807 on Monday December 02, 2019 @03:21AM (#21680769)
The problem isn't the unexpected behavior, it's needing "clever workarounds" to fix it.

And they don't even have a workaround for the GC assist being way too aggressive, they're just sucking it up and letting the latency exist.

Re:Go memory ballast: How I learnt to stop worrying and love... by ummonk on Monday December 02, 2019 @01:04AM (#21680187)
Baremetal assembly
Re:Go memory ballast: How I learnt to stop worrying and love... by presumably on Monday December 02, 2019 @01:18AM (#21680235)
Re:Go memory ballast: How I learnt to stop worrying and love... by saagarjha on Monday December 02, 2019 @05:37AM (#21681329)
Bugs are unintentional and can (and are) fixed.
Re:Go memory ballast: How I learnt to stop worrying and love... by johncolanduoni on Monday December 02, 2019 @09:37AM (#21682639)
Yeah, the book on performance concerns for assembly on Intel CPUs is pretty brief, only a few hundred pages: https://software.intel.com/en-us/download/intel-64-and-ia-32...
Re:Go memory ballast: How I learnt to stop worrying and love... by BubRoss on Monday December 02, 2019 @12:40AM (#21680099)
Modern C++, since there is no 'runtime' (and don't say linked in functions are a 'runtime'). If you have an example of where you think this breaks down I'll be happy to come up with a solution.
Re:Go memory ballast: How I learnt to stop worrying and love... by jchw on Monday December 02, 2019 @12:55AM (#21680155)
So when you throw an exception in C++, and the stack is being unwound, it is not being unwound by your C++ runtime? And the C++ standard library, specified in the same standard as the language, that you have, that has code present at runtime, is not part of the runtime?

Someone should let Microsoft know they need to rename their “C++ Runtime Library” package.

Re:Go memory ballast: How I learnt to stop worrying and love... by Const-me on Monday December 02, 2019 @01:13AM (#21680218)
They all optional. Don't throw exceptions and they won't unwind. Standard library is optional, there're good alternatives like ATL and EASTL. Microsoft's package is optional, change a compiler switch and your binary will stop using or requiring that package.

However, manual memory management makes development more expensive. Especially if you don't crunch numbers but parse strings. C++ probably ain't a good replacement for Go. For the last decades people and whole industries have been migrating the other way, from C++ to higher level memory safe languages, initially Java and C# then others followed.

Re:Go memory ballast: How I learnt to stop worrying and love... by jchw on Monday December 02, 2019 @01:52AM (#21680395)
Sigh.

I avoided mentioning that the C++ runtime was optional because I was trying not to be pedantic and I assumed in context it would be understood that this was irrelevant. I think I should’ve just made my point earlier, but:

- This all started with someone mentioning that C++ doesn’t have ‘bad runtime behavior’ because it doesn’t have a runtime, but this is false. It has a runtime, or to be exact, a specification for one, and I think it is safe to say a vast, perhaps extreme, majority of C++ developers are using it.

- If you opt to not use the runtime, then your runtime behavior is dictated somewhere else, but runtime behaviors don’t go away. In freestanding, you may be your own runtime, but then your runtime behavior is defined by the machine you’re running on. You just get to choose what layer of abstraction you are sitting on.

- edit: And also, as a point I forgot to mention initially, I don’t really feel like freestanding C++ vs standard Go is an apples-to-apples comparison.

I think the point was that the C++ has less runtime behavior, since it doesn’t have a scheduler or garbage collector, but extrapolating that to no runtime is wrong even if the runtime is optional.

Re:Go memory ballast: How I learnt to stop worrying and love... by Const-me on Monday December 02, 2019 @02:08AM (#21680471)
As far as I understood the context, it was about language runtimes. Underneath all languages, there’re usually OS kernel, drivers and hardware. They all have non-trivial amount of unexpected behavior, especially under load. But these apply to code written in all languages, almost equally.

BTW, C++ does have a scheduler. Optional like the rest of the runtime, but it’s 1 line of code away in all modern compilers, that line starts with #pragma omp.

Re:Go memory ballast: How I learnt to stop worrying and love... by jchw on Monday December 02, 2019 @02:25AM (#21680541)
Yes, that seems about right. There’s always behavior at runtime, and your language shields it away from you to varying degrees. It is the same for all languages, which is exactly what I am trying to drive home.

However, even if you go to the extreme of not using any features that require runtime support, if you are using hosted C++, in practice you still have one bit of runtime: the entrypoint. Technically, an operating system could implement the bits that call main, but to the best of my knowledge none of them ever have. So every compiled binary from every hosted C++ implementation begins at the runtime library. (Admittedly, normally the C runtime library, since C++ doesn’t differ here, but that is just another layer deep of pedantics. In practice, everyone has a runtime.)

Nitpick: As far as I am aware OpenMP is not part of the language itself but an extension. But yeah, you could argue that is runtime scheduling in C++, I think.

Re:Go memory ballast: How I learnt to stop worrying and love... by saagarjha on Monday December 02, 2019 @05:41AM (#21681342)
If you don’t have static initalizers you should just be able to set your entrypoint to be main, no?
Re:Go memory ballast: How I learnt to stop worrying and love... by jchw on Monday December 02, 2019 @01:22PM (#21685141)
Not really, because the entrypoint of executables is OS dependent and may not resemble the “main” function signature. I actually don’t know what Linux dumps on the stack/registers before calling your entrypoint, though, to be honest.
Re:Go memory ballast: How I learnt to stop worrying and love... by saagarjha on Monday December 02, 2019 @01:42PM (#21685367)
On a freestanding environment, the signature of main doesn't have to be the standard "int main(int argc, char argv)". Oh, and on Linux the the arguments to main are put on the stack, which you can see is handled by _start: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86...
Re:Go memory ballast: How I learnt to stop worrying and love... by int_19h on Monday December 02, 2019 @03:15AM (#21680740)
This isn't about freestanding C++. There's very little in the C++ standard library that can cause exceptions. Off the top of my head, it's throwing new (which nobody relies on anyway because of Linux OOM behavior); stuff like vector::at() that you have to use explicitly; and iostreams that are so horrible in general that they're usually avoided altogether.
Re:Go memory ballast: How I learnt to stop worrying and love... by murderfs on Monday December 02, 2019 @07:21AM (#21681764)
There are tons of things that throw exceptions in the standard library with no alternative. std::bad_alloc can get thrown from half the standard library (and it's a lot less implausible than new throwing, because of address space exhaustion on 32-bit). Any constructor that takes input that can be invalid has to throw (e.g. giving a malformed regex to std::regex).

The really obnoxious ones are std::stoi, stol, etc. which were added in C++11 as a replacement for strtol and friends, but throw on overflow/invalid input instead of returning a result type or a bool with out parameter.

Re:Go memory ballast: How I learnt to stop worrying and love... by Gupie on Monday December 02, 2019 @05:29AM (#21681292)
There is heap defragmentation.
Re:Go memory ballast: How I learnt to stop worrying and love... by JulianMorrison on Monday December 02, 2019 @06:02AM (#21681438)
About all it implies about Go is that the language as an integrated system isn't yet fully polished. There is a corner case of strange behaviour due to aggressive GC when the absolute memory requirements of the program aren't large. It can be worked around by making them larger by a ballast allocation. This is not "time to find a new language", it's a small issue with a known fix and there's a proposal to repair it at source in the pipeline.
Re:Go memory ballast: How I learnt to stop worrying and love... by kitd on Monday December 02, 2019 @06:15AM (#21681486)
A weak argument, maybe. The algorithm the pacer used seems reasonable in 99% of cases. Here's a fairly extreme case where it didn't.

But further, it seems fairly easy to fix and indeed it looks like the Go team are doing just that.

Re:Go memory ballast: How I learnt to stop worrying and love... by acrispino on Monday December 02, 2019 @12:51AM (#21680139)
It's hacky but also simple to implement. Should the go gc improve to the point that it's unnecessary, it seems simple to remove as well. Wouldn't bother me much.
Re:Go memory ballast: How I learnt to stop worrying and love... by codegladiator on Monday December 02, 2019 @01:09AM (#21680204)
> Strong argument against Go

No

Weak argument against Go ?

No

Let me know which language was perfect

That there is a proposal to work this out and relevant people are working on this makes a strong argument for go IMO.

https://github.com/golang/go/issues/23044