-
Notifications
You must be signed in to change notification settings - Fork 16
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
Speed up Func#call
by optimizing arg buffer initialization
#169
Comments
After: ``` $ rake compile:release && rake bench:host_call [...] Calculating ------------------------------------- Call host func (4 args) 519.910k (± 1.3%) i/s - 2.608M in 5.016526s Call host func (16 args) 440.924k (± 0.6%) i/s - 2.243M in 5.086693s Call host func (64 args) 277.404k (± 1.2%) i/s - 1.412M in 5.089372s Call host func (128 args) 144.274k (± 0.7%) i/s - 734.910k in 5.094121s Call host func (256 args) 55.141k (± 1.1%) i/s - 279.990k in 5.078321s ```
After: ``` $ rake compile:release && rake bench:host_call [...] Calculating ------------------------------------- Call host func (4 args) 519.910k (± 1.3%) i/s - 2.608M in 5.016526s Call host func (16 args) 440.924k (± 0.6%) i/s - 2.243M in 5.086693s Call host func (64 args) 277.404k (± 1.2%) i/s - 1.412M in 5.089372s Call host func (128 args) 144.274k (± 0.7%) i/s - 734.910k in 5.094121s Call host func (256 args) 55.141k (± 1.1%) i/s - 279.990k in 5.078321s ```
After: ``` $ rake compile:release && rake bench:host_call [...] Calculating ------------------------------------- Call host func (4 args) 519.910k (± 1.3%) i/s - 2.608M in 5.016526s Call host func (16 args) 440.924k (± 0.6%) i/s - 2.243M in 5.086693s Call host func (64 args) 277.404k (± 1.2%) i/s - 1.412M in 5.089372s Call host func (128 args) 144.274k (± 0.7%) i/s - 734.910k in 5.094121s Call host func (256 args) 55.141k (± 1.1%) i/s - 279.990k in 5.078321s ```
I tried 2 different approaches to this with similar performance (the commits have bench result):
After comparing them, I realized they both suffer from an issue though: converting a I guess we could use the Store to temporarily save Thoughts? |
I've updated Magnus so the So the results
.into_iter()
.map(|result| result.to_ruby_value(store))
.collect::<Result<RArray, _>>()
.map(|ary| ary.as_value()) I don't think I see a benchmark for this in |
I was experimenting when making
Func#call
faster, and noticed there is a decent performance win by avoidingrb_ary_push
. It requires a bit of unsafe code, but I believe the implemntation is sound:The text was updated successfully, but these errors were encountered: