Skip to content

Add obj_need_obj_free_p - #99

Merged
peterzhu2118 merged 1 commit into
mainfrom
obj-free-candidate
Jul 30, 2026
Merged

Add obj_need_obj_free_p#99
peterzhu2118 merged 1 commit into
mainfrom
obj-free-candidate

Conversation

@peterzhu2118

Copy link
Copy Markdown
Member

We don't need to call obj_free on certain types of objects anymore including T_FLOAT, T_RATIONAL, T_COMPLEX, and T_OBJECT. It makes freeing those objects faster.

Benchmark:

i = 0
while i < 10_000_000
  Object.new
  i += 1
end

Before:

Time (mean ± σ):      1.435 s ±  0.013 s    [User: 1.706 s, System: 1.970 s]
Range (min … max):    1.418 s …  1.461 s    10 runs

After:

Time (mean ± σ):      1.230 s ±  0.027 s    [User: 1.335 s, System: 1.743 s]
Range (min … max):    1.206 s …  1.294 s    10 runs

We don't need to call obj_free on certain types of objects anymore including
T_FLOAT, T_RATIONAL, T_COMPLEX, and T_OBJECT. It makes freeing those objects
faster.

Benchmark:

    i = 0
    while i < 10_000_000
      Object.new
      i += 1
    end

Before:

    Time (mean ± σ):      1.435 s ±  0.013 s    [User: 1.706 s, System: 1.970 s]
    Range (min … max):    1.418 s …  1.461 s    10 runs

After:

    Time (mean ± σ):      1.230 s ±  0.027 s    [User: 1.335 s, System: 1.743 s]
    Range (min … max):    1.206 s …  1.294 s    10 runs
@peterzhu2118
peterzhu2118 merged commit aa89a5b into main Jul 30, 2026
22 checks passed
@peterzhu2118
peterzhu2118 deleted the obj-free-candidate branch July 30, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant