Skip to content

Maintain one loader for the load_extensions session #2

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

Merged
merged 1 commit into from
Aug 28, 2022

Conversation

kaspth
Copy link
Owner

@kaspth kaspth commented Aug 28, 2022

Fixes #1

If we set a loader on the main entrance to load_extensions, any
load_extension/load_extensions calls from within an extension can
be tracked in a Set so we avoid double-loading.

Essentially, if load_extensions tries to load :first and :second, but
:first includes load_extension :second we should omit loading :second
when the original load_extensions gets to :second in its
each { load_one _1 } loop.

This means we can avoid using ::Kernel.require and $LOADED_FEATURES,
and it should give us better Zeitwerk interop, though I haven't tested
this yet.

Then once we exit the top-level load_extensions we can discard the
loader and all its state. Yay GC!

Fixes #1

If we set a loader on the main entrance to `load_extensions`, any
`load_extension`/`load_extensions` calls from within an extension can
be tracked in a Set so we avoid double-loading.

Essentially, if load_extensions tries to load :first and :second, but
:first includes `load_extension :second` we should omit loading :second
when the original `load_extensions` gets to :second in its
`each { load_one _1 }` loop.

This means we can avoid using `::Kernel.require` and `$LOADED_FEATURES`,
and it should give us better Zeitwerk interop, though I haven't tested
this yet.

Then once we exit the top-level `load_extensions` we can discard the
loader and all its state. Yay GC!
@kaspth kaspth merged commit a1ced37 into main Aug 28, 2022
@kaspth kaspth deleted the avoid-loaded-features-for-better-zeitwerk-interop branch August 28, 2022 01:11
kaspth added a commit that referenced this pull request Aug 28, 2022
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.

Test with Zeitwerk's reloading
1 participant