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

[HACK] ReSpecd - Lazy-load client libraries. #71

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

benk-gc
Copy link
Contributor

@benk-gc benk-gc commented Apr 22, 2024

Currently when loading the gem we also implicitly load the client libraries for the bucket providers. These are quite large, and increase the time to load the gem (and the number of files included) by orders of magnitude.

To avoid unnecessary slowing down the bootstrap, we can instead load these gems only if the provider is used, and memoise this on the class to avoid repeated calls to require (as this returns true when the library is first required).

In testing with Rails, lazy-loading these libraries reduces the time taken for Bundler to require the gem during bootstrap from 0.25 to 0.005 seconds (yes, that's two orders of magnitude faster).

Currently when loading the gem we also implicitly load the client
libraries for the bucket providers. These are quite large, and increase
the time to load the gem (and the number of files included) by orders of
magnitude.

To avoid unnecessary slowing down the bootstrap, we can instead load
these gems only if the provider is used, and memoise this on the class
to avoid repeated calls to `require` (as this returns `true` when the
library is first required).

In testing with Rails, lazy-loading these libraries reduces the time
taken for Bundler to require the gem during bootstrap from 0.25 to 0.005
seconds (yes, that's two orders of magnitude faster).
@benk-gc benk-gc force-pushed the benk--lazy-load-client-libraries branch from 1e7f761 to 456302c Compare April 22, 2024 07:41
@benk-gc benk-gc requested a review from ivgiuliani April 22, 2024 07:42
@benk-gc benk-gc changed the title Lazy-load client libraries. [HACK] ReSpecd - Lazy-load client libraries. Apr 22, 2024
Copy link
Contributor

@ivgiuliani ivgiuliani left a comment

Choose a reason for hiding this comment

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

I had something like this in my local backlog for months and never got around to fix it... 👌

@ivgiuliani ivgiuliani merged commit 8746f6e into master Apr 22, 2024
9 checks passed
@ivgiuliani ivgiuliani deleted the benk--lazy-load-client-libraries branch April 22, 2024 10:42
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.

2 participants