Skip to content

Commit 4f613fd

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 ea48e2d + 32596f3 commit 4f613fd

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

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.

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)