Hi Derick,

Please take a look

https://github.com/php/php-src/blob/51914610ab8bf75d87e5cdec15bd1b38de7907c5/ext/date/lib/parse_date.re#L684-L700

This code is enormously inefficient. For a single abbr_search(), it calls
timelib_strcasecmp() more than 1000 times (complete linear search in a huge
almost ordered array, with repeatable and redundant lowercasing). 11 calls
to abbr_search() per request in the Symfony Demo application (
https://github.com/symfony/demo) eat 2% of overall CPU time.

I see some other inefficient patterns in timelib. e.g. API design that
leads to many useless heap allocations/deallocations; calloc() followed by
memcpy(), etc

Thanks. Dmitry.

Reply via email to