Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NaN boxing #55

Merged
merged 6 commits into from
Mar 30, 2022
Merged

NaN boxing #55

merged 6 commits into from
Mar 30, 2022

Conversation

liquidev
Copy link
Member

Features some optimizations that make values more compact.

A big bottleneck right now is the amount of destructors that kill branch prediction. I did some optimizations in places where the type of the value is known (namely, number operations) and std::mem::forget is called there to not run destructors when we know that the type of a value does not need any special work.

Here's a comparison between having a impl Drop for ValueImpl and not having it:

> hyperfine --warmup 5 'target/release/mica code/functions.mi' 'target/release/mica-nodestructors code/functions.mi'
Benchmark 1: target/release/mica code/functions.mi
  Time (mean ± σ):     344.4 ms ±   5.1 ms    [User: 342.1 ms, System: 1.9 ms]
  Range (min … max):   338.4 ms … 356.3 ms    10 runs
 
Benchmark 2: target/release/mica-nodestructors code/functions.mi
  Time (mean ± σ):     288.2 ms ±   1.5 ms    [User: 286.8 ms, System: 1.4 ms]
  Range (min … max):   286.6 ms … 291.2 ms    10 runs
 
Summary
  'target/release/mica-nodestructors code/functions.mi' ran
    1.20 ± 0.02 times faster than 'target/release/mica code/functions.mi'

Of course the faster version does not clean up any memory, which is bad.
With that I conclude that Mica needs garbage collection for improved performance.

@liquidev liquidev merged commit 1670f11 into master Mar 30, 2022
@liquidev liquidev mentioned this pull request Mar 30, 2022
@liquidev liquidev deleted the nan-boxing branch January 29, 2023 19:12
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.

None yet

1 participant