typo3-realurl
typo3-realurl copied to clipboard
Turning ConfigurationReader into a Singleton increases performance on sites with a lot of domains
I'm running a TYPO3 installation with about 480 domains in sys_domains (regional newspapers with alternative URLs for dev/staging/production.
A significant portion (~5-10%) of the request lifecycle is taken up by setHostnames()
called by the constructor of ConfigurationReader, because it is called several (somewhere between 10-100, depending on page) times. I assume it's once per link.
Turning ConfigurationReader into a Singleton reduces that. Are there any unintended consequences of that? If not, do you want me to submit a pull request for it?
It has to be different for encoding and decoding.
I was thinking about this as well, a singleton would be better. The encoding, decoding modes could be made to be manually switched on a singleton by separating the __construct routines to a manually called static function.
ConfigurationReader::init($mode, array $urlParameters = array());
And then in that init function the arguments supplied can be compared to what is currently set. If they differ the hostnames etc can be reset. That would reduce the number of calls to setHostnames.
Just my 2c.
Host names will be different in your case. So singleton here will not work anyway. I think caching or optimisation is what is needed here.