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

chore(perf): Make all gems load faster #28104

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gmalette
Copy link

Gem.find_latest_files's performance scales with the amount of files contained across all gems of a project. This can quickly get out of hand, especially on projects with many gems, or large gems.

Gem.loaded_spec is already populated by bundler, and we can iterate over only the name of the gems to detect those matching the google-cloud-* pattern. We can then guess the name of the file we expect to be present.

On my machine, this makes auto_load_files go from ~100ms to <1ms, and requiring bigtable goes from ~220ms to ~110ms.

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea.
  • Follow the instructions in CONTRIBUTING. Most importantly, ensure the tests and linter pass by running bundle exec rake ci in the gem subdirectory.
  • Update code documentation if necessary.

Gem.find_latest_files's performance scales with the amount of files contained
across all gems of a project. This can quickly get out of hand,
especially on projects with many gems, or large gems.

Gem.loaded_spec is already populated by bundler, and we can iterate over
only the name of the gems to detect those matching the google-cloud-*
pattern. We can then guess the name of the file we expect to be present.

On my machine, this makes `auto_load_files` go from ~100ms to <1ms, and
requiring `bigtable` goes from ~220ms to ~110.
@gmalette
Copy link
Author

I don't understand what the CI failure is

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