Reorganize mrb_cache_entry and mrb_method_t types#6220
Merged
Conversation
The purpose is to remove the `mid` field from the `mrb_cache_entry` structure.
The resulting RAM requirement for the method cache is reduced from 5 words per entry to 4 words per entry for 32-bit CPUs.
The relevant changes are as follows:
- Removed `MRB_USE_METHOD_T_STRUCT`.
The `mrb_method_t` type is now always defined as a structure.
- Include method IDs in `mrb_method_t`
Change the `flags` member to `uint32_t`.
The bitstring structure should be the same as the keys of the `mt` table in `class.c`.
I believe the impact on API compatibility with previous versions is minimal.
Contributor
Author
|
The following is the number of CPU cycles obtained from # I only recently learned about the role and usage of Cachegrind from the SQLite documentation. |
matz
added a commit
that referenced
this pull request
Apr 2, 2024
- MRB_METHOD_CFUNC_P: reduce ternary; use logical-or instead - MRB_METHOD_CFUNC: assume MRB_METHOD_CFUNC_P check before call
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The purpose is to remove the
midfield from themrb_cache_entrystructure. The resulting RAM requirement for the method cache is reduced from 5 words per entry to 4 words per entry for 32-bit CPUs.The relevant changes are as follows:
Removed
MRB_USE_METHOD_T_STRUCT.The
mrb_method_ttype is now always defined as a structure.Include method IDs in
mrb_method_tChange the
flagsmember touint32_t. The bitstring structure should be the same as the keys of themttable inclass.c.I believe the impact on API compatibility with previous versions is minimal.
Attached is a benchmark comparison for your reference.
The targets are (1) the current master, (2) this PR, (3) another alternative and (4) 3.3.0.
Another alternative is to move the bits embedded in
struct mrb_cache_entry::midtostruct mrb_cache_entry::c0(like "word-boxing"). Link to difference.