Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upstyle: Don't loop over all the set of dependencies always. #13108
Conversation
highfive
commented
Aug 29, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Aug 29, 2016
|
r? @SimonSapin or @bholley |
|
@bors-servo: try |
style: Don't loop over all the set of dependencies always. <!-- Please describe your changes on the following line: --> Instead, divide which kind of dependencies could match a mutation. This cuts down incremental restyle time in BrowserHTML quite a bit. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [x] There are tests for these changes OR <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> The dependency count is not at all minor, and this way we avoid looping through all of them in the common cases, mainly either changing state, or attributes.
| @@ -341,16 +341,38 @@ struct Dependency { | |||
| #[derive(Debug)] | |||
| #[cfg_attr(feature = "servo", derive(HeapSizeOf))] | |||
| pub struct DependencySet { | |||
This comment has been minimized.
This comment has been minimized.
bholley
Aug 29, 2016
Contributor
Please add a comment above this struct that there are measurable performances wins from storing these separately.
| } | ||
| } | ||
|
|
||
| if !state_changes.is_empty() { |
This comment has been minimized.
This comment has been minimized.
bholley
Aug 29, 2016
Contributor
Rather than doing this in three places here, I think this should be abstracted into a method on DependencySet.
| } | ||
| } | ||
|
|
||
| impl DependencySet { | ||
| fn test_dependency<E>(&self, |
This comment has been minimized.
This comment has been minimized.
bholley
Aug 29, 2016
Contributor
This doesn't really make sense as a Dep on DependencySet. Can we impl it as a method on Vec, or does rust not let us do that? If not, I guess best would be to make it a non-method helper function.
|
Nice find! Looks good in general, though I'd like to look at the result of the refactor. |
|
|
| @@ -330,27 +337,52 @@ impl Sensitivities { | |||
| /// This allows us to quickly scan through the dependency sites of all style | |||
| /// rules and determine the maximum effect that a given state or attribute | |||
| /// change may have on the style of elements in the document. | |||
| /// | |||
| /// Note that there are measurable perf wins from storing them separately, and | |||
This comment has been minimized.
This comment has been minimized.
bholley
Aug 29, 2016
Contributor
I don't think the meaning of "storing them separately" is clear in this context.
This comment has been minimized.
This comment has been minimized.
bholley
Aug 29, 2016
Contributor
Would probably be better to move this into the comment on DependencySet, and say "storing attribute and state dependencies separately".
| } | ||
| } | ||
|
|
||
| fn test_dependencies<E>(deps: &[Dependency], |
This comment has been minimized.
This comment has been minimized.
bholley
Aug 29, 2016
Contributor
Hm, the free-floating function is still kind of annoying. Could we make a newtype:
struct DependencyList(Vec)
Inside DependencySet and then impl that?
This comment has been minimized.
This comment has been minimized.
bholley
Aug 29, 2016
Contributor
Also, given that we're now storing restyle hints instead of combinators, maybe "test" isn't quite the right word anymore for the operations on DependencyList. Maybe we should call it compute_partial_hint or collect_hints?
| } | ||
| } | ||
| if hint.is_all() { |
This comment has been minimized.
This comment has been minimized.
bholley
Aug 29, 2016
Contributor
Nit: Seems like this should go inside the branch where we actually modify hint, right?
This comment has been minimized.
This comment has been minimized.
| attrs_changed: bool, | ||
| hint: &mut RestyleHint) | ||
| where E: ElementExt | ||
| { |
This comment has been minimized.
This comment has been minimized.
bholley
Aug 29, 2016
Contributor
It seems cleaner to check hint.is_all() here and early-return, and then not check it in the callers.
|
r=me with those fixes. @bors-servo delegate+ |
|
|
The dependency count is not at all minor, and this way we avoid looping through all of them in the common cases, mainly either changing state, or attributes.
|
@bors-servo: r=bholley |
|
|
style: Don't loop over all the set of dependencies always. <!-- Please describe your changes on the following line: --> Instead, divide which kind of dependencies could match a mutation. This cuts down incremental restyle time in BrowserHTML quite a bit. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [x] There are tests for these changes OR <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> The dependency count is not at all minor, and this way we avoid looping through all of them in the common cases, mainly either changing state, or attributes. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13108) <!-- Reviewable:end -->
|
|
I'm stupid, and when I did the last moving-the-code-around, I failed miserably to double-check it in a debug build.
Fix debug assertion introduced in #13108 by me. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13125 (github issue number if applicable). <!-- Either: --> - [x] These changes do not require tests because #13127 <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> I'm stupid, and when I did the last moving-the-code-around, I failed miserably to double-check it in a debug build. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13128) <!-- Reviewable:end -->
I'm stupid, and when I did the last moving-the-code-around, I failed miserably to double-check it in a debug build.
emilio commentedAug 29, 2016
•
edited by larsbergstrom
Instead, divide which kind of dependencies could match a mutation. This cuts down incremental restyle time in BrowserHTML quite a bit.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThe dependency count is not at all minor, and this way we avoid looping
through all of them in the common cases, mainly either changing state, or
attributes.
This change is