Cache columns_digest on class#65
Merged
Merged
Conversation
0f1feaa to
cead017
Compare
We previously [improved][1] the speed of columns_digest by not allocating an intermediate array. However, columns_digest is still very hot in our application (~15% of time spent inside MessagePack::Unpacker#full_unpack). This commit caches columns_digest on the model class by hooking into schema loading. Since the value is calculated from a model's columns_hash, this ensures that if the schema is reloaded the value is recalculated. [1]: 5769fc2
cead017 to
d298e5a
Compare
Member
|
@hmcguire-shopify @chrisbutcher any blockers to landing this? |
nvasilevski
approved these changes
Apr 28, 2026
|
🎉 🙏 |
Merged
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.
We previously improved the speed of columns_digest by not allocating an intermediate array. However, columns_digest is still very hot in our application (~15% of time spent inside MessagePack::Unpacker#full_unpack).
This commit caches columns_digest on the model class by hooking into schema loading. Since the value is calculated from a model's columns_hash, this ensures that if the schema is reloaded the value is recalculated.
The benchmark in #67 shows a 2x speedup on dumping and loading an Active Record