HNHacker News
TopNewBestAskShowJobs

algorithmsRcool

1,521 karma · joined May 25, 2012

https://github.com/AlgorithmsAreCool
submissionscomments
algorithmsRcool··on A sub-millisecond GC for .NET?
Definetly interested to hear your results. The synthetics suggest that it is just winning in everything except raw allocation performance, but unless you're allocating millions of objects per second then that shouldn't matter.
algorithmsRcool··on Pauseless Garbage Collector
This is a github discussion about an experimental Garbage Collector for .NET that dramatically reduces pause durations, total pause time without significantly damaging throughput

The new GC is introduced in this comment:

https://github.com/dotnet/runtime/issues/96213#issuecomment-...

algorithmsRcool··on New atomic fountain clock joins group that keeps the world on time
I recall reading that our ability to measure time accurately exceeds that of any other quantity. According to the NIST, the newest Optical Lattice clocks would drift by less than 1 second if they were started 13 billion years ago at the big bang. What else can we measure down past 1 part per 10e18?
algorithmsRcool··on New atomic fountain clock joins group that keeps the world on time
The Naval Observatory in Washington DC has quite a few also
algorithmsRcool··on Observability 2.0 and the Database for It
Well, I could just enrich the trace/event with sample data from CPU, RAM, Disk I/O, etc...
algorithmsRcool··on Observability 2.0 and the Database for It
> Most sysadmins at this point would just configure a new filtered metric and start collecting data… for a month. While the system is broken. Wrong needle? Start looking through the haystack again with another new custom metric for another month.

In this example i feel like it is treating metrics as the only telemetry signal that operators have access to. Once the metrics indicate an issue, we can pull existing logs, traces and profiles to dig into it and eventually capture dumps.

I'm totally onboard with the idea of rich trace metadata, but it seems more evolutionary than revolutionary

algorithmsRcool··on Observability 2.0 and the Database for It
If I understand correctly the "big idea" here is:

1. Juice up your Traces with every attribute possible 2. Use a telemetry backend that relies on cheap object storage so that your costs don't explode. 3. ...profit?

Ok, but now we are exporting and storing everything about every request just so we can derive some previously cheap metrics like server CPU consumption? I guess for most applications the overhead of buffering, formatting and sending all of this telemetry data doesn't matter for folks?

algorithmsRcool··on A 10x Faster TypeScript
I am actually shocked that Anders chose Go over C# for this port.
algorithmsRcool··on Writing a .NET Garbage Collector in C# – Part 1
I didn't realize that the GC copied the surviving objects to a separate location. Come to think of it, i don't actually know how the GC keeps track of what object lies in what generation.
algorithmsRcool··on WASM will replace containers
Yes, but now you are going through another translation (aka V8) layer in order to get down to x86 or ARM. You just have to hope that the optimizer of this translation layer is at least as smart as what you had before.
algorithmsRcool··on WASM will replace containers
I just don't see it. WASM requires throwing away all the decades of x86/ARM compiler work in ecosystems like Java, .NET and C++ and placing all trust in the WASM runtime/V8 to perform as well as them.
algorithmsRcool··on Property-Based Testing for the People
Just going to plug the excellent .NET PBT library, CsCheck [0]. I have used it quite a bit to excersize strange corners of my program logic and found several exotic bugs with it.

[0]: https://github.com/AnthonyLloyd/CsCheck

algorithmsRcool··on Researchers design wearable tech that can sense glucose levels more accurately
I'm happy at the prospect of more accurate readings. But honestly, the Libre 3 is already simply excellent and I would personally prefer the back of the arm location to more wrist based tech. I wear a traditional (Citizen) mechanical watch, because I hated needing to charge a smartwatch.

I had some issues with the Libre 2 sensor getting knocked off or loosening after a few days in the shower. But the libre 3 is smaller than a US quarter coin and lasts 15 days and doesn't snag on anything. Will this watch exceed that? Because if not, then I'm not looking to switch.

Lastly for diabetics or pre-diabetics that are only using finger sticks, I CANNOT stress enough how important a CGM is to your health. You learn so much about how your body actually works with certian foods rather than low frequency (but somewhat more accurate) finger sticks and that information dropped my A1C like a rock in just a few months. Tell your older relatives also. These are life saving devices.

algorithmsRcool··on Types are a basic tool of software design (2018)
I go a little back and forth on this with my experience in F#, which relies heavily on inferred types. You can write a lot of F# before you need to add type annotations, but eventually, things become a spiderweb. The key issue is when you make a 'small' change to some method/value, the changes ripple through the program creating confusing errors sometimes where the compiler is trying to knit things together.

After a while, I found myself adding back types in a decent number of places to "anchor" the type inference, indicating that a certain type/signature is fixed and a change should be carefully considered.

I still don't know how folks deal with these kinds of changes in weakly typed languages without always allowing bugs to pour into their code over time. But I do love the "move fast" and low boiler-plate aspects of "typeless" coding.

algorithmsRcool··on How Distributed Systems Avoid Race Conditions Using Pessimistic Locking?
This article undermines itself a bit by introducing an optimistic concurrency primitive that it calls "fence tokens", aka content hashes, data versions or etags which are all the same concept.

Distributed locking, like all pessimistic concurrency, has a place but it comes with serious scaling concerns depending on how granular the scope of the locks are. Lock lived locks suffer from blocking other writers from large chunks of time, destroying latency. Very fine-grained locks eventually become dominated by networking overhead since the lock requires two to three trips to the database for each logical write/update.

Conversely, optimistic concurrency under high contention can lead to excessive waste from clients needing to retry operations because of conflicts.

The only way to win is reduce the scope of your writes/updates to avoid the contention as much as possible.

algorithmsRcool··on Hyrum's Law in Golang
Another related effect of this is Protocol Ossification [0] which happens when implementers of a public API/Protocol surface area take implicit dependencies on common but not standardized behaviors of the API/Protocol implementation.

That being said, you can take proactive steps to defeat this. For example, the default Hash for strings in .NET is randomly seeded each time a process starts[1] in order to strongly dissuade folks from taking an implicit dependency on the underlying algorithm which is not guaranteed to be stable

[0] : https://en.wikipedia.org/wiki/Protocol_ossification

[1] : https://andrewlock.net/why-is-string-gethashcode-different-e...

algorithmsRcool··on What's New in F# 9
The F# team has done a great job of building compatibility bridges back to the C# way of doing things so the actual impact isn't bad.
algorithmsRcool··on What's New in F# 9
F# has chosen this approach of implementing compatibility with newer C# features such as support for ValueTuple<T> and Span<T>. It has been pretty successful at keeping F# inside the compatibility story.

---EDIT---

Mean to post this under the GP

algorithmsRcool··on What's New in F# 9
F# is full supported on Windows, MacOS and Linux via CoreCLR and several more platforms via Mono, just like C# is
algorithmsRcool··on What's New in F# 9
C# these days is GREAT, but F# still has features that C# doesn't like unions and much more powerful (and ergonomic) pattern matching.

And line for line, F# is more effective at getting things done (and i would argue with less bugs)

algorithmsRcool··on What's New in F# 9
F# has been my favorite language since I first encountered it in uni. F# was/is waaaay out ahead of C# with features like unions, null safety, pattern matching, records, more powerful type inference and generic constraints.

Over the years C# has been implementing these features too, which is good, but they have been implementing them in incompatible ways, which isn't very good. Since the investment in F# has been much smaller than in C#, it hasn't been innovating as fast as C# and has been left behind in some ways.

But it is still a great language and remains broadly compatible with the ecosystem and can deliver equal performance to C# with far less boiler plate

algorithmsRcool··on Next Generation Out of Band Garbage Collection
How much of a throughput penalty do those options incur on the application?
algorithmsRcool··on A comparison of Rust’s borrow checker to the one in C#
It isn't trivial but it is supported. Here is an example [0] toy.

I am not aware of any production grade replacement GCs for .NET out there currently

https://github.com/kkokosa/UpsilonGC

algorithmsRcool··on A comparison of Rust’s borrow checker to the one in C#
There is very little new under the sun. It reminds me of the wheel of time books, as the wheel turns we forget about the learnings of the previous age and reinvent them for ourselves. Often worse.
algorithmsRcool··on A comparison of Rust’s borrow checker to the one in C#
> As for a delete operator, you can just roll your own struct based allocation framework that uses IDisposable to reclaim memory. But then you need to deal with all the traditional bugs like use-after-free and double-free and the like.

I forgot that there is built in support for this model using the MemoryManager<T> class [0]. A memory manager is an abstract class that represents a block of other memory, including possibly unmanaged memory. It implements IDisposable already so you can just plug into this.

The Memory<T> struct can optionally internally point to a MemoryManager instance allowing you to plug your perfered style of allocation and freeing of memory into parts of the framework.

There is a little irony that a MemoryManager<T> is itself a class and therefore managed on the gc-heap, but you can defeat this by using ObjectPool<T> to recycle those instances to keep allocation count steady state and not trigger the GC.

I have used this before (in the toy database i mentioned earlier) to allocate aligned blocks of unmanaged memory.

[0] https://learn.microsoft.com/en-us/dotnet/api/system.buffers....

algorithmsRcool··on A comparison of Rust’s borrow checker to the one in C#
Ref-structs can also implement interfaces now too. The C# compiler team has been really delivering in this space the last few iterations
algorithmsRcool··on A comparison of Rust’s borrow checker to the one in C#
Yes, this is what I meant
algorithmsRcool··on A comparison of Rust’s borrow checker to the one in C#
> Because Anders Hejlsberg is one of the greatest language architects and the C# team are continuing that tradition.

I wish Anders was still in charge of C# :(

algorithmsRcool··on A comparison of Rust’s borrow checker to the one in C#
>Anything that uses classes and interfaces will be memory managed by the GC...

Yes and no. Yes, almost all of the standard library collection are allocation heavy and it is still the dominate pattern in C#, so if you want to avoid the GC you need to avoid these and resort to building your own primitives based on Memory/Span. Which sucks.

However, you can use interfaces in a no GC world since you can constrain those interfaces to be structs or ref-structs and the compiler will enforce rules that prevent them from being boxed onto the GC heap.

Also of recent note, the JIT can now automagically convert simple gc-heap allocations into stack allocations if it can trivially prove they don't escape the stack context.

> It would be better if the GC can be turned off with a switch and just add a delete operator to manually free memory.

It is a little know fact that you can actually swap out the GC of the runtime. So you could plug in a null implementation that never collects (at your own peril...)

As for a delete operator, you can just roll your own struct based allocation framework that uses IDisposable to reclaim memory. But then you need to deal with all the traditional bugs like use-after-free and double-free and the like.

For me, I think low-gc is the happy medium. Avoid the heap in 99% of cases but let the GC keep things air tight

algorithmsRcool··on A comparison of Rust’s borrow checker to the one in C#
Span and ref-like types enable massive changes to the way that memory is managed in C#. You can absolutely write almost GC-less code. I have been tinkering with a toy no-GC database engine in C# based on Direct I/O and some object pooling. I have been amazed at how far i can get before resorting to GC heap allocations
← PreviousPage 2 of 9Next →