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

rb_provide_feature: Prevent $LOADED_FEATURES from being copied #5593

Merged
merged 1 commit into from Feb 23, 2022

Conversation

casperisfine
Copy link
Contributor

[Bug #18599]

vm->loaded_features and vm->loaded_features_snapshot both share the
same root. When a feature is pushed into loaded_features, the sharing
is broken and loaded_features is copied.

So an application requiring 1000 files, will allocate 1000 arrays of
increasing size, which is very wasteful.

To avoid this, we first clear the snapshot, so that loaded_features
can directly be pushed into.

Co-Authored-By: @peterzhu2118

[Bug #18599]

`vm->loaded_features` and `vm->loaded_features_snapshot` both share the
same root. When a feature is pushed into `loaded_features`, the sharing
is broken and `loaded_features` is copied.

So an application requiring 1000 files, will allocate 1000 arrays of
increasing size, which is very wasteful.

To avoid this, we first clear the snapshot, so that `loaded_features`
can directly be pushed into.

Co-Authored-By: Peter Zhu <peter.zhu@shopify.com>
@byroot byroot merged commit b8f0dc5 into ruby:master Feb 23, 2022
@XrXr XrXr deleted the loaded-features-avoid-copy branch March 8, 2022 19:59
@casperisfine casperisfine mentioned this pull request Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants