Dump dependency container and re-use it - 35% faster test-suite#3809
Dump dependency container and re-use it - 35% faster test-suite#3809TomasVotruba merged 31 commits intorectorphp:mainfrom
Conversation
|
I wonder why these failling tests depend on it seems the PR works for all tests but e2e. seems these are a few use cases which require |
|
the failling CI job is unrelated. created a upstream issue composer-unused/composer-unused#514 |
tests/Validation/Collector/EmptyConfigurableRectorCollector/ConfigurableArrayMissingTest.php
Show resolved
Hide resolved
|
its reproducible a lot faster locally then before. In CI it seems it got slower then before.. :-/.. still investigatin |
a975cad to
814a7ca
Compare
samsonasik
left a comment
There was a problem hiding this comment.
The commit with double quote: Revert "debug infos" should be changed to single quote or no quote to avoid error on build scoped.
|
in case this works in the near future I will squash everything together. atm I don't know why it gets slower on CI, but gets faster on my mac and also my windows laptop :/ |
|
perf wise we reached the goal. we are equal fast in CI and locally. I have updated the benchmark in the description |
5b2b6f0 to
01bee16
Compare
9ffc4d2 to
9c8656f
Compare
src/Kernel/RectorKernel.php
Outdated
| /** | ||
| * @var string | ||
| */ | ||
| private const CACHE_KEY = 'kernel-v4'; |
There was a problem hiding this comment.
when changing dependencies of registered services without also changing existing config files - like e.g. in #3817 -, one need to increase this key to invalidate existing permanent compiled DI containers
see e.g. https://github.com/rectorphp/rector-src/actions/runs/4966591084/jobs/8888109775 what happens when you forget to change the cache key
as soon as you have a need to adjust config files, cache will invalidate automatically
There was a problem hiding this comment.
with ecf3dc6 I have added a new case, which automatically invalidates the compiled container caches, when exceptions are thrown while getting services out of the container - to improve DX so we don't need to update the RectorKernel::CACHE_KEY for most operations
| // clear compiled container cache, to trigger re-discovery | ||
| RectorKernel::clearCache(); | ||
|
|
||
| throw $e; | ||
| } |
There was a problem hiding this comment.
This seems hacky. What is it need for and when it happens? It might be hiding a bug we have
We can adress it later, to keep this PR merged 👍
| return $container; | ||
| } | ||
|
|
||
| } |
|
Let's ship it... thank you Markus for tremendous work on this one 👏 |
|
@staabm it seems cause error in tests when add new param to __construct, see https://github.com/rectorphp/rector-src/actions/runs/4982896946/jobs/8919207651#step:6:26 |
| /** | ||
| * @var string | ||
| */ | ||
| private const CACHE_KEY = 'v7'; |
There was a problem hiding this comment.
should it be updated when add new param to __construct ? see error https://github.com/rectorphp/rector-src/actions/runs/4982917436/jobs/8919255393#step:6:26
There was 1 error:
1) Rector\Core\Tests\Issues\DowngradeNewInArrayInitializerPromotion\DowngradeNewInArrayInitializerPromotionTest::test with data set #0
ArgumentCountError: Too few arguments to function Rector\Core\PhpParser\Parser\InlineCodeParser::__construct(), 3 passed in /tmp/rector/kernel-v7-b923df1ea94cad9fb5b38891cbfaa566ed8e88d7e8551c1c3c978857f94fc876.php on line 3246 and exactly 4 expected
|
It will auto-repair on the next commit see #3809 (comment) |
|
It seems it not auto repair, I need to increase the key b4ad93c |
|
@staabm here first commit that error: https://github.com/rectorphp/rector-src/actions/runs/4982896946/jobs/8919207651 here second commit that still error https://github.com/rectorphp/rector-src/actions/runs/4982917436/jobs/8919255393 so need to increate key cache to fix it b4ad93c |
|
I will have a closer look tomorrow. Thx |
|
@staabm it seems also make e2e test on rector/rector repo error, see https://github.com/rectorphp/rector/actions/runs/4982533394/jobs/8918337344 |
|
@staabm I tried ➜ laminas-servicemanager-migration git:(1.13.x) ✗ vendor/bin/phpunit
PHPUnit 9.6.8 by Sebastian Bergmann and contributors.
EEEEEEEEEEEEEEEEEEE 19 / 19 (100%)
Time: 00:00.039, Memory: 16.00 MB
There were 19 errors:
1) LaminasTest\ServiceManager\Migration\Rector\Class_\ImplementsFactoryInterfaceToPsrFactoryRector\AutoImportRenameUseTest::test with data set #0 ('/Users/samsonasik/www/laminas...hp.inc')
Error: Class "RectorPrefix202305\Symplify\SmartFileSystem\SmartFileSystem" not found
/Users/samsonasik/www/laminas/laminas-servicemanager-migration/vendor/rector/rector/src/Kernel/CachedContainerBuilder.php:40
/Users/samsonasik/www/laminas/laminas-servicemanager-migration/vendor/rector/rector/src/Kernel/RectorKernel.php:112
/Users/samsonasik/www/laminas/laminas-servicemanager-migration/vendor/rector/rector/src/Kernel/RectorKernel.php:55
/Users/samsonasik/www/laminas/laminas-servicemanager-migration/vendor/rector/rector/packages/Testing/PHPUnit/AbstractTestCase.php:38
/Users/samsonasik/www/laminas/laminas-servicemanager-migration/vendor/rector/rector/packages/Testing/PHPUnit/AbstractRectorTestCase.php:60Step to reproduce: |
|
For reference error since rectorphp/rector@bd630a0 build from this PR. |
|
I create an issue for that so it tracked rectorphp/rector#7939 |
closes rectorphp/rector#7930
Before
After
running the whole test-suite it comes down to
Before
php vendor/bin/phpunit 160.22s user 28.24s system 98% cpu 3:11.11 totalAfter
php vendor/bin/phpunit 109.70s user 13.60s system 97% cpu 2:06.40 total