servo: Merge #19432 - style: Bail out from invalidation if we're the root and got tons of descendant invalidations (from emilio:invalidation-bail); r=heycam a=gchang
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 30 Nov 2017 05:30:01 -0600
changeset 445133 0319dd2d58a9161baceb8d91e023573f4d40c279
parent 445132 9b41fc04fab1a5f5670a324fd48ec03ccc0c6e24
child 445134 aded8e18768e3763243e38d948951e335ac6318c
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam, gchang
milestone58.0
servo: Merge #19432 - style: Bail out from invalidation if we're the root and got tons of descendant invalidations (from emilio:invalidation-bail); r=heycam a=gchang Bug: 1420741 Reviewed-by: heycam MozReview-Commit-ID: 4Kja20Ep9qD Source-Repo: https://github.com/servo/servo Source-Revision: e4d5e9699b9e784e5eba0aec316a35d048786052
servo/components/style/invalidation/element/collector.rs
--- a/servo/components/style/invalidation/element/collector.rs
+++ b/servo/components/style/invalidation/element/collector.rs
@@ -209,16 +209,27 @@ where
                 stylist.each_invalidation_map(|invalidation_map, _| {
                     collector.collect_dependencies_in_invalidation_map(invalidation_map);
                 })
             }
 
             collector.invalidates_self
         };
 
+        // If we generated a ton of descendant invalidations, it's probably not
+        // worth to go ahead and try to process them.
+        //
+        // Just restyle the descendants directly.
+        //
+        // This number is completely made-up, but the page that made us add this
+        // code generated 1960+ invalidations (bug 1420741).
+        if descendant_invalidations.len() > 150 {
+            self.data.hint.insert(RestyleHint::RESTYLE_DESCENDANTS);
+        }
+
         if invalidated_self {
             self.data.hint.insert(RestyleHint::RESTYLE_SELF);
         }
 
         invalidated_self
     }
 
     fn should_process_descendants(&mut self, element: E) -> bool {