Better HN
topnewbestaskshowjobs
Log inSign up

pebal

24 karma · joined May 27, 2022 (4y ago) · 138 submissions

Submissions

comment 3w ago · link · parent

Provide the GC name.

comment 3w ago · link · parent

Every GC in Java involves synchronization points and the pausing of application threads.

comment 3w ago · link · parent

It’s great that they were created for this purpose, but I have a faster allocator in non-moving GC engine in C++. And I don't have to moving gigabytes of data.

comment 3w ago · link · parent

A moving GC does not provide the fastest allocation. This is one of the myths in the Java world.

comment 1mo ago · link · parent

ZGC is not pause-free. The only pause-free GC that exists is SGCL for the C++.

comment 1mo ago · link · parent

Rust could just as well have an optional tracing GC for shared ownership instead of ARC, potentially improving performance rather than reducing it. Having a GC doesn't inherently make a language slower.

comment 1mo ago · link · parent

I’m not saying it doesn't work. I’m saying it’s a waste of resources and won’t gain widespread popularity. The current trend is porting source code to languages that generate native code.

comment 1mo ago · link · parent

It depends on the workload. ARC can be more expensive than tracing GC, especially with heavily shared objects.

But my main point was that the presence of a GC has nothing to do with how close a language is to the metal. Memory management strategy and low-level capabilities are two separate things.

comment 1mo ago · link · parent

An absurd amount. The cost wouldn't exceed $500 under a subscription model.

comment 1mo ago · link · parent

There is no connection. Rust has ARC which performs worse than the tracing GC.

comment 1mo ago · link · parent

Because that is precisely the trade-off we're discussing.

With immediate reference-counted reclamation, dropping the last reference can put an arbitrarily large amount of destruction and deallocation work on the current thread. If you defer that reclamation to get it off the critical path, you have introduced a collector that reclaims unreachable objects later.

Whether that collector discovers garbage by tracing or receives zero-reference objects from reference counting is an implementation detail. In both cases, memory reclamation is automatic and deferred.

So the supposed distinction "with ARC I know when I pay the reclamation cost, with GC I don't" only holds if you're willing to pay an unbounded reclamation cost synchronously when the last reference is dropped.

comment 1mo ago · link · parent

What exactly don't you understand?

comment 1mo ago · link · parent

Manual management involves an explicit function call. Functions called by a destructor are considered automatic.

comment 1mo ago · link · parent

Yes, I can, e.g. by implementing deferred deallocation, which is a primitive GC form.

> actually, you don't know

I know because I’ve verified it.

comment 1mo ago · link · parent

You might lose 100 ns or 300 ms. When? Nobody knows. You lose nothing when going out of scope with GC.

comment 1mo ago · link · parent

It is also unknown how much work will be performed if ARC goes out of scope.

comment 1mo ago · link · parent

Because some people are allergic to the word GC and pretend that a duck isn't a bird.

comment 1mo ago · link · parent

That "good collector" has higher memory usage, has to pause mutator threads, and makes application code run slower. Thanks, but no thanks.

comment 1mo ago · link · parent

It is better to scan everything than to copy it.

comment 1mo ago · link · parent

You've described where deallocation can happen, not when it will. Every block exit is a candidate, but which one drops the last reference depends on runtime state: how many other owners the object has and which of them goes away first. With shared ownership across threads it's a race by construction. The free runs on whichever thread happens to release last.

The cost isn't bounded either. Dropping the last reference to the head of a list or the root of a tree frees the whole structure at that block exit, and its size is a runtime property.

And it isn't only block exits. Every assignment to a variable or field holding a reference decrements the old target, and so does removing an element from a container. Swift's ARC doesn't even promise the scope boundary: the optimizer may release right after the last use, which is why withExtendedLifetime exists.

By the same "where" criterion a non-concurrent tracing GC is predictable too, because it can only run at allocation points. That doesn't tell you which allocation will trigger it, just as knowing the block exits doesn't tell you which one will free.

comment 1mo ago · link · parent

> The problem with GC in the strict sense is that you cannot predict when it will happen.

It’s the same with ARC. You also don’t know when the counter will reach zero.

comment 1mo ago · link · parent

The inefficient combination of reference counting and a tracing garbage collector found in Python should be discarded in favor of a fully pause-free, concurrent GC.

comment 2mo ago · link · parent

The standard provided no GC support. What was there was completely useless.

comment 2mo ago · link · parent

On your third point (compilers and Boehm): agreed on both counts. The C++11 "garbage collection support" (declare_reachable and friends) never got an implementation and C++23 removed it, so a collector for C++ has to live without the compiler - and Boehm, being conservative on the heap and stop-the-world, is what most people think that has to mean.

It doesn't. I've been building one as a plain header-only library (SGCL, https://github.com/pebal/sgcl - my project): the heap is traced precisely through per-type pointer maps the collector builds at runtime by elimination (a word ever seen holding a non-heap value is data, for good), marking and sweeping run concurrently with the mutators and in parallel over helper threads, cycles are generational, and nothing is ever moved. What it can't do without the compiler is the stacks, which it scans conservatively, like Go before 1.4.

On the "abstract model" point: you're right that it isn't 100% faithful either. The collector reads words of objects while other threads write them, relies on word-sized stores being what every real platform makes them, and reads stacks it does not own. The rules the program has to keep are few (a tracked pointer lives on a stack or in a managed object, never shares storage with data, destructors don't touch peers) and debug builds check them, but it is engineering on top of the platforms, not the standard.

12345