-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HTTP archive support project
Josh Matthews edited this page Sep 25, 2017
·
4 revisions
Background information: Major browsers support creating HTTP archive files which can be analyzed by other tools. Adding native support for this feature to Servo will allow us to compare our network performance more precisely against other browsers.
Tracking issue: https://github.com/servo/servo/issues/4004 (please ask questions here)
Initial steps:
- email the mozilla.dev.servo mailing list (be sure to subscribe to it first!) introducing your group and asking any necessary questions
- add the rust-har library as a dependency of the net_traits component
- define an enum that represents either a filename or an IpcSender that can send a vector of har::Log values
- using the new enum, add a new optional member to ResourceChannelManager that is initialized via create_resource_threads
- modify the CoreResourceMsg::Exit message to contain an optional vector of har::Page values
- add a command line flag that controls whether to store HAR data. The flag should accept a filename argument.
- using this new global option, pass an appropriate argument when calling
new_resource_threadsin create_constellation - when processing the CoreResourseMsg::Exit message, send an empty vector or write an empty vector as JSON to an appropriate file depending on the member variable that was added earlier
Subsequent steps:
- Store a vector of
har::Pagein Constellation- when a new pipeline is created (
Constellation::new_pipeline), add an entry to this vector using the pipeline ID as the page's unique id
- when a new pipeline is created (
- Store a vector of
har::Entryvalues in CoreResourceManager, wrapped insideArcandMutextypes to allow other threads to manipulate the vector- add a
Arc<Mutex<Vec<har::Entry>>>member to theFetchContextstructure, and initialize it from the resource manager's new field - in http_fetch, create a new
har::Requestinstance based on the values available from the request variable - before step 5 of
http_fetch, create a newhar::Responsevalue based on the values available from the response variable - create a new
har::Entryvalue and append it to the vector stored inFetchContext, using the request'spipeline_idfield as thepagerefvalue to associate it with the pages stored in theConstellation - during
Constellation::handle_shutdownas part of theCoreResourceMsg::Exitmessage send the vector ofhar::Pagevalues - when the resource thread receives this message (
CoreResourceManager::process_msg), if there is a vector present then combine the provided Page and member Entry values and process them according to the member variable (either sending them on the channel or writing them to a file)
- add a
-
add a unit test to ensure that the resource thread logs the HAR information correctly:
- create a resource manager with an IpcSender as the HAR output
- start an HTTP server and fetch a URL from it by sending a CoreResourceMsg::Fetch message to the resource manager
- Once the fetch is complete, send the exit message to the resource manager with a har::Page value for the single fetch (acting as the Constellation)
- assert that the expected har::Log value is received from the resource thread