Req #66295 [Opn->Csd]: fetch_timezone_offset has poor performance

From: Date: Wed, 07 Apr 2021 15:59:35 +0000
Subject: Req #66295 [Opn->Csd]: fetch_timezone_offset has poor performance
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233295@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66295&edit=1

 ID:                 66295
 Updated by:         cmb@php.net
 Reported by:        ben dot maurer at gmail dot com
 Summary:            fetch_timezone_offset has poor performance
-Status:             Open
+Status:             Closed
 Type:               Feature/Change Request
 Package:            Date/time related
 Operating System:   N/A
 PHP Version:        Irrelevant
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

This is impemented[1] as of timelib 2021.3, so should be in PHP
8.1.

[1] <https://github.com/derickr/timelib/commit/550d068274be0dea9badd94b1be6be113f84eeef>


Previous Comments:
------------------------------------------------------------------------
[2013-12-15 01:37:17] ben dot maurer at gmail dot com

Description:
------------
fetch_timezone_offset does a linear search through the list of time transitions. Many timezones have
a rather large number of transitions. Eg, Pacific time appears to have ~180 transitions.

One possible solution might be to do a binary search rather than a linear search of the list of
times. But a simpler solution could be to do a search backwards in the array: most people probably
do manipulation of recent rather than old dates

I tested this using HHVM, which uses the same upstream timezone code as PHP.

Test script:
---------------
<?
date_default_timezone_set("America/Los_Angeles");
for ($i = 0; $i < 10000000; $i ++) date('I');

Expected result:
----------------
figuring out the DST rules should not be a perf issue

Actual result:
--------------
perf record shows timelib_get_time_zone_info taking a substantial amount of time


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=66295&edit=1


Thread (1 message)

  • cmb@php.net
  • Unknown Message
    • cmb@php.net
« previous php.bugs (#233295) next »