Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

v3 performance while registering services factories and aliases #122

Closed
@pine3ree

Description

@pine3ree

Working with zend-expressive i found out that migrating to a newer version that included servicemanage 3 the very same test app was much slower. This occurred when registering all zend-form helper plugins.

zendframework/zend-expressive-zendviewrenderer#25
zendframework/zend-form#76

So i decided to prepare and run 2 simple test scripts whose only purpose is to register all zend-form view helpers using zend-servicemanager v2 and v3 and explain the issue here as I believe this repo is more appropriate for this.

v3 test: zend-form configuration time ~ 22 ms (PHP 7.0), ~52-70 ms (PHP 5.6)
cd /my/test/path/sm3
composer require zend-servicemanager:3.0.*
composer require zend-i18n
composer require zend-form
composer require zend-view
<?php
// file /my/test/path/sm3/test.php
require 'vendor/autoload.php';

use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\Config;
use Zend\I18n\View\HelperConfig as I18nViewHelperConfig;
use Zend\Form\View\HelperConfig as FormViewHelperConfig;
use Zend\View\HelperPluginManager;

$serviceManager = new ServiceManager();
$helperManager  = new HelperPluginManager($serviceManager);

(new I18nViewHelperConfig())->configureServiceManager($helperManager);

$t0 = microtime(true);
(new FormViewHelperConfig())->configureServiceManager($helperManager);
$ms = 1000 * round(microtime(true) - $t0, 5) . ' ms';

echo 'zend-servicemanager-v3 => ' . $ms . PHP_EOL;
$ php70 test.php # ~ 22 ms
$ php56 test.php # ~52-70 ms
v2 test: zend-form configuration time < 2ms (PHP 7.0), ~7-9 ms (PHP 5.6)
cd /my/test/path/sm2
composer require zend-servicemanager:2.7.*
composer require zend-i18n
composer require zend-form
composer require zend-view
<?php
// file /my/test/path/sm2/test.php
require 'vendor/autoload.php';

use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\Config;
use Zend\I18n\View\HelperConfig as I18nViewHelperConfig;
use Zend\Form\View\HelperConfig as FormViewHelperConfig;
use Zend\View\HelperPluginManager;

$serviceManager = new ServiceManager();
$helperManager  = new HelperPluginManager();
$helperManager->setServiceLocator($serviceManager);

(new I18nViewHelperConfig())->configureServiceManager($helperManager);

$t0 = microtime(true);
(new FormViewHelperConfig())->configureServiceManager($helperManager);
$ms = 1000 * round(microtime(true) - $t0, 5) . ' ms';

echo 'zend-servicemanager-v2 => ' . $ms . PHP_EOL;
$ php70 test.php # < 2ms
$ php56 test.php # ~7-9 ms

All the installed packages have the same version excluding zend-servicemanager

any hint/help?

could this performance degradation be related to ServiceManager 3 configure() method, involving rewriting the alias arrays and performing inner tests on existing keys and called for every registered alias?

or simply is there something wrong in my setup (all this started when overwriting/delegating a new HelperPluginManagerFactory/DelegatorFactory in zend-expressive zendframework/zend-expressive-zendviewrenderer#25
zendframework/zend-form#76 my last comments)

kind regards

PS
forgot to mention that in the zend-expressive test app I obviously use zend opcode cache ext.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions