laminas / laminas-zendframework-bridge

Alias legacy ZF class names to Laminas Project equivalents.
BSD 3-Clause "New" or "Revised" License
1.18k stars 21 forks source link

Development mode response times have increased 10x after migration. #73

Closed robertmarsal closed 2 years ago

robertmarsal commented 4 years ago

Bug Report

Q A
Version(s) 1.1.0

Summary

Development mode response times have increased 10x after migration.

Current behavior

We have a large Apigility deployment (17 APIs, 100s of services). Using Zend/Apigility packages the average response time in development mode (config not cached) is around 70 ms. Once migrated to Laminas packages (using the official migration path) we are seeing response times around 700ms with the exact same codebase. With development mode disabled we see the usual response times but this still has a significant impact on our development experience.

How to reproduce

The culprit seems to be Laminas\ZendFrameworkBridge\ConfigPostProcessor please see attached a stack trace where 73% of the request time is spent on this method.

image

I am not sure why we even need this package to do autoloading for us since all classes and references have already been renamed in the migration. The package is not a direct dependency but a dependency of all the laminas packages so we can't remove it.

Expected behavior

Response time is not impacted.

weierophinney commented 4 years ago

One trick you can use is to audit your third-party libraries for usage of Zend Framework and/or legacy Apigility packages; the easiest way to determine that is running composer show and seeing if any were installed. If none are being used, you can add the following to your composer.json file:

"provide": {
    "laminas/laminas-zendframework-bridge": "*"
}

(And remove any entry in the require section, if present.)

After making your changes, run composer update.

Essentially, the autoloading that the bridge package provides is unnecessary if there are no ZF packages installed. If you've run the migration tooling, your configuration should have been rewritten, and there's no more need for the bridge. The above essentially prevents installation of the package, fixing the issues you're seeing.

froschdesign commented 4 years ago

@weierophinney Should we add this hint to the migration guide?

weierophinney commented 4 years ago

Should we add this hint to the migration guide?

Yes. To be honest, I thought we already had :frowning: .

robertmarsal commented 4 years ago

Thanks @weierophinney. I had to use replace instead of provide in composer.json but response times are as expected now. replace will also remove the module from modules.config.php. As far as I am concerned this can be closed because there is a workaround.