[go: nahoru, domu]

tree: 4d6fbd58ca3c8dd37227249658f5e647b2e6de4b [path history] [tgz]
  1. decorators/
  2. doc/
  3. embedder/
  4. execution_context/
  5. execution_context_priority/
  6. freezing/
  7. graph/
  8. metrics/
  9. persistence/
  10. power/
  11. public/
  12. resource_attribution/
  13. test_support/
  14. user_tuning/
  15. v8_memory/
  16. binders.cc
  17. browser_child_process_host_proxy.cc
  18. browser_child_process_watcher.cc
  19. browser_child_process_watcher.h
  20. BUILD.gn
  21. COMMON_METADATA
  22. DEPS
  23. DIR_METADATA
  24. features.cc
  25. frame_node_source.h
  26. graph_features.cc
  27. graph_features_unittest.cc
  28. owned_objects.h
  29. owned_objects_unittest.cc
  30. OWNERS
  31. performance_manager.cc
  32. performance_manager_browsertest.cc
  33. performance_manager_feature_observer_client.cc
  34. performance_manager_feature_observer_client.h
  35. performance_manager_impl.cc
  36. performance_manager_impl.h
  37. performance_manager_impl_unittest.cc
  38. performance_manager_lifetime.cc
  39. performance_manager_registry.cc
  40. performance_manager_registry_impl.cc
  41. performance_manager_registry_impl.h
  42. performance_manager_registry_impl_unittest.cc
  43. performance_manager_tab_helper.cc
  44. performance_manager_tab_helper.h
  45. performance_manager_tab_helper_unittest.cc
  46. performance_manager_unittest.cc
  47. prerendering_browsertest.cc
  48. process_node_source.cc
  49. process_node_source.h
  50. README.md
  51. registered_objects.h
  52. registered_objects_unittest.cc
  53. render_frame_host_proxy.cc
  54. render_process_host_id_unittest.cc
  55. render_process_host_proxy.cc
  56. render_process_host_proxy_browsertest.cc
  57. render_process_user_data.cc
  58. render_process_user_data.h
  59. service_worker_context_adapter.cc
  60. service_worker_context_adapter.h
  61. tab_helper_frame_node_source.cc
  62. tab_helper_frame_node_source.h
  63. voting_unittest.cc
  64. web_contents_proxy.cc
  65. web_contents_proxy_impl.cc
  66. web_contents_proxy_impl.h
  67. web_contents_proxy_unittest.cc
  68. worker_watcher.cc
  69. worker_watcher.h
  70. worker_watcher_unittest.cc
components/performance_manager/README.md

Performance Manager Overview

Overview

The Performance Manager supports data-driven, centralized resource management, prioritization and planning for the Chrome browser. Over time, data-driven, centralized resource management will supplant and/or supplement the heuristics that can be found all over Chrome at present.

Here’s an overview picture of the intended architecture:

Overview Image

  • The Embedder is responsible for notifying the Performance Manager Registry when content entities are created or their relationships change. The Performance Manager Registry maintains the structure of the Graph, which is a coarsely abstracted view of the state of the browser.
  • Decorators populate the graph nodes with interesting properties and data, such as e.g. the results of CPU, memory and battery measurements and so on.
  • Aggregators aggregate data in the graph, possibly across nodes. As an example, the memory usage of all frame nodes could be summed up to their associated page node, to establish the total memory usage of the page.
  • Resource Management Policies are observers of the graph, and use the graph structure as well as the properties of graph nodes to make policy decisions.
  • Resource Management Mechanisms are invoked by Resource Management Policy to implement policy decisions. Note that while the mechanisms are depicted in the main thread, they can be hosted anywhere necessary or convenient, such as in a renderer process at the far end of a mojo::Remote<>.
  • Content Proxies are a convenience feature to allow easy and safe access from nodes in the graph to the corresponding content entity for any task that needs to run on the main thread.

The graph lives on the Performance Manager Sequence, as do all graph observers and mutators. The graph structure can be viewed in the graph tab of the chrome://discards WebUI.

In addition to the above, the Performance Manager also provides support for users that need to occasionally query the graph to e.g. collect metrics.

Details

Graph

The performance manager exposes a simplified, coarse model of the browser’s state as a Graph of Nodes, where the nodes represent such things as:

  1. Page: corresponds to a content::WebContents.
  2. Frame: corresponds to a frame in a content::WebContents frame tree.
  3. Process: corresponds to a content::RenderProcessHost or other type of process, such as e.g. the Browser or GPU process.
  4. Worker: corresponds to a web worker.

Nodes in the graph are connected with edges, such that e.g. each frame or worker connects to its hosting process. Frames are connected in a tree, and all frames in a tree connect to their corresponding page. Other edge types may denote dependencies between nodes, such as e.g. a MessagePort connection or the like. Different node types in the graph are adorned with different sets of properties, each of which represents necessary information about the particular node type. The graph provides node lookup and retrieval, as well as an observer interface for notification of addition and removal of nodes, as well as node property changes. The graph also provides a way for users to adorn nodes with private data by means of Node Attached Data. It’s preferable to store data that’s used for intermediate results or for private purposes in Node Attached Data rather than in Node properties.

Public & Private APIs.

The graph exposes both a public and a private API. The private API is only available to code in the component’s directory, whereas the public API can be used by anyone in the browser process. The private API provides read-write access to nodes and allows for node-intimate storage of node attached properties. The public API provides read-only access to nodes, but otherwise the two APIs are fairly similar. Where possible, using the public API is preferable, as the public API is more stable, and doesn’t require the user to live in the component.

Good examples where the public API is appropriate, is e.g. for periodically collecting metrics by iteration over the graph, or where iterating over the graph can yield a set of content entities for some operation. As an example, finding the set of frames in a page that belong to the same browsing instance would be easy to do by iterating over the graph.

Decorators

Decorators set properties on the graph that are derived from data external to the graph itself, such as e.g. performance measurement data.

A simple example Decorator might periodically measure the cumulative CPU usage for each process Node in the Graph and adorn each node with the measured cumulative CPU usage of the corresponding process.

Decorators can make data available to consumers by updating core properties of a node or by exposing their own custom API. A common interface is to provide an associated Data class, with a static accessor to retrieve a Data object from a given Node. See PageLiveStateDecorator::Data for an example.

Observers

Each node type provides an observer interface that callers can implement to receive notifications when core node properties change. Data that is exposed through a decorator or Node Attached Data may or may not provide change notifications depending on the details of the decorator's API.

Aggregators

Aggregators, like Decorators, set properties on the graph nodes. The difference is that Aggregators work solely on data in the graph, to e.g. aggregate or distribute data from one node to another.

A simple example Aggregator working with the simple example Decorator above might compute the difference in cumulative CPU usage from the most recent measurement, then distribute the difference across the Frame (and/or Worker) nodes associated with each Process. This would in turn allow summing up the cumulative CPU usage of each Frame and Worker node to their associated Page node. This would yield the CPU usage of the entire Page (content::WebContents).

Policies & Mechanisms

The intent is for all Resource Management Policies to use the graph and the data therein to make policy decisions. The decisions are then implemented by invoking some kind of Resource Management Mechanism. Making this a clean distinction makes the implementation easier, more readable and more testable.

A simple example of a policy and a mechanism might be a policy for flushing some kind of a cache after all frames in a process have been backgrounded or idle for a set amount of time. This policy would register for the appropriate notifications and likely maintain private state on a process node. When the criteria for flushing is met, the policy invokes the mechanism by rendezvousing to a process-associated mojo interface and invoking on it.

If the mojo interface is accessible through a content entity (e.g. content::WebContents), the mechanism invocation is posted to the main thread where the relevant content proxy (e.g. performance_manager::WebContentsProxy) makes it easy and safe to retrieve the content entity on the main thread. Should the corresponding content entity have been deleted after the task was posted, the content proxy will simply return nullptr.