Remove monitoring Network.dataReceived to optimise performance - #486
Open
vbanos wants to merge 1 commit into
Open
Remove monitoring Network.dataReceived to optimise performance#486vbanos wants to merge 1 commit into
vbanos wants to merge 1 commit into
Conversation
The more methods we monitor on `_handle_message`, the slower we are. We monitor `Network.dataReceived` to update `self.last_network_activity`. We also monitor so many `Network` and `Page` events that cover all aspects of requests' lifecycle. We could drop `Network.dataReceived` and miss very little `self.last_network_activity` accuracy. According to ChatGTP, when we capture a typical page we have the following number of events: ``` | CDP method | When triggered | Typical frequency per page load | | ------------------------------------ | -------------------------------- | ------------------------------: | | `Network.requestWillBeSent` | Every outgoing HTTP request | **50–500+ times** | | `Network.responseReceived` | Every response header received | **50–500+ times** | | `Network.dataReceived` | Every response data chunk | **100–10,000+ times** | | `Network.loadingFinished` | Every completed request | **50–500+ times** | | `Network.loadingFailed` | Failed requests | **0–20 times** | | `Page.loadEventFired` | Browser `load` event | **1 time** | | `Console.messageAdded` | JS console output | **0–1000+ times** | | `Runtime.exceptionThrown` | Uncaught JS exceptions | **0–100s** | | `Page.javascriptDialogOpening` | alert/confirm/prompt | **0–few** | | `ServiceWorker.workerVersionUpdated` | Service worker lifecycle changes | **0–few** | | `Inspector.targetCrashed` | Chrome renderer crash | **0 normally** | | `Page.interstitialShown` | HTTP auth/captive portal/etc. | **0 normally** | ``` `Network.dataReceived` is the most frequent method.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The more methods we monitor on
_handle_message, the slower we are. We monitorNetwork.dataReceivedto updateself.last_network_activity.We also monitor so many
NetworkandPageevents that cover all aspects of requests' lifecycle. We could dropNetwork.dataReceivedand miss very littleself.last_network_activityaccuracy.According to ChatGTP, when we capture a typical page we have the following number of events:
Network.dataReceivedis the most frequent method.