Skip to content

Conversation

@hmistry
Copy link
Contributor

@hmistry hmistry commented Dec 30, 2022

Adds benchmarks for Sequel with no plugins and with as many plugins as applicable. Would like to track JIT performance for the Module plugin architecture used in Sequel and Roda where base methods are overridden in plugins. Having both benchmarks allows us to see any impacts due to plugins.

Please advise how you'd like me to setup the 2 different benchmarks - base Sequel and Sequel + plugins. Do you prefer separate folders or 2 files is ok?

@hmistry
Copy link
Contributor Author

hmistry commented Dec 30, 2022

CLA signed. Need help rerunning CI 🙏

@noahgibbs
Copy link
Contributor

Currently there's no easy way to return two different measurements from a single benchmark, so "sequel no plugins" and "sequel with plugins" would need to be two different benchmarks.

@noahgibbs
Copy link
Contributor

It would be possible to keep your current setup, which gives the "sequel" benchmark, and then add a file called something like "benchmarks/sequel_with_plugins.rb" that changes into the sequel directory before use_gemfile. Basically, make one of them a single-file benchmark while the other is a directory benchmark, but otherwise keep basically the same setup.

@maximecb often has opinions on how many similar benchmarks we want, though, and may or may not be up for two different Sequel benchmarks.

I believe she's away for the holidays, maybe until 5th Jan? So our side may take a bit to reply back here.

With that said, this code looks fine on quick inspection, and I think a Sequel benchmark is a good idea in general.

@hmistry
Copy link
Contributor Author

hmistry commented Jan 4, 2023

@noahgibbs Thanks for the quick review. I made the recommended changes. If @maximecb feels there's no value to having 2 different sequel benchmarks, it's fine with me - happy to change as required. My main goal is to ensure the Module plugin architecture also benefits from YJIT optimizations.

@maximecb
Copy link
Contributor

maximecb commented Jan 5, 2023

Hi there. Thanks for putting this together @hmistry. Database access is something we don't really have in our benchmarks and so it seems like a good idea to benchmark it.

I think I would prefer to have just one benchmark for this package. What do you think is the most realistic/typical use case for this gem? Do people usually have many plugins?

@hmistry
Copy link
Contributor Author

hmistry commented Jan 6, 2023

Hi @maximecb. Ok, I'll make this a single benchmark after knowing whether you prefer to be consistent with ActiveRecord benchmark or have a realistic case.

Regarding plugins, yes, a typical application will use several plugins but not all. I'm not sure if you're familiar with this plugin architecture but it's a very minimal vanilla core and then all the functionality is composed using plugins that override the core methods. That way you have the best of both worlds - performance and just the right functionality with nothing extra.

@noahgibbs
Copy link
Contributor

Database access is something we don't really have in our benchmarks and so it seems like a good idea to benchmark it.

Sequel is probably best thought of as an ActiveRecord competitor, which is presumably why he followed the structure of that benchmark. There are significant differences, but overall it's used for very similar things.

@maximecb
Copy link
Contributor

maximecb commented Jan 6, 2023

Hi @maximecb. Ok, I'll make this a single benchmark after knowing whether you prefer to be consistent with ActiveRecord benchmark or have a realistic case.

Regarding plugins, yes, a typical application will use several plugins but not all. I'm not sure if you're familiar with this plugin architecture but it's a very minimal vanilla core and then all the functionality is composed using plugins that override the core methods. That way you have the best of both worlds - performance and just the right functionality with nothing extra.

Can you make a judgment call as to which plugins are very commonly used and only include those? 😅

@hmistry
Copy link
Contributor Author

hmistry commented Jan 8, 2023

Can you make a judgment call as to which plugins are very commonly used and only include those? 😅

Yes absolutely. I changed to only use a common set of plugins. Hope that'll be enough to determine any YJIT performance optimizations for a chain of method overrides used by the plugin architecture.

Also reduced it to one benchmark per your request. Thank you all for your feedback, please review the changes.

@hmistry hmistry changed the title Add benchmarks for Sequel +/- plugins Add benchmarks for Sequel with common plugins Jan 8, 2023
@maximecb
Copy link
Contributor

maximecb commented Jan 8, 2023

LGTM. Will give @noahgibbs a chance to comment on Monday as well 👍

@noahgibbs
Copy link
Contributor

LGTM too!

@maximecb
Copy link
Contributor

maximecb commented Jan 9, 2023

There's just one last detail missing, which is that we should add this benchmark to the list, in the headline category:
https://github.com/Shopify/yjit-bench/blob/main/benchmarks.yml

@hmistry
Copy link
Contributor Author

hmistry commented Jan 9, 2023

There's just one last detail missing, which is that we should add this benchmark to the list, in the headline category:
https://github.com/Shopify/yjit-bench/blob/main/benchmarks.yml

Done 🙂

@maximecb maximecb merged commit 7f52737 into ruby:main Jan 9, 2023
@maximecb
Copy link
Contributor

maximecb commented Jan 9, 2023

Well done @hmistry, and thanks for your patience in getting this merged 🙏 :)

@hmistry
Copy link
Contributor Author

hmistry commented Jan 9, 2023

@maximecb You're welcome! I've been following your work along with MJIT and MIR. I really look forward to seeing YJIT bring significant performance increases to Ruby. Thank you for leading YJIT development! 🙏


run_benchmark(10) do
1.upto(1000) do |i|
post = Post.where(id: i).first
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this is actually an inefficient way to query a record in Sequel, Post[i] or Post.first(id: i) are much faster: #207

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.

4 participants