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

[backport 8.x] Add missing argument to Hash default proc #3486

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

sandbergja
Copy link
Contributor

This is a backport of #3485

The proc to fill in a default value for a Hash accepts
two arguments: the hash itself and then the key.  Prior
to this commit, our proc was only using the Hash, but
was treating it as if it was a key.  This had the potential
to cause some serious performance problems when solr
returned many facets or many facet values, when a huge
hash was treated as a string and interpolated into other
strings via Hash#inspect.

Adding this missing argument ensures that we send the
key/field_name, rather than the entire hash.  For the
provided test case on my laptop, this commit speed up
null facet object generation up from 45 iterations/second
to 18,700 iterations/second.  It also doubles the
performance of our advanced search form.

This commit also adds the rspec-benchmark gem as a
dev dependency -- I'm definitely open to figuring out
a different way to test this if the additional dependency
is not desired.

Closes #3484

Co-authored-by: Christina Chortaria <[email protected]>
Co-authored-by: Kevin Reiss <[email protected]>
Co-authored-by: Max Kadel <[email protected]>
@sandbergja sandbergja marked this pull request as ready for review January 6, 2025 20:41
@sandbergja sandbergja merged commit 03ea265 into release-8.x Jan 7, 2025
14 checks passed
@sandbergja sandbergja deleted the backport-hash-default-proc branch January 7, 2025 15:08
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.

2 participants