Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up - too much (unnecessary) includes #1578

Open
gooof opened this issue Sep 23, 2018 · 7 comments

Comments

@gooof
Copy link

commented Sep 23, 2018

Bug Report

Current Behavior
Currently flarum is loading over 450 files per page (with standard extensions enabled).
That is a bit too much and costs much unnecessary time.

Example: swiftmailer are never need on the frontend, its only to send mails in cronjobs, after sending a post etc., no need to load these 17 files on every page.

Expected Behavior
Make sure that only files are loading that used on the requested page.

Environment

  • Flarum version: 0.1.0.beta.7.1
total: 0.218 sec (fast but it could faster)
included files:
0 \\index.php
2 \\vendor\autoload.php
3 \\vendor\composer\autoload_real.php
4 \\vendor\composer\ClassLoader.php
5 \\vendor\composer\autoload_static.php
6 \\vendor\danielstjules\stringy\src\Create.php
7 \\vendor\paragonie\random_compat\lib\random.php
8 \\vendor\illuminate\support\helpers.php
9 \\vendor\symfony\polyfill-ctype\bootstrap.php
10 \\vendor\symfony\polyfill-mbstring\bootstrap.php
11 \\vendor\zendframework\zend-diactoros\src\functions\create_uploaded_file.php
12 \\vendor\zendframework\zend-diactoros\src\functions\marshal_headers_from_sapi.php
13 \\vendor\zendframework\zend-diactoros\src\functions\marshal_method_from_sapi.php
14 \\vendor\zendframework\zend-diactoros\src\functions\marshal_protocol_version_from_sapi.php
15 \\vendor\zendframework\zend-diactoros\src\functions\marshal_uri_from_sapi.php
16 \\vendor\zendframework\zend-diactoros\src\functions\normalize_server.php
17 \\vendor\zendframework\zend-diactoros\src\functions\normalize_uploaded_files.php
18 \\vendor\zendframework\zend-diactoros\src\functions\parse_cookie_header.php
19 \\vendor\guzzlehttp\psr7\src\functions_include.php
20 \\vendor\guzzlehttp\psr7\src\functions.php
21 \\vendor\swiftmailer\swiftmailer\lib\swift_required.php
22 \\vendor\swiftmailer\swiftmailer\lib\classes\Swift.php
23 \\vendor\guzzlehttp\promises\src\functions_include.php
24 \\vendor\guzzlehttp\promises\src\functions.php
25 \\vendor\guzzlehttp\guzzle\src\functions_include.php
26 \\vendor\guzzlehttp\guzzle\src\functions.php
27 \\vendor\nikic\fast-route\src\functions.php
28 \\vendor\flarum\core\src\helpers.php
29 \\vendor\flarum\core\src\Forum\Server.php
30 \\vendor\flarum\core\src\Http\AbstractServer.php
31 \\vendor\flarum\core\src\Foundation\AbstractServer.php
32 \\config.php
33 \\vendor\zendframework\zend-diactoros\src\Server.php
34 \\vendor\zendframework\zend-diactoros\src\ServerRequestFactory.php
35 \\vendor\zendframework\zend-diactoros\src\ServerRequest.php
36 \\vendor\zendframework\zend-diactoros\src\RequestTrait.php
37 \\vendor\zendframework\zend-diactoros\src\MessageTrait.php
38 \\vendor\psr\http-message\src\ServerRequestInterface.php
39 \\vendor\psr\http-message\src\RequestInterface.php
40 \\vendor\psr\http-message\src\MessageInterface.php
41 \\vendor\zendframework\zend-diactoros\src\Uri.php
42 \\vendor\psr\http-message\src\UriInterface.php
43 \\vendor\zendframework\zend-diactoros\src\PhpInputStream.php
44 \\vendor\zendframework\zend-diactoros\src\Stream.php
45 \\vendor\psr\http-message\src\StreamInterface.php
46 \\vendor\zendframework\zend-diactoros\src\HeaderSecurity.php
47 \\vendor\zendframework\zend-diactoros\src\Response.php
48 \\vendor\psr\http-message\src\ResponseInterface.php
49 \\vendor\zendframework\zend-stratigility\src\NoopFinalHandler.php
50 \\vendor\flarum\core\src\Foundation\Application.php
51 \\vendor\illuminate\container\Container.php
52 \\vendor\illuminate\contracts\Container\Container.php
53 \\vendor\illuminate\contracts\Foundation\Application.php
54 \\vendor\illuminate\events\EventServiceProvider.php
55 \\vendor\illuminate\support\ServiceProvider.php
56 \\vendor\illuminate\support\Arr.php
57 \\vendor\illuminate\support\Traits\Macroable.php
58 \\vendor\illuminate\events\Dispatcher.php
59 \\vendor\illuminate\contracts\Events\Dispatcher.php
60 \\vendor\illuminate\config\Repository.php
61 \\vendor\illuminate\contracts\Config\Repository.php
62 \\vendor\monolog\monolog\src\Monolog\Logger.php
63 \\vendor\psr\log\Psr\Log\LoggerInterface.php
64 \\vendor\monolog\monolog\src\Monolog\Handler\StreamHandler.php
65 \\vendor\monolog\monolog\src\Monolog\Handler\AbstractProcessingHandler.php
66 \\vendor\monolog\monolog\src\Monolog\Handler\AbstractHandler.php
67 \\vendor\monolog\monolog\src\Monolog\Handler\HandlerInterface.php
68 \\vendor\monolog\monolog\src\Monolog\Formatter\LineFormatter.php
69 \\vendor\monolog\monolog\src\Monolog\Formatter\NormalizerFormatter.php
70 \\vendor\monolog\monolog\src\Monolog\Formatter\FormatterInterface.php
71 \\vendor\flarum\core\src\Database\DatabaseServiceProvider.php
72 \\vendor\flarum\core\src\Foundation\AbstractServiceProvider.php
73 \\vendor\flarum\core\src\Settings\SettingsServiceProvider.php
74 \\vendor\flarum\core\src\Locale\LocaleServiceProvider.php
75 \\vendor\illuminate\bus\BusServiceProvider.php
76 \\vendor\illuminate\filesystem\FilesystemServiceProvider.php
77 \\vendor\illuminate\hashing\HashServiceProvider.php
78 \\vendor\illuminate\mail\MailServiceProvider.php
79 \\vendor\illuminate\view\ViewServiceProvider.php
80 \\vendor\illuminate\validation\ValidationServiceProvider.php
81 \\vendor\illuminate\contracts\Validation\ValidatesWhenResolved.php
82 \\vendor\flarum\core\src\Settings\MemoryCacheSettingsRepository.php
83 \\vendor\flarum\core\src\Settings\SettingsRepositoryInterface.php
84 \\vendor\flarum\core\src\Settings\DatabaseSettingsRepository.php
85 \\vendor\illuminate\database\Connectors\ConnectionFactory.php
86 \\vendor\illuminate\database\Connectors\MySqlConnector.php
87 \\vendor\illuminate\database\Connectors\Connector.php
88 \\vendor\illuminate\database\DetectsLostConnections.php
89 \\vendor\illuminate\database\Connectors\ConnectorInterface.php
90 \\vendor\illuminate\database\MySqlConnection.php
91 \\vendor\illuminate\database\Connection.php
92 \\vendor\illuminate\database\ConnectionInterface.php
93 \\vendor\illuminate\database\Query\Grammars\MySqlGrammar.php
94 \\vendor\illuminate\database\Query\Grammars\Grammar.php
95 \\vendor\illuminate\database\Grammar.php
96 \\vendor\illuminate\database\Query\Processors\MySqlProcessor.php
97 \\vendor\illuminate\database\Query\Processors\Processor.php
98 \\vendor\illuminate\database\Query\Builder.php
99 \\vendor\flarum\core\src\Core\CoreServiceProvider.php
100 \\vendor\illuminate\container\ContextualBindingBuilder.php
101 \\vendor\illuminate\contracts\Container\ContextualBindingBuilder.php
102 \\vendor\flarum\core\src\Core\Notification\NotificationServiceProvider.php
103 \\vendor\flarum\core\src\Core\Search\SearchServiceProvider.php
104 \\vendor\flarum\core\src\Formatter\FormatterServiceProvider.php
105 \\vendor\flarum\core\src\Api\ApiServiceProvider.php
106 \\vendor\flarum\core\src\Forum\ForumServiceProvider.php
107 \\vendor\flarum\core\src\Admin\AdminServiceProvider.php
108 \\vendor\flarum\core\src\Extension\ExtensionServiceProvider.php
109 \\vendor\flarum\core\src\Extension\ExtensionManager.php
110 \\vendor\flarum\core\src\Database\Migrator.php
111 \\vendor\flarum\core\src\Database\MigrationRepositoryInterface.php
112 \\vendor\flarum\core\src\Database\DatabaseMigrationRepository.php
113 \\vendor\illuminate\database\ConnectionResolver.php
114 \\vendor\illuminate\database\ConnectionResolverInterface.php
115 \\vendor\illuminate\filesystem\Filesystem.php
116 \\vendor\illuminate\support\Collection.php
117 \\vendor\illuminate\contracts\Support\Arrayable.php
118 \\vendor\illuminate\contracts\Support\Jsonable.php
119 \\vendor\flarum\core\src\Extension\Extension.php
120 \\vendor\illuminate\support\Str.php
121 \\vendor\flarum\flarum-ext-approval\bootstrap.php
122 \\vendor\flarum\flarum-ext-approval\src\Listener\AddClientAssets.php
123 \\vendor\flarum\flarum-ext-approval\src\Listener\AddPostApprovalAttributes.php
124 \\vendor\flarum\flarum-ext-approval\src\Listener\ApproveContent.php
125 \\vendor\flarum\core\src\Core\Access\AssertPermissionTrait.php
126 \\vendor\flarum\flarum-ext-approval\src\Listener\HideUnapprovedContent.php
127 \\vendor\flarum\flarum-ext-approval\src\Listener\UnapproveNewContent.php
128 \\vendor\flarum\flarum-ext-approval\src\Access\TagPolicy.php
129 \\vendor\flarum\core\src\Core\Access\AbstractPolicy.php
130 \\vendor\flarum\flarum-ext-bbcode\bootstrap.php
131 \\vendor\flarum\flarum-ext-bbcode\src\Listener\FormatBBCode.php
132 \\vendor\cbmainz\flarum-de\bootstrap.php
133 \\vendor\flarum\flarum-ext-emoji\bootstrap.php
134 \\vendor\flarum\flarum-ext-emoji\src\Listener\AddClientAssets.php
135 \\vendor\flarum\flarum-ext-emoji\src\Listener\FormatEmoticons.php
136 \\vendor\flarum\flarum-ext-english\bootstrap.php
137 \\vendor\flarum\flarum-ext-flags\bootstrap.php
138 \\vendor\flarum\flarum-ext-flags\src\Listener\AddClientAssets.php
139 \\vendor\flarum\flarum-ext-flags\src\Listener\AddFlagsApi.php
140 \\vendor\flarum\flarum-ext-flags\src\Listener\AddPostFlagsRelationship.php
---
143 \\vendor\flarum\flarum-ext-likes\bootstrap.php
144 \\vendor\flarum\flarum-ext-likes\src\Listener\AddClientAssets.php
145 \\vendor\flarum\flarum-ext-likes\src\Listener\AddPostLikesRelationship.php
146 \\vendor\flarum\flarum-ext-likes\src\Listener\SaveLikesToDatabase.php
147 \\vendor\flarum\flarum-ext-likes\src\Listener\SendNotificationWhenPostIsLiked.php
148 \\vendor\flarum\core\src\Core\Notification\NotificationSyncer.php
149 \\vendor\flarum\core\src\Core\Repository\NotificationRepository.php
150 \\vendor\flarum\core\src\Core\Notification\NotificationMailer.php
151 \\vendor\illuminate\contracts\Mail\Mailer.php
152 \\vendor\illuminate\mail\Mailer.php
153 \\vendor\illuminate\contracts\Mail\MailQueue.php
154 \\vendor\illuminate\view\Engines\EngineResolver.php
155 \\vendor\illuminate\view\FileViewFinder.php
156 \\vendor\illuminate\view\ViewFinderInterface.php
157 \\vendor\illuminate\view\Factory.php
158 \\vendor\illuminate\contracts\View\Factory.php
159 \\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Mailer.php
160 \\vendor\swiftmailer\swiftmailer\lib\swift_init.php
161 \\vendor\swiftmailer\swiftmailer\lib\dependency_maps\cache_deps.php
162 \\vendor\swiftmailer\swiftmailer\lib\classes\Swift\DependencyContainer.php
163 \\vendor\swiftmailer\swiftmailer\lib\dependency_maps\mime_deps.php
164 \\vendor\swiftmailer\swiftmailer\lib\mime_types.php
165 \\vendor\swiftmailer\swiftmailer\lib\dependency_maps\message_deps.php
166 \\vendor\swiftmailer\swiftmailer\lib\dependency_maps\transport_deps.php
167 \\vendor\swiftmailer\swiftmailer\lib\preferences.php
168 \\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Preferences.php
169 \\vendor\illuminate\mail\TransportManager.php
170 \\vendor\illuminate\support\Manager.php
171 \\vendor\swiftmailer\swiftmailer\lib\classes\Swift\MailTransport.php
172 \\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\MailTransport.php
173 \\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport.php
174 \\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\SimpleMailInvoker.php
175 \\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\MailInvoker.php
176 \\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Events\SimpleEventDispatcher.php
177 \\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Events\EventDispatcher.php
178 \\vendor\flarum\flarum-ext-lock\bootstrap.php
179 \\vendor\flarum\flarum-ext-lock\src\Listener\AddClientAssets.php
180 \\vendor\flarum\flarum-ext-lock\src\Listener\AddDiscussionLockedAttributes.php
181 \\vendor\flarum\flarum-ext-lock\src\Listener\AddLockedGambit.php
182 \\vendor\flarum\flarum-ext-lock\src\Listener\CreatePostWhenDiscussionIsLocked.php
183 \\vendor\flarum\flarum-ext-lock\src\Listener\SaveLockedToDatabase.php
184 \\vendor\flarum\flarum-ext-lock\src\Access\DiscussionPolicy.php
185 \\vendor\flarum\flarum-ext-lock\src\Access\PostPolicy.php
186 \\vendor\flarum\flarum-ext-markdown\bootstrap.php
187 \\vendor\flarum\flarum-ext-markdown\src\Listener\FormatMarkdown.php
188 \\vendor\flarum\flarum-ext-mentions\bootstrap.php
189 \\vendor\flarum\flarum-ext-mentions\src\Listener\AddClientAssets.php
190 \\vendor\flarum\flarum-ext-mentions\src\Listener\AddPostMentionedByRelationship.php
191 \\vendor\flarum\core\src\Core\Repository\PostRepository.php
192 \\vendor\flarum\flarum-ext-mentions\src\Listener\FormatPostMentions.php
193 \\vendor\flarum\core\src\Forum\UrlGenerator.php
194 \\vendor\flarum\core\src\Http\AbstractUrlGenerator.php
195 \\vendor\flarum\core\src\Http\RouteCollection.php
196 \\vendor\nikic\fast-route\src\DataGenerator\GroupCountBased.php
197 \\vendor\nikic\fast-route\src\DataGenerator\RegexBasedAbstract.php
198 \\vendor\nikic\fast-route\src\DataGenerator.php
199 \\vendor\nikic\fast-route\src\RouteParser\Std.php
200 \\vendor\nikic\fast-route\src\RouteParser.php
201 \\vendor\flarum\flarum-ext-mentions\src\Listener\FormatUserMentions.php
202 \\vendor\flarum\core\src\Core\Repository\UserRepository.php
203 \\vendor\flarum\flarum-ext-mentions\src\Listener\UpdatePostMentionsMetadata.php
204 \\vendor\flarum\flarum-ext-mentions\src\Listener\UpdateUserMentionsMetadata.php
205 \\vendor\flarum\flarum-ext-mentions\src\Listener\AddFilterByMentions.php
206 \\vendor\flarum\flarum-ext-sticky\bootstrap.php
207 \\vendor\flarum\flarum-ext-sticky\src\Listener\AddApiAttributes.php
208 \\vendor\flarum\flarum-ext-sticky\src\Listener\AddClientAssets.php
209 \\vendor\flarum\flarum-ext-sticky\src\Listener\CreatePostWhenDiscussionIsStickied.php
210 \\vendor\flarum\flarum-ext-sticky\src\Listener\PinStickiedDiscussionsToTop.php
211 \\vendor\flarum\flarum-ext-sticky\src\Listener\SaveStickyToDatabase.php
212 \\vendor\flarum\flarum-ext-subscriptions\bootstrap.php
213 \\vendor\flarum\flarum-ext-subscriptions\src\Listener\AddClientAssets.php
214 \\vendor\flarum\flarum-ext-subscriptions\src\Listener\AddDiscussionSubscriptionAttribute.php
215 \\vendor\flarum\flarum-ext-subscriptions\src\Listener\FilterDiscussionListBySubscription.php
216 \\vendor\flarum\flarum-ext-subscriptions\src\Listener\SaveSubscriptionToDatabase.php
217 \\vendor\flarum\flarum-ext-subscriptions\src\Listener\SendNotificationWhenReplyIsPosted.php
218 \\vendor\flarum\flarum-ext-subscriptions\src\Listener\FollowAfterReply.php
219 \\vendor\flarum\flarum-ext-suspend\bootstrap.php
220 \\vendor\flarum\flarum-ext-suspend\src\Listener\AddClientAssets.php
221 \\vendor\flarum\flarum-ext-suspend\src\Listener\AddUserSuspendAttributes.php
222 \\vendor\flarum\flarum-ext-suspend\src\Listener\RevokeAccessFromSuspendedUsers.php
223 \\vendor\flarum\flarum-ext-suspend\src\Listener\SaveSuspensionToDatabase.php
224 \\vendor\flarum\flarum-ext-suspend\src\SuspendValidator.php
225 \\vendor\flarum\core\src\Core\Validator\AbstractValidator.php
226 \\vendor\illuminate\validation\Factory.php
227 \\vendor\illuminate\contracts\Validation\Factory.php
228 \\vendor\flarum\core\src\Locale\Translator.php
229 \\vendor\symfony\translation\Translator.php
230 \\vendor\symfony\translation\TranslatorInterface.php
231 \\vendor\symfony\translation\TranslatorBagInterface.php
232 \\vendor\symfony\translation\MessageSelector.php
233 \\vendor\flarum\core\src\Locale\PrefixedYamlFileLoader.php
234 \\vendor\symfony\translation\Loader\YamlFileLoader.php
235 \\vendor\symfony\translation\Loader\ArrayLoader.php
236 \\vendor\symfony\translation\Loader\LoaderInterface.php
237 \\vendor\illuminate\validation\DatabasePresenceVerifier.php
238 \\vendor\illuminate\validation\PresenceVerifierInterface.php
239 \\vendor\flarum\flarum-ext-suspend\src\Access\UserPolicy.php
240 \\vendor\flarum\flarum-ext-tags\bootstrap.php
241 \\vendor\flarum\flarum-ext-tags\src\Listener\AddClientAssets.php
242 \\vendor\flarum\flarum-ext-tags\src\Listener\AddDiscussionTagsRelationship.php
243 \\vendor\flarum\flarum-ext-tags\src\Listener\AddForumTagsRelationship.php
244 \\vendor\flarum\flarum-ext-tags\src\Listener\AddTagsApi.php
245 \\vendor\flarum\flarum-ext-tags\src\Listener\CreatePostWhenTagsAreChanged.php
246 \\vendor\flarum\flarum-ext-tags\src\Listener\FilterDiscussionListByTags.php
247 \\vendor\flarum\flarum-ext-tags\src\Listener\FilterPostsQueryByTag.php
248 \\vendor\flarum\flarum-ext-tags\src\Listener\SaveTagsToDatabase.php
249 \\vendor\flarum\flarum-ext-tags\src\Listener\UpdateTagMetadata.php
250 \\vendor\flarum\flarum-ext-tags\src\Access\GlobalPolicy.php
251 \\vendor\flarum\flarum-ext-tags\src\Access\DiscussionPolicy.php
252 \\vendor\flarum\flarum-ext-tags\src\Access\TagPolicy.php
253 \\vendor\flarum\flarum-ext-tags\src\Access\FlagPolicy.php
254 \\vendor\flarum\core\src\Database\AbstractModel.php
255 \\vendor\illuminate\database\Eloquent\Model.php
256 \\vendor\illuminate\contracts\Queue\QueueableEntity.php
257 \\vendor\illuminate\contracts\Routing\UrlRoutable.php
258 \\vendor\flarum\core\src\Locale\LocaleManager.php
259 \\vendor\flarum\core\src\Event\ConfigureLocales.php
260 \\vendor\flarum\core\src\Event\ConfigureNotificationTypes.php
261 \\vendor\flarum\flarum-ext-likes\src\Notification\PostLikedBlueprint.php
262 \\vendor\flarum\core\src\Core\Notification\BlueprintInterface.php
263 \\vendor\flarum\flarum-ext-lock\src\Notification\DiscussionLockedBlueprint.php
264 \\vendor\flarum\flarum-ext-mentions\src\Notification\PostMentionedBlueprint.php
265 \\vendor\flarum\core\src\Core\Notification\MailableInterface.php
266 \\vendor\flarum\flarum-ext-mentions\src\Notification\UserMentionedBlueprint.php
267 \\vendor\flarum\flarum-ext-subscriptions\src\Notification\NewPostBlueprint.php
268 \\vendor\flarum\core\src\Core\Notification.php
269 \\vendor\flarum\core\src\Core\Notification\DiscussionRenamedBlueprint.php
270 \\vendor\flarum\core\src\Core\User.php
271 \\vendor\flarum\core\src\Core\Support\EventGeneratorTrait.php
272 \\vendor\flarum\core\src\Core\Support\ScopeVisibilityTrait.php
273 \\vendor\illuminate\bus\Dispatcher.php
274 \\vendor\illuminate\contracts\Bus\Dispatcher.php
275 \\vendor\illuminate\contracts\Bus\QueueingDispatcher.php
276 \\vendor\illuminate\contracts\Bus\HandlerResolver.php
277 \\vendor\illuminate\pipeline\Pipeline.php
278 \\vendor\illuminate\contracts\Pipeline\Pipeline.php
279 \\vendor\flarum\core\src\Core\Access\Gate.php
280 \\vendor\illuminate\contracts\Auth\Access\Gate.php
281 \\vendor\flarum\core\src\Event\ConfigurePostTypes.php
282 \\vendor\flarum\core\src\Core\Post.php
283 \\vendor\flarum\core\src\Core\Post\CommentPost.php
284 \\vendor\flarum\core\src\Core\Post\DiscussionRenamedPost.php
285 \\vendor\flarum\core\src\Core\Post\AbstractEventPost.php
286 \\vendor\flarum\core\src\Core\Post\MergeableInterface.php
287 \\vendor\flarum\flarum-ext-lock\src\Post\DiscussionLockedPost.php
288 \\vendor\flarum\flarum-ext-sticky\src\Post\DiscussionStickiedPost.php
289 \\vendor\flarum\flarum-ext-tags\src\Post\DiscussionTaggedPost.php
290 \\vendor\flarum\core\src\Formatter\Formatter.php
291 \\vendor\illuminate\cache\Repository.php
292 \\vendor\illuminate\contracts\Cache\Repository.php
293 \\vendor\illuminate\cache\FileStore.php
294 \\vendor\illuminate\contracts\Cache\Store.php
295 \\vendor\illuminate\hashing\BcryptHasher.php
296 \\vendor\illuminate\contracts\Hashing\Hasher.php
297 \\vendor\flarum\core\src\Core\Listener\SelfDemotionGuard.php
298 \\vendor\flarum\core\src\Core\Listener\DiscussionMetadataUpdater.php
299 \\vendor\flarum\core\src\Core\Listener\UserMetadataUpdater.php
300 \\vendor\flarum\core\src\Core\Listener\ExtensionValidator.php
301 \\vendor\flarum\core\src\Core\Listener\EmailConfirmationMailer.php
302 \\vendor\flarum\core\src\Core\Listener\DiscussionRenamedNotifier.php
303 \\vendor\flarum\core\src\Core\Access\DiscussionPolicy.php
304 \\vendor\flarum\core\src\Core\Access\GroupPolicy.php
305 \\vendor\flarum\core\src\Core\Access\PostPolicy.php
306 \\vendor\flarum\core\src\Core\Access\UserPolicy.php
307 \\vendor\flarum\core\src\Http\Handler\RouteHandlerFactory.php
308 \\vendor\flarum\core\src\Http\Handler\ControllerRouteHandler.php
309 \\vendor\nikic\fast-route\src\Route.php
310 \\vendor\flarum\core\src\Event\ConfigureApiRoutes.php
311 \\vendor\flarum\core\src\Event\AbstractConfigureRoutes.php
312 \\vendor\flarum\core\src\Api\Serializer\NotificationSerializer.php
313 \\vendor\flarum\core\src\Api\Serializer\AbstractSerializer.php
314 \\vendor\tobscure\json-api\src\AbstractSerializer.php
315 \\vendor\tobscure\json-api\src\SerializerInterface.php
316 \\vendor\flarum\core\src\Api\Controller\AbstractSerializeController.php
317 \\vendor\flarum\core\src\Http\Controller\ControllerInterface.php
318 \\vendor\flarum\core\src\Event\ConfigureForumRoutes.php
319 \\vendor\zendframework\zend-stratigility\src\MiddlewarePipe.php
320 \\vendor\zendframework\zend-stratigility\src\MiddlewareInterface.php
321 \\vendor\http-interop\http-middleware\src\ServerMiddlewareInterface.php
322 \\vendor\flarum\core\src\Http\Middleware\HandleErrors.php
323 \\vendor\zendframework\zend-stratigility\src\Utils.php
324 \\vendor\zendframework\zend-stratigility\src\Route.php
325 \\vendor\flarum\core\src\Http\Middleware\ParseJsonBody.php
326 \\vendor\flarum\core\src\Http\Middleware\StartSession.php
327 \\vendor\flarum\core\src\Http\CookieFactory.php
328 \\vendor\flarum\core\src\Http\Middleware\RememberFromCookie.php
329 \\vendor\flarum\core\src\Http\Middleware\AuthenticateWithSession.php
330 \\vendor\flarum\core\src\Http\Middleware\SetLocale.php
331 \\vendor\flarum\core\src\Event\ConfigureMiddleware.php
332 \\vendor\flarum\core\src\Http\Middleware\DispatchRoute.php
333 \\vendor\zendframework\zend-stratigility\src\Http\Request.php
334 \\vendor\zendframework\zend-stratigility\src\Http\Response.php
335 \\vendor\zendframework\zend-stratigility\src\Http\ResponseInterface.php
336 \\vendor\zendframework\zend-stratigility\src\Next.php
337 \\vendor\http-interop\http-middleware\src\DelegateInterface.php
338 \\vendor\zendframework\zend-stratigility\src\Dispatch.php
339 \\vendor\symfony\http-foundation\Session\Session.php
340 \\vendor\symfony\http-foundation\Session\SessionInterface.php
341 \\vendor\symfony\http-foundation\Session\Storage\NativeSessionStorage.php
342 \\vendor\symfony\http-foundation\Session\Storage\SessionStorageInterface.php
343 \\vendor\symfony\http-foundation\Session\Storage\MetadataBag.php
344 \\vendor\symfony\http-foundation\Session\SessionBagInterface.php
345 \\vendor\symfony\http-foundation\Session\Storage\Proxy\SessionHandlerProxy.php
346 \\vendor\symfony\http-foundation\Session\Storage\Proxy\AbstractProxy.php
347 \\vendor\symfony\http-foundation\Session\Attribute\AttributeBag.php
348 \\vendor\symfony\http-foundation\Session\Attribute\AttributeBagInterface.php
349 \\vendor\symfony\http-foundation\Session\Flash\FlashBag.php
350 \\vendor\symfony\http-foundation\Session\Flash\FlashBagInterface.php
351 \\vendor\flarum\core\src\Http\AccessToken.php
352 \\vendor\flarum\core\src\Event\ConfigureModelDefaultAttributes.php
353 \\vendor\flarum\core\src\Event\GetModelRelationship.php
354 \\vendor\illuminate\database\Eloquent\Builder.php
355 \\vendor\illuminate\database\Eloquent\Collection.php
356 \\vendor\flarum\core\src\Event\ConfigureModelDates.php
357 \\vendor\flarum\core\src\Event\ConfigureUserPreferences.php
358 \\vendor\nesbot\carbon\src\Carbon\Carbon.php
359 \\vendor\nikic\fast-route\src\Dispatcher\GroupCountBased.php
360 \\vendor\nikic\fast-route\src\Dispatcher\RegexBasedAbstract.php
361 \\vendor\nikic\fast-route\src\Dispatcher.php
362 \\vendor\flarum\core\src\Forum\Controller\IndexController.php
363 \\vendor\flarum\core\src\Forum\Controller\WebAppController.php
364 \\vendor\flarum\core\src\Http\Controller\AbstractWebAppController.php
365 \\vendor\flarum\core\src\Http\Controller\AbstractHtmlController.php
366 \\vendor\flarum\core\src\Forum\WebApp.php
367 \\vendor\flarum\core\src\Http\WebApp\AbstractWebApp.php
368 \\vendor\flarum\core\src\Http\WebApp\WebAppAssetsFactory.php
369 \\vendor\flarum\core\src\Http\WebApp\WebAppViewFactory.php
370 \\vendor\flarum\core\src\Api\Client.php
371 \\vendor\flarum\core\src\Api\ErrorHandler.php
372 \\vendor\tobscure\json-api\src\ErrorHandler.php
373 \\vendor\flarum\core\src\Api\Handler\FloodingExceptionHandler.php
374 \\vendor\tobscure\json-api\src\Exception\Handler\ExceptionHandlerInterface.php
375 \\vendor\flarum\core\src\Api\Handler\IlluminateValidationExceptionHandler.php
376 \\vendor\flarum\core\src\Api\Handler\InvalidAccessTokenExceptionHandler.php
377 \\vendor\flarum\core\src\Api\Handler\InvalidConfirmationTokenExceptionHandler.php
378 \\vendor\flarum\core\src\Api\Handler\MethodNotAllowedExceptionHandler.php
379 \\vendor\flarum\core\src\Api\Handler\ModelNotFoundExceptionHandler.php
380 \\vendor\flarum\core\src\Api\Handler\PermissionDeniedExceptionHandler.php
381 \\vendor\flarum\core\src\Api\Handler\RouteNotFoundExceptionHandler.php
382 \\vendor\flarum\core\src\Api\Handler\TokenMismatchExceptionHandler.php
383 \\vendor\flarum\core\src\Api\Handler\ValidationExceptionHandler.php
384 \\vendor\tobscure\json-api\src\Exception\Handler\InvalidParameterExceptionHandler.php
385 \\vendor\tobscure\json-api\src\Exception\Handler\FallbackExceptionHandler.php
386 \\vendor\flarum\core\src\Api\Serializer\CurrentUserSerializer.php
387 \\vendor\flarum\core\src\Api\Serializer\UserSerializer.php
388 \\vendor\flarum\core\src\Api\Serializer\UserBasicSerializer.php
389 \\vendor\flarum\core\src\Http\WebApp\WebAppAssets.php
390 \\vendor\flarum\core\src\Http\WebApp\WebAppView.php
391 \\vendor\flarum\core\src\Asset\JsCompiler.php
392 \\vendor\flarum\core\src\Asset\RevisionCompiler.php
393 \\vendor\flarum\core\src\Asset\CompilerInterface.php
394 \\vendor\flarum\core\src\Asset\LessCompiler.php
395 \\vendor\flarum\core\src\Locale\JsCompiler.php
396 \\vendor\symfony\translation\MessageCatalogue.php
397 \\vendor\symfony\translation\MessageCatalogueInterface.php
398 \\vendor\symfony\translation\MetadataAwareInterface.php
399 \\vendor\symfony\yaml\Parser.php
400 \\vendor\symfony\yaml\Inline.php
401 \\vendor\symfony\yaml\Unescaper.php
402 \\vendor\flarum\core\src\Api\Controller\ListDiscussionsController.php
403 \\vendor\flarum\core\src\Api\Controller\AbstractCollectionController.php
404 \\vendor\flarum\core\src\Core\Search\Discussion\DiscussionSearcher.php
405 \\vendor\flarum\core\src\Core\Search\ApplySearchParametersTrait.php
406 \\vendor\flarum\core\src\Core\Search\GambitManager.php
407 \\vendor\flarum\core\src\Event\ConfigureDiscussionGambits.php
408 \\vendor\flarum\core\src\Event\AbstractConfigureGambits.php
409 \\vendor\flarum\core\src\Core\Repository\DiscussionRepository.php
410 \\vendor\flarum\core\src\Api\UrlGenerator.php
411 \\vendor\tobscure\json-api\src\Document.php
412 \\vendor\tobscure\json-api\src\LinksTrait.php
413 \\vendor\tobscure\json-api\src\MetaTrait.php
414 \\vendor\flarum\core\src\Event\ConfigureApiController.php
415 \\vendor\tobscure\json-api\src\Parameters.php
416 \\vendor\flarum\core\src\Core\Search\SearchCriteria.php
417 \\vendor\flarum\core\src\Core\Discussion.php
418 \\vendor\flarum\core\src\Event\ScopeModelVisibility.php
419 \\vendor\flarum\core\src\Core\Group.php
420 \\vendor\illuminate\database\Eloquent\Relations\BelongsToMany.php
421 \\vendor\illuminate\database\Eloquent\Relations\Relation.php
422 \\vendor\illuminate\database\Query\JoinClause.php
423 \\vendor\illuminate\database\Eloquent\Relations\Pivot.php
424 \\vendor\illuminate\database\Query\Expression.php
425 \\vendor\flarum\flarum-ext-tags\src\Tag.php
426 \\vendor\illuminate\database\Eloquent\Relations\BelongsTo.php
427 \\vendor\flarum\core\src\Event\ScopePrivateDiscussionVisibility.php
428 \\vendor\flarum\core\src\Event\GetPermission.php
429 \\vendor\flarum\core\src\Core\Search\Discussion\DiscussionSearch.php
430 \\vendor\flarum\core\src\Core\Search\AbstractSearch.php
431 \\vendor\flarum\core\src\Core\Search\Discussion\Gambit\AuthorGambit.php
432 \\vendor\flarum\core\src\Core\Search\AbstractRegexGambit.php
433 \\vendor\flarum\core\src\Core\Search\GambitInterface.php
434 \\vendor\flarum\core\src\Core\Search\Discussion\Gambit\CreatedGambit.php
435 \\vendor\flarum\core\src\Core\Search\Discussion\Gambit\HiddenGambit.php
436 \\vendor\flarum\core\src\Core\Search\Discussion\Gambit\UnreadGambit.php
437 \\vendor\flarum\flarum-ext-lock\src\Gambit\LockedGambit.php
438 \\vendor\flarum\flarum-ext-sticky\src\Gambit\StickyGambit.php
439 \\vendor\flarum\flarum-ext-subscriptions\src\Gambit\SubscriptionGambit.php
440 \\vendor\flarum\flarum-ext-tags\src\Gambit\TagGambit.php
441 \\vendor\flarum\flarum-ext-tags\src\TagRepository.php
442 \\vendor\flarum\core\src\Event\ConfigureDiscussionSearch.php
443 \\vendor\flarum\core\src\Core\Post\RegisteredTypesScope.php
444 \\vendor\illuminate\database\Eloquent\ScopeInterface.php
445 \\vendor\flarum\flarum-ext-tags\src\TagState.php
446 \\vendor\illuminate\database\Eloquent\Relations\HasOne.php
447 \\vendor\illuminate\database\Eloquent\Relations\HasOneOrMany.php
448 \\vendor\flarum\core\src\Core\DiscussionState.php
449 \\vendor\flarum\core\src\Core\Search\SearchResults.php
450 \\vendor\flarum\core\src\Event\PrepareApiData.php
451 \\vendor\flarum\core\src\Api\Serializer\DiscussionSerializer.php
452 \\vendor\flarum\core\src\Api\Serializer\DiscussionBasicSerializer.php
453 \\vendor\tobscure\json-api\src\Collection.php
454 \\vendor\tobscure\json-api\src\ElementInterface.php
455 \\vendor\tobscure\json-api\src\Resource.php
456 \\vendor\flarum\core\src\Api\JsonApiResponse.php
457 \\vendor\zendframework\zend-diactoros\src\Response\JsonResponse.php
458 \\vendor\zendframework\zend-diactoros\src\Response\InjectContentTypeTrait.php
459 \\vendor\flarum\core\src\Event\PrepareApiAttributes.php
460 \\vendor\tobscure\json-api\src\Util.php
461 \\vendor\flarum\core\src\Event\GetApiRelationship.php
462 \\vendor\tobscure\json-api\src\Relationship.php
463 \\vendor\flarum\core\src\Api\Serializer\PostBasicSerializer.php
464 \\vendor\flarum\flarum-ext-tags\src\Api\Serializer\TagSerializer.php
465 \\storage\formatter\Renderer_ae5f71c0360c13da41e2da639984171533ca7491.php
466 \\vendor\s9e\text-formatter\src\Renderer.php
467 \\vendor\flarum\core\src\Event\ConfigureFormatterRenderer.php
468 \\vendor\illuminate\view\View.php
469 \\vendor\illuminate\contracts\View\View.php
470 \\vendor\illuminate\contracts\Support\Renderable.php
471 \\vendor\illuminate\view\Engines\CompilerEngine.php
472 \\vendor\illuminate\view\Engines\PhpEngine.php
473 \\vendor\illuminate\view\Engines\EngineInterface.php
474 \\vendor\illuminate\view\Compilers\BladeCompiler.php
475 \\vendor\illuminate\view\Compilers\Compiler.php
476 \\vendor\illuminate\view\Compilers\CompilerInterface.php
477 \\vendor\flarum\core\src\Event\ConfigureClientView.php
478 \\vendor\flarum\core\src\Event\ConfigureWebApp.php
479 \\vendor\flarum\core\src\Api\Controller\ShowForumController.php
480 \\vendor\flarum\core\src\Api\Controller\AbstractResourceController.php
481 \\vendor\flarum\core\src\Api\Serializer\ForumSerializer.php
482 \\vendor\flarum\flarum-ext-flags\src\Flag.php
483 \\vendor\flarum\core\src\Api\Serializer\GroupSerializer.php
484 \\vendor\illuminate\database\Eloquent\Relations\HasMany.php
485 \\storage\views\219726d0017c7ae14a78c838d8c76498
486 \\storage\views\66278043d9e9bc7a5afec245afac553c
487 \\storage\views\d5d277da1868ee6e6474300b87b9b3fc
488 \\storage\views\5570885baf24def609bef9e8ae8a3a75
@tobyzerner

This comment has been minimized.

Copy link
Member

commented Sep 23, 2018

@franzliedke any ideas how we would defer inclusion of some of those files by composer, or whether it's even worth doing?

@luceos

This comment has been minimized.

Copy link
Member

commented Sep 24, 2018

Composer already only loads the files it needs. A few causes for this high amount:

  • Laravel being build on top of Symfony and thus for pretty much every Illuminate class needing a Symfony counterpart.
  • IoC always resolving classes needed by the loaded class, which causes a waterfall. But that is the intention.
  • Event driven and pipelines causing code to flow through all registered listeners and pipes.

As to lowering the amount. Laravel natively supports deferred service providers, causing the provider to be only loaded when any class in the provides array of the provider is needed. I'm not sure we support that, but applying it to the MailServiceProvider - for instance - would make sense.

@gooof

This comment has been minimized.

Copy link
Author

commented Sep 24, 2018

Solution for swiftmailer?

  1. Remove the __construct in \vendor\flarum\core\src\Core\Notification\NotificationMailer.php
  2. Remove the Mailer from __construct in \vendor\flarum\core\src\Core\Listener\EmailConfirmationMailer.php
    = -22 files (466 total (422 api))

@franzliedke franzliedke added this to the 0.1.0-beta.9 milestone Sep 24, 2018

@franzliedke

This comment has been minimized.

Copy link
Member

commented Sep 24, 2018

@gooof Thanks for raising this issue. I will have a look at this for the next beta release after the upcoming beta.8. Out of interest: a) how did you notice this, and b) what did you use to get the list of included files?

Re. service providers: At Laracon, I talked to Taylor about deferred service providers. He agreed they are mostly useless nowadays, and might be removed in a future release. (Memory savings - probably not, CPU cycle savings - meh.) They won't help much with this problem anyway: with well-written service providers, you will only avoid loading the service providers itself. Thanks to the IoC container, services that aren't needed for a request should not be instantiated, and thus not loaded.

What we see here is probably due to two things:
1.) some service providers instantiating services that aren't needed on every request, and
2.) the use of event subscribers such as this one - they need to be instantiated in order to register event listeners, which may instantiate other services (such as the mailer) that aren't needed very often.

Not very hard to fix, but we'll have to go through all service providers and extensions.

@gooof

This comment has been minimized.

Copy link
Author

commented Sep 24, 2018

@franzliedke I notice that the API need 0.2sec to load my 3 groups on localhost and that every page has the same response time. While finding out from what the slowness comes, I'll use get_included_files() before the output happens.
I also wrote a little debugger that show all sql queries, included files and times, so if a page is loading too long, I got a warning (to find (security) bugs).
~150 small included files normally = >0.05sec

A hack is using a own class that call a class only if its really called.
__construct(Mailer $mailer) -> $this->mailer = $mailer;
becomes: $this->mailer = $pseudo('mailer');
if someone called $this->mailer->send() the class check if "new mailer()" already loaded, if not he is include/loading it. Like this: https://github.com/marc1706/fast-image-size/pull/49/files

Extensions have a similar problem, in the bootstrap.php should be the event name defined where the class is required.
Or the subscribe() function should be in bootstrap.php. But I wait for 0.8 to test this.

@clarkwinkelmann

This comment has been minimized.

Copy link
Contributor

commented Dec 7, 2018

To add to the NotificationMailer case, I noticed that NotificationSyncer (which depends on the mailer) is included multiple times in listener constructors in core extensions (likes, suspend, ...) and are therefore unnecessarily loaded for every single request.

Most Laravel providers (including the mailer) already use singletons that should ideally never resolve if the feature isn't actually used. Right now it's not the case as email drivers are loaded for every request because of the above...

franzliedke added a commit that referenced this issue Dec 13, 2018

franzliedke added a commit that referenced this issue Dec 13, 2018

Inject dependencies when firing events, not before
The event subscriber approach means that dependencies have to be
injected (and thus instantiated, along with all *their* dependencies) at
the time of registering event listeners - even when events are never
fired within a request's lifecycle.

This is unnecessary and causes more classes than necessary to be loaded.

In this case, we can explicitly register event listeners that will
resolve their dependencies when the event is fired, not before.

Refs #1578.
@franzliedke franzliedke referenced this issue Dec 13, 2018
1 of 1 task complete

franzliedke added a commit that referenced this issue Dec 13, 2018

franzliedke added a commit to flarum/mentions that referenced this issue Dec 15, 2018

franzliedke added a commit to flarum/flags that referenced this issue Dec 15, 2018

franzliedke added a commit to flarum/likes that referenced this issue Dec 15, 2018

franzliedke added a commit to flarum/lock that referenced this issue Dec 15, 2018

franzliedke added a commit to flarum/pusher that referenced this issue Dec 15, 2018

franzliedke added a commit to flarum/subscriptions that referenced this issue Dec 16, 2018

franzliedke added a commit to flarum/suspend that referenced this issue Dec 16, 2018

franzliedke added a commit to flarum/tags that referenced this issue Dec 16, 2018

franzliedke added a commit to flarum/mentions that referenced this issue Dec 16, 2018

franzliedke added a commit to flarum/akismet that referenced this issue Dec 17, 2018

franzliedke added a commit to flarum/pusher that referenced this issue Dec 17, 2018

franzliedke added a commit that referenced this issue Dec 19, 2018

franzliedke added a commit that referenced this issue Dec 19, 2018

franzliedke added a commit that referenced this issue Dec 19, 2018

@franzliedke

This comment has been minimized.

Copy link
Member

commented Dec 31, 2018

@gooof Can I ask you to share your setup that got you the list of included files in your original post? I am asking so that I can get something reproducible to test my progress. 😃

@luceos luceos modified the milestones: 0.1.0-beta.9, 0.1.0-beta.10 Mar 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.