lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Tue, Apr 16, 2019 at 5:20 AM Jim <> wrote:
On 4/14/19, Sean Conner <> wrote:
> What's wrong with __gc ?

please read

Many of the points in that article are still valid, but mobile platforms are no longer as resource constrained as they were in 2013, and a well-designed GC may be faster than a reference counting implementation, especially one in a multithreaded environment. 

A thread safe reference counting implementations is not cheap:
C++ std:shared_ptr<> reference counting for instance introduces lots of overhead because the reference count is adjusted using thread safe (atomic) operations, and those operations are slow. I managed to double the speed of a single threaded program by writing a shared_ptr variant that was not thread safe (and yes, I used move construction and move assignment wherever feasible to avoid reference count adjustments).

When I added thread safety back into my implementation it became just as slow as std::shared_ptr<>.