[TYPO3-core] Taming the Performance in 6.2

Michiel Roos michiel at maxserv.nl
Sat Nov 23 12:14:08 CET 2013


So, we're at version 14 of the patch. It uses only stock PHP to reduce the
amount of calls to idna_convert().

Please test and vote for a 62% reduction in the amount of methods being called on pages like /typo3/.
https://review.typo3.org/#/c/25636/

That's right! 62.5 to be exact %!
http://forge.typo3.org/attachments/25574/Screen_Shot_2013-11-23_at_12.08.54.png

GeneralUtility::isValidUrl() idna converts whole URI instead of domain only.
The expensive idna_convert() is called from isValidUrl().  Instead of
feeding it just the domain part, the whole URI is converted.
When feeding it just the domain part, a great speed gain can be seen.
But if special characters are present in the rest of the url,
filter_var() will still return false.

To prevent the expensive idna_convert() from running for each url, we
first attempt to validate the plain url with filter_var(). If that
succeeds then return TRUE, if not then convert the url to punicode and
re-test.

Urls with special characters in them as well as invalid urls will run
slower, but _most_ of the validation checks will return as quick as they
did in TYPO3 4.5.

Profiling shows only a very slight reduction in method calls. The cause
is probably that many faulty urls are tested.

PHP no longer supports the flags FILTER_FLAG_HOST_REQUIRED and
FILTER_FLAG_SCHEME_REQUIRED. A scheme is now required by default.
[1]

This means we can take a shortcut to FALSE by checking if the url starts
with a scheme. This gives us a 61% reduction in method calls for the
TYPO3 login page. We check for the most common schemes, not all of them
[2].

Also, the text part of the scheme is optional. This allows for urls
like //somescript.js A relative URL without a scheme (http: or https:)
is valid, per RFC 3986: "Uniform Resource Identifier (URI): Generic
Syntax", Section 4.2. [3]. Unfortunately filter_var() sees these urls
as invalid. So these urls were and are still not handled by isValid(). But
that's for another patch.

[1] http://www.php.net/manual/en/filter.filters.flags.php#107382
[2] http://en.wikipedia.org/wiki/URI_scheme
[3] http://www.ietf.org/rfc/rfc3986.txt


More information about the TYPO3-team-core mailing list