-
Notifications
You must be signed in to change notification settings - Fork 312
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
Updated prepare_date_terms to only call date_i18n once #2214
Merged
Conversation
This file contains 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
6 tasks
felipeelia
requested changes
May 26, 2021
|
Changed from json_encode to wp_json_encode
felipeelia
approved these changes
May 27, 2021
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.
This is a "take over" of #1958 just to address some minor things.
Description of the Change
Calling
date_i18n
a lot gets pretty expensive. Only calling it once for eachprepare_date_terms
call is much more efficient and make indexing faster.Props @WPprodigy
cc: @rinatkhaziev @nickdaugherty @pschoffer @netsuso @parkcityj
Alternate Designs
N/A
Benefits
Removes extraneous calls to
date_i18n
and makes indexing faster.Possible Drawbacks
N/A
Verification Process
There are 4 calls to
prepare_date_terms()
per post being indexed. Each call resulted in 12 calls todate_i18n()
, which ends up going down a bit of a rabbit hole and eventually adding up to a lot of time spent doing filters and alloption calls. So per page of 500 posts being indexed, that is 24,000 calls (500 x 12*4)- seen in cachegrind.Before the changes, a test group of 500 posts took 7.91601 seconds running prepare_date(). After this PR, 0.85888 seconds.
Checklist:
Applicable Issues
Closes: #1958
Changelog Entry
Changed prepare_date_terms to only call date_i18n once. Props @WPprodigy