-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Do not use proxy-decorators and event listeners when debug is skipped #277
Comments
👍 That would definitely be great for performance.
I'd prevent subscribing in this case if possible. |
Checked current implementation. Am I right in my research, @xepozz? What are your thoughts? EventsCurrently event subscription is done via configs:
Despite collectors are event listeners, they aren't doing anything when If we want to completely skip calling listeners, own implementation of Disadvantage of such approach is that it requires event dispatcher to always use composite provider. Disabling proxiesAs for proxies, can we make |
EventsYou're almost right. When a new request starts the application middleware stack, it's being checked by the ProxiesIn long-running applications such as RoadRunner, etc., the container state within any related and resolved services does not change from request to request. So pushing a "debug" logger/event dispatcher into a user service may be stuck until a full application restart (= web server/worker restart), which is totally not a good idea. We can add skipping logic into proxies, so then the "debug" logger can skip any proxy functionality and call directly the decorated object. Like the following: public function __call($method, $params) {
if ($this->disabled) {
$this->decorated->$method(...$params);
}
$this->$method(...$params);
} But these checks must be added to each decorated function. And one more thing: going deeper, the logger/event dispatcher may be stuck in a not decorated state, so any debugger's run will skip calling the "debug" correspondent classes => we must register "debug" proxies at all times even if the debugger did not activate the debug session. |
So no need to do anything about events for release. As for proxies... yes, seems we have to add "disabled" to all of them... |
I'll try to figure it out |
There are a few checks that disable data collecting:
yii-debug/src/Debugger.php
Line 43 in cd4fe68
yii-debug/src/Debugger.php
Line 48 in cd4fe68
But they do not unwrap proxied classes, like
\Yiisoft\Yii\Debug\Collector\LoggerInterfaceProxy
or any other.Also they do not unsubscribe from event-dispatcher.
It may negatively impact performance.
An idea to control if data collecting is skipped:
*InterfaceProxy
classes*InterfaceProxy
must expose decorated class$proxy->getDecorated()->$method($args)
directly$proxy->$method($args)
Or add check
is data collecting is skipped
to each public method of proxy classesThe text was updated successfully, but these errors were encountered: