-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make clients autoload #1351
Make clients autoload #1351
Conversation
@gmcgibbon What are you using to visualize the load time there? |
@tas50 I'm using stackprof to measure and speedscope to visualize! |
@@ -2,7 +2,6 @@ | |||
require 'octokit/warnable' | |||
require 'octokit/arguments' | |||
require 'octokit/repo_arguments' | |||
require 'octokit/configurable' | |||
require 'octokit/authentication' | |||
require 'octokit/gist' | |||
require 'octokit/rate_limit' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move these to autoloads in the Octokit
module as well in case they are referenced before Client
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right... it depends on the API of the gem. It looks like they are all public API and you expect these modules to be pluggable by other client types.
I'll take a look at the modules that aren't under Client
and see if it makes sense to autoload them. If they are trivial enough, we could consider just moving the require.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to autoload all constants nested in Octokit
besides Configurable
(because that's used immediately in the main module). It should be roughly the same performance diff that way.
59c0ea9
to
fa32180
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me!
@tarebyte this should be ready whenever you have a moment to review. 🙏 |
fa32180
to
35a4ea6
Compare
Happy new year! I'd still like to see this merged when someone has a chance. ❤️ |
35a4ea6
to
7b4dc71
Compare
@jhawthorn are you able to ping someone with merge access to look at this? It looks like this is still an issue. |
7b4dc71
to
dd5612e
Compare
@gmcgibbon we're needing to roll back this change in our next release. It turns out this had some side effects that we are going to need to think through and work around. see #1427 Apologies for the back and forth on this - the change you proposed here is a good one, we just need to introduce it in such a way that doesn't cause harm to other users. |
Reverted in release v4.24.0 |
Make clients autoload so that requiring the gem doesn't slow down boot time of apps that use this gem. In our app, it took about 400ms to load
Octokit::Client
on boot:You can test this on a simpler scale by wrapping the test suite require in a benchmark block like so:
Pre patch this took around ~200ms and post patch about 110ms on my machine. Not quite 2x faster, but still worth autoloading I think. The autoload patched client also removes octokit from our app profiles, which means the require time is reduced significantly in both cases.