Commit graph

71 commits

Author SHA1 Message Date
Oriol Brufau
ab2ba273e3 Simplify our setup for font metric queries from style
This is a backport of https://phabricator.services.mozilla.com/D157589,
by Emilio Cobos Álvarez, plus some additions so that Servo compiles,
and some parts from https://phabricator.services.mozilla.com/D144455.

Should have no change in behavior.
2023-05-11 21:02:15 +02:00
Josh Matthews
a7c87af9ca Update arrayvec. 2022-04-01 01:14:13 -04:00
Emilio Cobos Álvarez
ad61cae6b0 style: Update smallvec to 1.0.
Differential Revision: https://phabricator.services.mozilla.com/D56044
2019-12-16 14:23:56 +01:00
Bastien Orivel
28fa0f8009 Update rayon to dedupe crossbeam-epoch
As a bonus this also removes one version of crossbeam-utils
2019-07-12 21:01:33 +02:00
Cameron McCormack
3a22bb6c49 style: Add Gecko profiler labels for when the style threads are doing work.
Differential Revision: https://phabricator.services.mozilla.com/D30869
2019-05-29 16:14:06 +02:00
Simon Sapin
be69f9c3e6 Rustfmt has changed its default style :/ 2018-12-28 13:17:47 +01:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Simon Sapin
a15d33a10e cargo fix --edition 2018-11-10 17:47:28 +01:00
Bobby Holley
c99bcdd4b8 Run rustfmt on selectors, servo_arc, and style.
This was generated with:

./mach cargo fmt --package selectors &&
./mach cargo fmt --package servo_arc &&
./mach cargo fmt --package style

Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
2018-04-10 17:35:15 -07:00
Emilio Cobos Álvarez
13f61a6e5f
style: Indent properly a couple more functions. 2018-02-24 23:23:16 +01:00
Bobby Holley
f3abbb4ee3 Increase stack safety margin for stylo.
MozReview-Commit-ID: Fv9DttU20hM
2017-09-07 11:44:45 -07:00
Bobby Holley
b66111c428 Fix up stack limit sanity assertions.
MozReview-Commit-ID: ILblsins91P
2017-08-25 18:39:25 -07:00
Bobby Holley
707ab455bb Eliminate the sequential/traversal parallel distinction in favor of a unified adaptive driver.
MozReview-Commit-ID: ADVTNJntzmp
2017-08-25 10:00:27 -07:00
Bobby Holley
f7c6b2f04e Switch to an iterator for traverse_nodes.
We can't use a slice anymore, because the input might be the VecDeque from the
sequential traversal, which requires an iterator to handle the ring buffer.

MozReview-Commit-ID: JwH6MtRgMfY
2017-08-25 10:00:21 -07:00
Julian Seward
8b15347217 stylo: Drop thread pool stack size to 100K.
Reviewed in bug 1376883 by bholley.
2017-08-25 15:36:21 +02:00
Bobby Holley
f4ccbf3687 Hoist StyleNew{Children,Subtree} into their own paths.
The buggy animation handling isn't a regression, since currently we pass
UnstyledChildrenOnly in those cases, which blocks the animation traversal
in Servo_TraverseSubtree.

In general I really wanted to handle these two paths together. But there's
enough broken with the NewChildren path that I wanted to scope the buginess
as tightly as possible. And I really need to separate the handling here from
StyleDocument() to make the restyle root stuff work.

MozReview-Commit-ID: 9F0mcQl7AAX
2017-08-11 10:53:08 -07:00
Boris Zbarsky
2e02487526 Don't start kicking off work units during parallel stylo traversal until they're actually full.
This improves style sharing at the cost of a bit less parallelism.  Fixes Gecko
bug 1385982.  r=bholley
2017-08-01 15:59:31 -04:00
Bobby Holley
b7de96e702 Pass a callback to recalc_style_at to avoid traversing children twice.
MozReview-Commit-ID: DIHXaVNzbFM
2017-07-15 14:45:51 -07:00
Bobby Holley
2a58c0768b Avoid memmoving the large smallvec in Parallel.rs.
MozReview-Commit-ID: 7nzjMwOmszZ
2017-07-15 14:27:18 -07:00
Bobby Holley
3330653dc8 Rip out the generic abstractions around ThreadLocalStyleContext.
MozReview-Commit-ID: 5WTLuk323Ac
2017-07-05 16:37:17 -07:00
Julian Seward
4aa9829889 Bug 1368302 - stylo: possible stack overflow when processing very deep DOM. r=bholley.
Whilst working with variants of the bloom-basic test for Stylo perf
profiling, I noticed that it is easy to cause Firefox to segfault on DOMs
with a depth of more than about 1500 elements.  This fix limits the use of
tail recursion to 150 elements.  This isn't externally observable to content
-- we're still completely correct, just not using tail recursion any more.
2017-06-29 22:56:38 +02:00
Bobby Holley
fe7191568c Use ArrayVec and tweak the SmallVec sizes.
MozReview-Commit-ID: 1tEZiPdp9WQ
2017-06-14 22:50:44 -07:00
Bobby Holley
c6d0ef5e9f Eliminate an unnecessary heap allocation.
MozReview-Commit-ID: 4cleAH0JsKK
2017-06-14 22:50:39 -07:00
Bobby Holley
f04c25c33c Don't do recursive tail calls if there's work in the queue.
MozReview-Commit-ID: 8JEdjqAIYmQ
2017-06-14 22:50:33 -07:00
Cameron McCormack
c533097e20 style: Distinguish between the tree structures used for traversal and selector matching.
This patch renames TNode::parent_element to traversal_parent, since it returns
the parent from the perspective of traversal (which in Gecko uses the
flattened tree).  It also renames TNode::children to traversal_children
for the saem reason.

We keep parent_element and children functions on TNode to use for selector
matching, which must be done on the real DOM tree structure.
2017-06-09 18:37:35 +08:00
Boris Zbarsky
2f2b93c521 Increase the size of the style sharing cache to 31.
Still a lot of guesswork here, but this does seem to get us better sharing.  See
https://bugzilla.mozilla.org/show_bug.cgi?id=1369621 for some data.
2017-06-08 14:14:44 -04:00
Boris Zbarsky
93271e199b Reduce the size of top_down_dom stackframes.
The idea is to put the memmoving of the ThreadLocalContext out of line from the point of view of top_down_dom so we don't need to allocate a large chunk of stack space for it.
2017-06-08 13:02:36 -04:00
Boris Zbarsky
3d3ce51797 Back out https://github.com/servo/servo/pull/17198 for Gecko test failures 2017-06-07 15:57:48 -04:00
Boris Zbarsky
21eafaa9f8 Increase the size of the style sharing cache to 31.
Still a lot of guesswork here, but this does seem to get us better sharing.  See
https://bugzilla.mozilla.org/show_bug.cgi?id=1369621 for some data.
2017-06-06 22:34:46 -04:00
Bobby Holley
a182ae46f6 Rewrite parallel.rs to be not slow. 2017-05-21 07:45:39 +02:00
Bobby Holley
591733408d Limit traversal statistics dumps to subtrees of 50 or more elements.
On Gecko, we get tons of console spam from 1-element traversals if we
don't do this.
2017-04-13 13:41:52 +08:00
Bobby Holley
dc5dbd5542 Store style system options in the global style data and shared style context.
I wanted to add an environmental variable to disable the style sharing
cache for gecko, but the current pattern involves lazy_static!, which
involves an atomic operation on lookup, which is a bit hot to do each
time we try to share styles. This makes that work happen once per
process.
2017-04-12 14:34:42 +08:00
Bobby Holley
3f52052cf9 Do the sequential traversal breadth-first.
While we're at it, we also eliminate the 'unknown' dom depth for the
bloom filter. Computing depth has negligible cost relative to the
amount of work we do setting up the bloom filter at a given depth.
Doing it once per traversal should be totally fine.

I originally separated the elimination of unknown dom depth from the
traversal changes, but I got bloom filter crashes on the intermediate
patch, presumably because I didn't properly fix the sequential traversal
for this case. Given that the final state is green, I just decided to
squash and move on.
2017-04-09 14:52:49 +08:00
Bobby Holley
1b363ac909 Factor out the bottom-up postorder traversal logic. 2017-04-09 12:35:58 +08:00
Emilio Cobos Álvarez
58c6aad1f0
style: Add the traversal kind to the style stats. 2017-03-11 11:31:11 +01:00
Bobby Holley
d7d6979144 Dump traversal time with other style statistics. 2017-02-14 17:17:45 -08:00
Bobby Holley
37b8d5231d Bug 1336646 - Move opts check for statistics into should_dump. r=emilio
This makes things more consistent between the parallel and sequential traversal drivers.
2017-02-08 17:09:41 -08:00
Emilio Cobos Álvarez
f00b628c3a
style: Expose the traversal kind to the style system.
This way we'll be able to take different paths for the sequential and parallel
traversals in some concrete cases.

This is a preliminar patch to fix bug 1332525.
2017-01-24 08:41:29 +01:00
Bobby Holley
5370224877 Bug 1331856 - Add style performance statistics to Servo. r=emilio
MozReview-Commit-ID: ECHZgYNA8nb
2017-01-19 15:05:19 -08:00
Bobby Holley
92b9d70c3a Bug 1325734 - Pass the thread-local context into should_traverse_children. r=emilio 2017-01-09 11:51:37 -08:00
Bobby Holley
3060865577 Bug 1325734 - Parameterize the style traversal on TElement instead of TNode. r=emilio
This works around the issue described in https://github.com/rust-lang/rust/issues/38917
2017-01-09 11:51:36 -08:00
Emilio Cobos Álvarez
e03ef33f58
style: Document the parallel traversal. 2016-12-31 12:17:10 +01:00
Bobby Holley
ea6a61af59 Stop using UnsafeNode in the parallel traversal.
\o/ \o/ \o/
2016-12-22 10:42:53 -08:00
Bobby Holley
c5f01fe3b8 Introduce and use Scoped TLS.
It turns out that it's problematic to embed ThreadLocalStyleContext within
LayoutContext, because parameterizing the former on TElement (which we do
in the next patch) infects all the traversal stuff with the trait parameters,
which we don't really want.

In general, it probably makes sense to use separate scoped TLS types for
the separate DOM and Flow tree passes, so we can add a different ScopedTLS
type for the Flow pass if we ever need it.

We also reorder the |scope| and |shared| parameters in parallel.rs, because
it aligns more with the order in style/parallel.rs. I did this when I was
adding a TLS parameter to all these functions, which I realized we don't need
for now.
2016-12-21 11:10:39 -08:00
Bobby Holley
648ce1e44e Make the DomTraversalContext own the SharedStyleContext and share it immutably across the traversal.
This allows us to get rid of a bunch of lifetimes and simplify a lot of code. It
also lets us get rid of that nasty lifetime transmute, which is awesome.

The situation with thread-local contexts is still suboptimal, but we fix that in
subsequent patches.
2016-12-16 10:57:27 -08:00
Alan Jeffrey
9be4fd56ce Removed util. 2016-12-14 18:04:37 -06:00
Bobby Holley
3a56954069 Bug 1322945 - Change skip_root to unstyled_children_only and use StyleNewChildren in more places. r=heycam
I noticed that our current behavior in ContentRangeInserted is incorrect. Unlike
ContentInserted (where this code lived originally), ContentRangeInserted takes a
start and end element. I'm not sure if we ever take that path for new content that
needs style, but it seemed sketchy. And generally, it seems nice to just always
style new content the same way (though we still need to style NAC by the subtree
root, since it hasn't been attached to the parent yet).

For situations where there is indeed only one unstyled child, the traversal
overhead should be neglible, since we special-case the single-element in
parallel.rs to avoid calling into rayon.

Being more explicit about what we want here also makes us more robust against
the other handful of callpaths that can take us into
nsCSSFrameConstructor::{ContentRangeInserted,ContentAppended}. Currently we
can call StyleNewSubtree on an already-styled element via RecreateFramesForContent,
which triggers an assertion in the servo traversal.

MozReview-Commit-ID: DqCGh90deHH
2016-12-12 18:50:33 -08:00
Bobby Holley
80460cc549 Make Restyle tracking more granular.
The primary idea of this patch is to ditch the rigid enum of Previous/Current
styles, and replace it with a series of indicators for the various types of
work that needs to be performed (expanding snapshots, rematching, recascading,
and damage processing). This loses us a little bit of sanity checking (since
the up-to-date-ness of our style is no longer baked into the type system), but
gives us a lot more flexibility that we'll need going forward (especially when
we separate matching from cascading). We also eliminate get_styling_mode in
favor of a method on the traversal.

This patch does a few other things as ridealongs:
* Temporarily eliminates the handling for transfering ownership of styles to the
  frame. We'll need this again at some point, but for now it's causing too much
  complexity for a half-implemented feature.
* Ditches TRestyleDamage, which is no longer necessary post-crate-merge, and is
  a constant source of compilation failures from either needing to be imported
  or being unnecessarily imported (which varies between gecko and servo).
* Expands Snapshots for the traversal root, which was missing before.
* Fixes up the skip_root stuff to avoid visiting the skipped root.
* Unifies parallel traversal and avoids spawning for a single work item.
* Adds an explicit pre_traverse step do any pre-processing and determine whether
  we need to traverse at all.

MozReview-Commit-ID: IKhLAkAigXE
2016-12-09 14:46:40 -10:00
Emilio Cobos Álvarez
de1a3d879f
style: Enable the bloom filter recovering. 2016-11-27 15:55:10 +01:00
Emilio Cobos Álvarez
84a50ed5cb
style: Introduce StyleBloom
The idea is this will fix the bad behavior of the bloom filter in parallel
traversal.
2016-11-27 15:55:10 +01:00