Polaris: Faster Page Loads Using Fine-grained Dependency Tracking

Ravi Netravali, Ameesh Goyal, James Mickens, Hari BalakrishnanNSDI 2016 · OpenReview

TL;DR

This paper introduces Polaris, a novel client-side JavaScript scheduler that significantly speeds up web page loading by accurately tracking fine-grained dependencies between page elements. By overcoming the limitations of traditional, coarse-grained dependency analysis, Polaris achieves median page load time reductions of 34% and 95th percentile reductions of 59%.

What Problem Does This Paper Address?

Modern web pages are complex compositions of HTML, CSS, JavaScript, and various media. Browsers must fetch and evaluate these components in a specific order to ensure correct rendering and functionality. This order is dictated by a "dependency graph," where edges represent "load-before" relationships. However, traditional browsers and existing optimization techniques rely on coarse-grained, lexical dependencies derived from HTML tag order. This approach is often too conservative, as it cannot see the true semantic dependencies (e.g., JavaScript code reading a DOM element's style). This leads to underutilization of network and CPU resources, resulting in slower page load times. The core problem is the inability of current systems to accurately capture and leverage the fine-grained, dynamic dependencies that govern how web page components truly interact.

Methods

The paper introduces two main contributions:

  • Scout: A new measurement infrastructure that automatically tracks fine-grained data flows across the JavaScript heap and the DOM. Scout instruments web pages by rewriting JavaScript and HTML to log precise data flows. This allows for the generation of much more accurate dependency graphs than previously possible. Scout identifies three key types of dependencies:
  • Write/read dependencies: When one object produces state that another consumes.
  • Read/write dependencies: When an object needs to read a state before it's updated by another.
  • Write/write dependencies: When multiple objects update the same piece of state, requiring preservation of write order.
  • Polaris: A dynamic, client-side scheduler implemented in JavaScript. Polaris takes the fine-grained dependency graph generated by Scout and combines it with real-time network condition observations to determine the dynamic critical path (the path with the most unresolved objects at any given moment). It then aggressively fetches and evaluates objects along this path, prioritizing those that unblock the most downstream dependencies. Polaris runs on unmodified browsers and works by having servers return a "scheduler stub" containing the Polaris JavaScript library, the Scout graph, and the original HTML.

Datasets

The paper evaluates its approach using a corpus of 200 popular web pages collected from the Alexa Top 500 list. These pages were recorded using Mahimahi and then processed to create Polaris-enabled versions. The authors specifically selected pages that did not use eval() or with() JavaScript statements, as their prototype Scout implementation did not fully support these.

Key Insights and Ideas

  • Lexical dependencies are insufficient: The paper strongly demonstrates that relying solely on HTML tag order for dependency tracking misses a significant number of crucial relationships, leading to suboptimal scheduling.
  • Fine-grained tracking unlocks aggressive scheduling: By accurately capturing semantic dependencies, Polaris can break free from conservative assumptions and fetch/evaluate objects much more aggressively, leading to substantial performance gains.
  • Dynamic critical path is key: Polaris's ability to adapt to real-time network conditions and identify the dynamic critical path, rather than just a static one, is crucial for maximizing performance.
  • Client-side scheduling is feasible and effective: Implementing Polaris as a JavaScript library allows it to run on any browser without modification, making it widely applicable.

Key Results

  • Scout detects significantly more edges in dependency graphs: 30% more at the median and 118% more at the 95th percentile compared to traditional approaches.
  • Polaris reduces page load times by 34% at the median and 59% at the 95th percentile across the tested corpus.
  • Polaris's benefits increase with network latency, making it particularly valuable for users on slower or mobile networks.
  • Even with warm caches, Polaris still provides significant benefits, especially when critical path objects are not cached.
  • Polaris's performance gains are complementary to protocols like SPDY, suggesting that fine-grained dependency information is a fundamental bottleneck that SPDY alone cannot fully address.

Limitations and Future Work

  • JavaScript eval() and with() statements: The current implementation of Scout does not fully support these JavaScript features, limiting the set of pages that can be analyzed. The authors suggest that Scout could be extended to handle these by rewriting the source code passed to eval() and by shimming with().
  • Time-to-first-paint: In some cases, Polaris's chunked HTML rendering can lead to a slightly slower initial paint compared to native browser schedulers, although it quickly overtakes them for overall load time. Future work aims to address this by rendering HTML in smaller increments.
  • Server-side cooperation: While Polaris is client-side, the paper briefly touches on how servers could potentially use Scout graphs for push policies, but argues that client-side control is superior for dynamic critical path optimization.
  • Nondeterministic dependencies: The paper acknowledges that pages with nondeterministic JavaScript behavior could pose challenges. Scout aims to handle this by creating aggregate graphs that encompass all possible dependencies, though this might overconstrain scheduling.

Summary updated

BibTeX
@inproceedings{netravali2016polaris,
  author = {Ravi Netravali and Ameesh Goyal and James Mickens and Hari Balakrishnan},
  title = {{Polaris: Faster Page Loads Using Fine-grained Dependency Tracking}},
  booktitle = {NSDI},
  year = {2016},
  url = {https://openreview.net/forum?id=DKJNaMNJvT},
}

Loading related content...

Figure