Project

General

Profile

« Previous | Next » 

Revision e15b454b

Added by peterzhu2118 (Peter Zhu) 9 months ago

Simplify how finalizers are ran at shutdown

We don't need to build a linked list from the finalizer table and
instead we can just run the finalizers by iterating the ST table.

This also improves the performance at shutdown, for example:

1_000_000.times.map do
  o = Object.new
  ObjectSpace.define_finalizer(o, proc { })
  o
end

Before:

Time (mean ± σ):      1.722 s ±  0.056 s    [User: 1.597 s, System: 0.113 s]
Range (min … max):    1.676 s …  1.863 s    10 runs

After:

Time (mean ± σ):      1.538 s ±  0.025 s    [User: 1.437 s, System: 0.093 s]
Range (min … max):    1.510 s …  1.586 s    10 runs