#58277 closed enhancement (fixed)
Change the position of notoptions lookup in get_option
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.4 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Options, Meta APIs | Keywords: | has-patch needs-dev-note |
| Focuses: | performance | Cc: |
Description
Added in [4855] and #3726 the notoptions cache was added to get_option. This cache was designed to save database queries, do option name that are none not to exist in the database / cache.
However, the ordering this functions present a performance problem. In get_option the look for if a option does not exist, is done before if it does. It is extremely uncommon for a get_option, for a option name that does not exist. Most times it is called, it for a option that does exist. This means the call to notoptions cache is called pointless.
Moving this check, before the database lookup would improve performance.
Attachments (2)
Change History (18)
This ticket was mentioned in PR #4413 on WordPress/wordpress-develop by @spacedmonkey.
3 years ago
#1
- Keywords has-patch added
#2
@
3 years ago
- Keywords has-patch removed
500 runs on TT1
| Trunk - TT1 | PR - TT1 | Trunk - TT1 - Memcached | PR - TT1 - Memcached | |
| Response Time (median) | 73.16 | 73.1 | 73.62 | 72.49 |
| wp-load-alloptions-query (median) | 0.7 | 0.69 | 0.68 | 0.68 |
| wp-before-template (median) | 28.21 | 28.28 | 28.29 | 28.04 |
| wp-before-template-db-queries (median) | 2.76 | 2.78 | 2.76 | 2.75 |
| wp-template (median) | 37.73 | 37.64 | 38.11 | 37.62 |
| wp-total (median) | 65.91 | 66.1 | 66.63 | 65.87 |
| wp-template-db-queries (median) | 6.29 | 6.34 | 6.39 | 6.37 |
500 runs on TT3
| Trunk - TT3 | PR - TT3 | Trunk - TT3 - Memcached | PR - TT3 - Memcached | |
| Response Time (median) | 109.18 | 108.92 | 108.14 | 107.78 |
| wp-before-template (median) | 58.54 | 58.76 | 55.08 | 54.61 |
| wp-template (median) | 44.77 | 44.6 | 47.25 | 47.47 |
| wp-total (median) | 103.52 | 103.45 | 102.76 | 102.47 |
#3
follow-up:
↓ 4
@
3 years ago
In a block theme, this saves 100s of calls to cache.
PR - 1302 vs Trunk - 1949.
#4
in reply to:
↑ 3
@
3 years ago
Replying to spacedmonkey:
In a block theme, this saves 100s of calls to cache.
Yep, this change makes sense imho. I'm a bit unsure on how to best test the result. Seems it would have to compare getting existing and non-existing options (that would trigger DB connections). Perhaps something like get an existing option 1000 times, and 5 different non-existing options 3 times each, etc.
In any case reducing the number of cache lookups is a good thing, even if the speed improvements are minimal.
#5
@
2 years ago
- Milestone changed from Awaiting Review to 6.4
- Owner set to spacedmonkey
- Status changed from new to assigned
This ticket was mentioned in Slack in #core-performance by spacedmonkey. View the logs.
2 years ago
This ticket was mentioned in Slack in #core-performance by spacedmonkey. View the logs.
2 years ago
@spacedmonkey commented on PR #4413:
2 years ago
#11
@costdev @felixarntz Feedback actioned. Ready for review.
#12
@
2 years ago
- Owner changed from flixos90 to spacedmonkey
- Status changed from reviewing to accepted
Trac ticket: https://core.trac.wordpress.org/ticket/58277