5 ms·
GC was probably not a concern in 2009, but these days GC pauses will kill any moderately high throughput app. The stackoverflow blog has lots of content dedicat
by daxfohl 6y ago
GC was probably not a concern in 2009, but these days GC pauses will kill any moderately high throughput app. The stackoverflow blog has lots of content dedicated to the lengths they go to avoid them in C#, such that the resulting C# code doesn't look like idiomatic C# at all.
In F# that would be an even bigger challenge. You could do it, but it would but way ugly. F# is my go-to language for side projects, but for anything server-side that I'm getting paid to work on, I'd be reluctant to suggest F# as a starting point, as much as I'd like to.
- Quarrelsome 6y agoWhile GC can be a factor to work around its also a religious issue (e.g. when C++ devs transition to C# they often fight it as a subjectively perceived foe) which always make it suspicious to put to the top especially in contrast to 2009. What's the difference there? You've still got a server that you're thrashing in both cases. Did something significant change in the GC implementations between 2009 and today that makes it _less_ suitable to use as a backend server?
- motives 6y agoUnless you're working on a SOTA HFT application where you're optimising your latency by the nanosecond, I can't see modern .Net/F#/C# being a problem in production. Given that Bing[1] and Azure Active Directory[2] run on .Net Core/.Net 5, which are among the most used applications on the entire internet, the idea that a medium-large project cant use them is ridiculous. This isn't even just with modern .Net aswell, Microsoft Trill has been running trillions of operations a day on single machines since 2012 as a .Net library [3]. [1] - https://www.bing.com/version https://www.bing.com/version [2] - https://devblogs.microsoft.com/dotnet/azure-active-directorys-gateway-service-is-on-net-core-3-1/ https://devblogs.microsoft.com/dotnet/azure-active-directory... [3] - https://www.microsoft.com/en-us/research/project/trill/ https://www.microsoft.com/en-us/research/project/trill/
- daxfohl 6y agoI used to work in the Azure Resource Manager team and we had big GC issues there. API servers would pause for 200 ms and queues would explode. Workers would grind to a near halt in certain conditions due to GC overload. Granted this was a couple years ago and running dotnet framework, so perhaps things have improved. I think it's likely most of the serious problems there could have been fixed by smarter in memory caching: a few big objects instead of millions of small ones. However the whole experience left a sour taste in my mouth for overly allocation-happy code styles.
- phillipcarter 6y agoDo you think that a lot of what you experienced was before widespread use of the Span primitive in the .NET libraries and frameworks? Even if you go to great lengths to avoid GC pauses in your own code, the components you depend on may not have done that and then you're toast. Much has changed in the past 1.5-2 years to eliminate almost all unnecessary allocations across the stack. C# and F# also got compile-time analysis for working with spans, span-like, byrefs, etc. as of 2018 so that you can write some of this code yourself and have a reasonable assurance the the compiler will keep your code from allocating. Coding like this isn't easy either, but it's far simpler than it used to be because of the underlying types an compiler analysis that can help you.
- daxfohl 6y agoOh, absolutely. In fact I proposed an effort and wrote up a few prototypes to bring those things into ARM codebase while I was there. IDK if any of it ever went anywhere though, as I left the team shortly thereafter.
- motives 6y ago"Granted this was a couple years ago and running dotnet framework, so perhaps things have improved" - I think this explains the differences in our opinions on .Net, as I'm from the opposite side of the spectrum having only worked on .Net Core on Linux. From other discussions I've had with people who used older versions of .Net, they seem to share your opinion that it was nowhere near as pleasant of an experience as something like .Net 5. As the other comment mentions, Span<T> has really permeated through core libraries, and the effect is much smoother, more predictable performance, with low memory usage making container based development a breeze.
- gameswithgo 6y agoF# is designed so that the performance ceiling is the same as C#. Certainly you would get less idiomatic to reduce GC pressure, but I'm not sure its harder than c#
- Smaug123 6y agoI dunno, there are some weird places where idiomatic F# allocates even when you avoid the usual suspects, but can be trivially rewritten not to allocate. (There are even bugs which cause allocation. Try iterating over an array of `unit -> unit`, calling each in turn.)