wp_timezone_override_offset() has noticeable performance hit
|Reported by:||Rarst||Owned by:|
|Cc:||contact@…, Otto42, tom@…|
While wandering through XHProf generated callgraph of my test stack I came upon wp_timezone_override_offset() eating 3.4% of runtime (73 calls). I do not expect noticeable resource consumption from such minor configuration-related function.
The obvious performance aspect is that it creates and discards two objects (DateTime and DateTimeZone - latter seemingly more heavy) per each call, while calculating same result each run.
The less obvious aspect is that the only use of this function is to pre-filter gmt_offset option, and it essentially hijacks option cache for it.
- calculate result once per run and cache in static variable inside function (straightforward, but retains multiple function call)
- filter gmt_offset on set rather than get (more involved)
- scrap the extra function and/or option altogether? is there still practical need for having two options for timezone information?
Change History (10)
- Cc contact@… added
- Summary changed from wp_timezone_override_offset() has notiecable performance hit to wp_timezone_override_offset() has noticeable performance hit
comment:3 SergeyBiryukov — 11 months ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 3.6