News for hackers. Stuff that matters.
Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by Thaxll on Tuesday August 24, 2021 @02:59PM (#28293321)
When you see how much effort it takes to C# and Java to optimize the runtime, there are a lot of people working on that. C# is fast but you see that it uses between 2 and 32 times the memory that Go needs.

Overall you can see how fast Go is, it has little optimization compare to C# and it's as fast. Compare this: https://benchmarksgame-team.pages.debian.net/benchmarksgame/... and overly complicated C# version: https://benchmarksgame-team.pages.debian.net/benchmarksgame/... ( avx, Intrinsics etc ... )

Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by JamesSwift on Tuesday August 24, 2021 @03:03PM (#28293366)
I definitely have run into this, even when using 'server mode' in asp.net core. I never was able to figure out why the C# version of my POC was using so much memory, but rewriting to golang ended up using a very predictable, minimal amount of memory in comparison.
Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by Mattish on Tuesday August 24, 2021 @03:33PM (#28293752)
Server mode is much less likely to incur GC. Were you causing enough memory usage to force your app to actually free memory?

It will intentionally use more memory for the sake of throughput, hence why this post has all .NET program flag for it, as it's a _speed_ benchmark primarily.

Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by JamesSwift on Wednesday August 25, 2021 @09:10AM (#28301202)
I cant say for certain, but I'm pretty sure I manually GC'ed as a test and it didn't seem to help. Its been a while and the C# ended up being a temporary approach until I saw how much less memory the golang version used.

They performed almost equivalently for RPS I believe.

Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by azth on Tuesday August 24, 2021 @03:07PM (#28293417)
My guess is that golang's GC is optimized for latency at the expense of throughput, limiting the max memory size.
Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by xh-dude on Tuesday August 24, 2021 @03:50PM (#28294018)
It is, and it’s not directly tunable … the opinion is ‘we’re IO-bound, not compute-bound’.

I spent a chunk of time recently (10s of hours) doing dumb C# vs Go benchmarks - files and networking, and nothing worth taking seriously - just, usually the part about being IO-bound was true. C# is really impressive and was just a little slower with the best async solutions I could come up with. The machinery for async has overhead, so do Go routines and channels … the first-pass, not very performant code was just a little faster and IMHO clearer with Go (but I’m much better with Go /shrug).

Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by merb on Tuesday August 24, 2021 @03:37PM (#28293816)
nah he just compares two different things. basically his golang hello world probably had basically nothing while his dotnet version used the "Microsoft.NET.Sdk.Web" which basically pulls the shared framework which will load a ton of stuff. BUT even after that the memory usage might be bigger. however does it really matter? I mean dotnet is not a big memory hog. it's pretty lightweight for what it is. compare it to java and the golang number would be insane.
Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by JamesSwift on Wednesday August 25, 2021 @09:07AM (#28301177)
I tried to do the most minimal, idiomatic design for both. I didn't save the C# code (I think it probably was just asp.net core and newtonsoft.json), but here is the go version [1].

It basically just loads a JSON file into memory then allows you to query the data with 2 API endpoints.

[1] - https://github.com/J-Swift/GamesDbMirror-go

Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by merb on Wednesday August 25, 2021 @06:03PM (#28307704)
well asp.net core is not really minimal or idomatic. it pulls a whole framework your code doesn't do a lot of things that asp.net core would do. sadly since nancyfx died there arent that many c# http framework that are as lightweight as the golang once. asp.net core is more like java spring btw. nowdays most c# http frameworks do call `<FrameworkReference Include="Microsoft.AspNetCore.App" />` which is really really big compared to just Microsoft.NETCore.App most often the defaut aspnetcore also configures a "secure" application (working cors, etc.)
Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by igouy on Tuesday August 24, 2021 @04:31PM (#28294604)
Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by joelfolksy on Tuesday August 24, 2021 @06:05PM (#28295570)
"( avx, Intrinsics, etc ... )"

I have to give you credit for trying to apply the Rule of Three to a single criticism.

Of course, I don't really understand how the fact that someone took the time to vectorize the C# submission is supposed to be a mark against C#...

Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by agumonkey on Tuesday August 24, 2021 @03:58PM (#28294119)
and afaik, .net has record types unlike the jvm (yet) which means java is even worse
Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by kaba0 on Tuesday August 24, 2021 @04:14PM (#28294364)
I think you mean structs (value types. Will be called primitive types in Java). Records are not too interesting from a performance pov (and java has them, and I think they actually predate c#’s), though java will likely be able to optimize serialization/deserialization of records better.
Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by ternaryoperator on Tuesday August 24, 2021 @04:45PM (#28294781)
Java recently added record types.
Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by agumonkey on Wednesday August 25, 2021 @01:43AM (#28298383)
did it land in a release ? i thought it was still at review proposal
Re:Golang vs. C# (.NET 5.0) at Benchmarks Game by scns on Wednesday August 25, 2021 @04:29PM (#28306504)
In openjdk 16 IIRC.