nibi-lang / nibi

An interpreted list processing language inspired by Lisp
GNU Affero General Public License v3.0
3 stars 2 forks source link

GC - Remote reference count #102

Closed bosley closed 1 year ago

bosley commented 1 year ago

It may not play out well, but I had an idea for a garbage collection scheme I want to try.

This is really just an abstracted reference counter, but what it would buy the cell_c type is the following:

This would ensure we continue to have 0 memory leaks while reducing the overall size of the cell by an estimated 16 bytes.

bosley commented 1 year ago

So I ran this on bosleylab (much slower than everything on the planet) and I got this differential in speed:

BEFORE:

test time (s) time (ms)
mandelbrot.nibi 0.1383s 138.3382ms
primality.nibi 1.2408s 1240.7899ms
4sieve.nibi 1.306s 1306.0257ms
leibniz.nibi 0.1469s 146.8661ms

AFTORE:

test time (s) time (ms)
mandelbrot.nibi 0.8463s 846.293ms
primality.nibi 8.0331s 8033.0782ms
4sieve.nibi 13.4166s 13416.5957ms
leibniz.nibi 0.9215s 921.5019ms

The performance hit was due to the fact that we introduced new hops for every copy and delete. The remote GC thing I figured would be slower, but not THIS much slower.

The performance hit was not worth the 4-bytes saving on cell_c