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

Improve Ruby string interning #3216

Merged
merged 8 commits into from
Aug 17, 2023

Conversation

nirvdrum
Copy link
Collaborator

This is essentially the follow-up work to #3185. I didn't realize that rebasing my branch and pushing that up was going to break the branch link in GitHub. Since it did, I can't re-open that PR. I'm sorry for the churn.

Previously, we always extracted the precise range of bytes we needed when looking up an entry in the frozen string table. If an entry already existed, we'd discard that extracted range in favor of what was already in the cache. This change defers making a copy of the string's bytes until we need to insert into the cache. For situations with many cache hits this approach can be much faster.
…ble.

By restructuring to work with `InternalByteArray`, we can now support working with native strings as well. The `InternalByteArray` will make a copy of the native memory into a Java `byte[]`, which won't change behind our backs.
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Aug 16, 2023
Comment on lines +46 to +47
/** Supports the creation of a cache key using a subset of bytes. This key *must* be used for lookups only. If you
* want to insert into the cache, you *must* use the result of {@link #makeCacheable(boolean)}.
Copy link
Member

Choose a reason for hiding this comment

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

This is super helpful to understand this code/class, thanks!

Comment on lines 101 to 103
if (bytes == null) {
return 0;
}
Copy link
Member

Choose a reason for hiding this comment

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

bytes can never be null, right? I'll just remove this then.
(it probably comes from Arrays#hashCode checking that)

@eregon eregon self-assigned this Aug 17, 2023
@eregon eregon added the in-ci The PR is being tested in CI. Do not push new commits. label Aug 17, 2023
@graalvmbot graalvmbot merged commit f9c1679 into oracle:master Aug 17, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-ci The PR is being tested in CI. Do not push new commits. OCA Verified All contributors have signed the Oracle Contributor Agreement. performance shopify
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants