Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit dbb7ab9

Browse files
committed
bug #36103 [DI] fix preloading script generation (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [DI] fix preloading script generation | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - (fabbot failure is a false positive) On master, we should work on being able to preload more classes (esp. all cache-warmup artifacts). But for 4.4, this is good enough. Submitted as a bug fix because 1. the current code that deals with preloading kinda-works, but only on "dev" mode... and 2. fixing it provides a nice boost! Small bench on a hello world: - before: 380 req/s - after: 580 req/s That's +50%! Pro-tip: adding a few `class_exists()` as done in this PR for the classes that are always used in the implementations (e.g. `new Foo()` in the constructor) will help the preload-script generator to work optimally. Without them, it will discover the symbols to preload only if they're found on methods. Some of those `class_exists()` are mandatory, in relation to anonymous classes and https://bugs.php.net/79349 Commits ------- a10fc4da5d [DI] fix preloading script generation
2 parents 6935305 + 0d92943 commit dbb7ab9

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

Core/Authentication/AuthenticationProviderManager.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
use Symfony\Component\Security\Core\Exception\AuthenticationException;
2323
use Symfony\Component\Security\Core\Exception\ProviderNotFoundException;
2424

25+
// Help opcache.preload discover always-needed symbols
26+
class_exists(AuthenticationEvents::class);
27+
class_exists(AuthenticationFailureEvent::class);
28+
class_exists(AuthenticationSuccessEvent::class);
29+
2530
/**
2631
* AuthenticationProviderManager uses a list of AuthenticationProviderInterface
2732
* instances to authenticate a Token.

Core/Authorization/ExpressionLanguage.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use Psr\Cache\CacheItemPoolInterface;
1515
use Symfony\Component\ExpressionLanguage\ExpressionLanguage as BaseExpressionLanguage;
1616

17+
// Help opcache.preload discover always-needed symbols
18+
class_exists(ExpressionLanguageProvider::class);
19+
1720
if (!class_exists(BaseExpressionLanguage::class)) {
1821
throw new \LogicException(sprintf('The "%s" class requires the "ExpressionLanguage" component. Try running "composer require symfony/expression-language".', ExpressionLanguage::class));
1922
} else {

Http/Firewall/AnonymousAuthenticationListener.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
2020
use Symfony\Component\Security\Core\Exception\AuthenticationException;
2121

22+
// Help opcache.preload discover always-needed symbols
23+
class_exists(AnonymousToken::class);
24+
2225
/**
2326
* AnonymousAuthenticationListener automatically adds a Token if none is
2427
* already present.

Http/Firewall/LegacyListenerTrait.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
1616
use Symfony\Component\HttpKernel\Event\RequestEvent;
1717

18+
// Help opcache.preload discover always-needed symbols
19+
class_exists(RequestEvent::class);
20+
1821
/**
1922
* @deprecated
2023
*

0 commit comments

Comments
 (0)