servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
use cssparser::{Parser, SourcePosition};
|
|
|
|
use rayon;
|
|
|
|
use servo_url::ServoUrl;
|
2017-04-28 06:32:24 +03:00
|
|
|
use style::context::QuirksMode;
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
use style::error_reporting::ParseErrorReporter;
|
|
|
|
use style::media_queries::MediaList;
|
2017-03-17 00:48:53 +03:00
|
|
|
use style::properties::{longhands, Importance, PropertyDeclaration, PropertyDeclarationBlock};
|
2017-01-31 01:54:26 +03:00
|
|
|
use style::rule_tree::{CascadeLevel, RuleTree, StrongRuleNode, StyleSource};
|
servo: Merge #16014 - Per-process lock for CSSOM objects (from servo:style-ref); r=emilio
<!-- Please describe your changes on the following line: -->
Before this PR, every object reflected in CSSOM is in `Arc<RwLock<_>>` to enable safe (synchronized) mutable aliasing. Acquiring all these locks has significant cost during selector matching:
* https://bugzilla.mozilla.org/show_bug.cgi?id=1311469
* https://bugzilla.mozilla.org/show_bug.cgi?id=1335941
* https://bugzilla.mozilla.org/show_bug.cgi?id=1339703
This PR introduce a mechanism to protect many objects with the same `RwLock` that only needs to be acquired once.
In Stylo, there is one such lock per process (in a `lazy_static`), used for everything.
I non-Stylo Servo, I originally intended to have one such lock per document (for author-origin stylesheets, and one per process for user-agent and user sytlesheets since they’re shared across documents, and never mutated anyway). However I failed to have the same document-specific (or pipeline-specific) `Arc` reachable from both `Document` nodes and `LayoutThread`. Recursively following callers lead me to include this `Arc` in `UnprivilegedPipelineContent`, but that needs to be serializable. So there is a second process-wide lock.
This was previously #15998, closed accidentally.
---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: bb54f0a429de0e8b8861f8071b6cf82f73622664
--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 851230e57ac8775707df5f0f103be5feac81fc41
2017-03-20 00:31:19 +03:00
|
|
|
use style::shared_lock::SharedRwLock;
|
2017-05-03 04:01:10 +03:00
|
|
|
use style::stylearc::Arc;
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
use style::stylesheets::{Origin, Stylesheet, CssRule};
|
|
|
|
use test::{self, Bencher};
|
|
|
|
|
|
|
|
struct ErrorringErrorReporter;
|
|
|
|
impl ParseErrorReporter for ErrorringErrorReporter {
|
2017-04-14 04:12:08 +03:00
|
|
|
fn report_error(&self,
|
|
|
|
input: &mut Parser,
|
|
|
|
position: SourcePosition,
|
|
|
|
message: &str,
|
|
|
|
url: &ServoUrl,
|
|
|
|
line_number_offset: u64) {
|
|
|
|
let location = input.source_location(position);
|
|
|
|
let line_offset = location.line + line_number_offset as usize;
|
|
|
|
panic!("CSS error: {}\t\n{}:{} {}", url.as_str(), line_offset, location.column, message);
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct AutoGCRuleTree<'a>(&'a RuleTree);
|
|
|
|
|
|
|
|
impl<'a> AutoGCRuleTree<'a> {
|
|
|
|
fn new(r: &'a RuleTree) -> Self {
|
|
|
|
AutoGCRuleTree(r)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Drop for AutoGCRuleTree<'a> {
|
|
|
|
fn drop(&mut self) {
|
2017-04-03 23:15:49 +03:00
|
|
|
unsafe {
|
|
|
|
self.0.gc();
|
|
|
|
assert!(::std::thread::panicking() ||
|
|
|
|
!self.0.root().has_children_for_testing(),
|
|
|
|
"No rule nodes other than the root shall remain!");
|
|
|
|
}
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-31 01:54:26 +03:00
|
|
|
fn parse_rules(css: &str) -> Vec<(StyleSource, CascadeLevel)> {
|
2017-04-12 18:00:26 +03:00
|
|
|
let lock = SharedRwLock::new();
|
|
|
|
let media = Arc::new(lock.wrap(MediaList::empty()));
|
|
|
|
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
let s = Stylesheet::from_str(css,
|
|
|
|
ServoUrl::parse("http://localhost").unwrap(),
|
|
|
|
Origin::Author,
|
2017-04-12 18:00:26 +03:00
|
|
|
media,
|
|
|
|
lock,
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
None,
|
2017-04-14 04:12:08 +03:00
|
|
|
&ErrorringErrorReporter,
|
2017-04-28 06:32:24 +03:00
|
|
|
QuirksMode::NoQuirks,
|
2017-04-14 04:12:08 +03:00
|
|
|
0u64);
|
servo: Merge #16014 - Per-process lock for CSSOM objects (from servo:style-ref); r=emilio
<!-- Please describe your changes on the following line: -->
Before this PR, every object reflected in CSSOM is in `Arc<RwLock<_>>` to enable safe (synchronized) mutable aliasing. Acquiring all these locks has significant cost during selector matching:
* https://bugzilla.mozilla.org/show_bug.cgi?id=1311469
* https://bugzilla.mozilla.org/show_bug.cgi?id=1335941
* https://bugzilla.mozilla.org/show_bug.cgi?id=1339703
This PR introduce a mechanism to protect many objects with the same `RwLock` that only needs to be acquired once.
In Stylo, there is one such lock per process (in a `lazy_static`), used for everything.
I non-Stylo Servo, I originally intended to have one such lock per document (for author-origin stylesheets, and one per process for user-agent and user sytlesheets since they’re shared across documents, and never mutated anyway). However I failed to have the same document-specific (or pipeline-specific) `Arc` reachable from both `Document` nodes and `LayoutThread`. Recursively following callers lead me to include this `Arc` in `UnprivilegedPipelineContent`, but that needs to be serializable. So there is a second process-wide lock.
This was previously #15998, closed accidentally.
---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: bb54f0a429de0e8b8861f8071b6cf82f73622664
--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 851230e57ac8775707df5f0f103be5feac81fc41
2017-03-20 00:31:19 +03:00
|
|
|
let guard = s.shared_lock.read();
|
|
|
|
let rules = s.rules.read_with(&guard);
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
rules.0.iter().filter_map(|rule| {
|
|
|
|
match *rule {
|
|
|
|
CssRule::Style(ref style_rule) => Some(style_rule),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}).cloned().map(StyleSource::Style).map(|s| {
|
2017-01-31 01:54:26 +03:00
|
|
|
(s, CascadeLevel::UserNormal)
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
}).collect()
|
|
|
|
}
|
|
|
|
|
2017-01-31 01:54:26 +03:00
|
|
|
fn test_insertion(rule_tree: &RuleTree, rules: Vec<(StyleSource, CascadeLevel)>) -> StrongRuleNode {
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
rule_tree.insert_ordered_rules(rules.into_iter())
|
|
|
|
}
|
|
|
|
|
servo: Merge #16014 - Per-process lock for CSSOM objects (from servo:style-ref); r=emilio
<!-- Please describe your changes on the following line: -->
Before this PR, every object reflected in CSSOM is in `Arc<RwLock<_>>` to enable safe (synchronized) mutable aliasing. Acquiring all these locks has significant cost during selector matching:
* https://bugzilla.mozilla.org/show_bug.cgi?id=1311469
* https://bugzilla.mozilla.org/show_bug.cgi?id=1335941
* https://bugzilla.mozilla.org/show_bug.cgi?id=1339703
This PR introduce a mechanism to protect many objects with the same `RwLock` that only needs to be acquired once.
In Stylo, there is one such lock per process (in a `lazy_static`), used for everything.
I non-Stylo Servo, I originally intended to have one such lock per document (for author-origin stylesheets, and one per process for user-agent and user sytlesheets since they’re shared across documents, and never mutated anyway). However I failed to have the same document-specific (or pipeline-specific) `Arc` reachable from both `Document` nodes and `LayoutThread`. Recursively following callers lead me to include this `Arc` in `UnprivilegedPipelineContent`, but that needs to be serializable. So there is a second process-wide lock.
This was previously #15998, closed accidentally.
---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: bb54f0a429de0e8b8861f8071b6cf82f73622664
--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 851230e57ac8775707df5f0f103be5feac81fc41
2017-03-20 00:31:19 +03:00
|
|
|
fn test_insertion_style_attribute(rule_tree: &RuleTree, rules: &[(StyleSource, CascadeLevel)],
|
|
|
|
shared_lock: &SharedRwLock)
|
|
|
|
-> StrongRuleNode {
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
let mut rules = rules.to_vec();
|
servo: Merge #16014 - Per-process lock for CSSOM objects (from servo:style-ref); r=emilio
<!-- Please describe your changes on the following line: -->
Before this PR, every object reflected in CSSOM is in `Arc<RwLock<_>>` to enable safe (synchronized) mutable aliasing. Acquiring all these locks has significant cost during selector matching:
* https://bugzilla.mozilla.org/show_bug.cgi?id=1311469
* https://bugzilla.mozilla.org/show_bug.cgi?id=1335941
* https://bugzilla.mozilla.org/show_bug.cgi?id=1339703
This PR introduce a mechanism to protect many objects with the same `RwLock` that only needs to be acquired once.
In Stylo, there is one such lock per process (in a `lazy_static`), used for everything.
I non-Stylo Servo, I originally intended to have one such lock per document (for author-origin stylesheets, and one per process for user-agent and user sytlesheets since they’re shared across documents, and never mutated anyway). However I failed to have the same document-specific (or pipeline-specific) `Arc` reachable from both `Document` nodes and `LayoutThread`. Recursively following callers lead me to include this `Arc` in `UnprivilegedPipelineContent`, but that needs to be serializable. So there is a second process-wide lock.
This was previously #15998, closed accidentally.
---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: bb54f0a429de0e8b8861f8071b6cf82f73622664
--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 851230e57ac8775707df5f0f103be5feac81fc41
2017-03-20 00:31:19 +03:00
|
|
|
rules.push((StyleSource::Declarations(Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one(
|
2017-03-17 00:48:53 +03:00
|
|
|
PropertyDeclaration::Display(
|
|
|
|
longhands::display::SpecifiedValue::block),
|
2017-03-08 14:07:04 +03:00
|
|
|
Importance::Normal
|
|
|
|
)))), CascadeLevel::UserNormal));
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
test_insertion(rule_tree, rules)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_insertion_basic(b: &mut Bencher) {
|
|
|
|
let r = RuleTree::new();
|
|
|
|
|
|
|
|
let rules_matched = parse_rules(
|
|
|
|
".foo { width: 200px; } \
|
|
|
|
.bar { height: 500px; } \
|
|
|
|
.baz { display: block; }");
|
|
|
|
|
|
|
|
b.iter(|| {
|
|
|
|
let _gc = AutoGCRuleTree::new(&r);
|
|
|
|
|
|
|
|
for _ in 0..(4000 + 400) {
|
|
|
|
test::black_box(test_insertion(&r, rules_matched.clone()));
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_insertion_basic_per_element(b: &mut Bencher) {
|
|
|
|
let r = RuleTree::new();
|
|
|
|
|
|
|
|
let rules_matched = parse_rules(
|
|
|
|
".foo { width: 200px; } \
|
|
|
|
.bar { height: 500px; } \
|
|
|
|
.baz { display: block; }");
|
|
|
|
|
|
|
|
b.iter(|| {
|
|
|
|
let _gc = AutoGCRuleTree::new(&r);
|
|
|
|
|
|
|
|
test::black_box(test_insertion(&r, rules_matched.clone()));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_expensive_insertion(b: &mut Bencher) {
|
|
|
|
let r = RuleTree::new();
|
|
|
|
|
|
|
|
// This test case tests a case where you style a bunch of siblings
|
|
|
|
// matching the same rules, with a different style attribute each
|
|
|
|
// one.
|
|
|
|
let rules_matched = parse_rules(
|
|
|
|
".foo { width: 200px; } \
|
|
|
|
.bar { height: 500px; } \
|
|
|
|
.baz { display: block; }");
|
|
|
|
|
servo: Merge #16014 - Per-process lock for CSSOM objects (from servo:style-ref); r=emilio
<!-- Please describe your changes on the following line: -->
Before this PR, every object reflected in CSSOM is in `Arc<RwLock<_>>` to enable safe (synchronized) mutable aliasing. Acquiring all these locks has significant cost during selector matching:
* https://bugzilla.mozilla.org/show_bug.cgi?id=1311469
* https://bugzilla.mozilla.org/show_bug.cgi?id=1335941
* https://bugzilla.mozilla.org/show_bug.cgi?id=1339703
This PR introduce a mechanism to protect many objects with the same `RwLock` that only needs to be acquired once.
In Stylo, there is one such lock per process (in a `lazy_static`), used for everything.
I non-Stylo Servo, I originally intended to have one such lock per document (for author-origin stylesheets, and one per process for user-agent and user sytlesheets since they’re shared across documents, and never mutated anyway). However I failed to have the same document-specific (or pipeline-specific) `Arc` reachable from both `Document` nodes and `LayoutThread`. Recursively following callers lead me to include this `Arc` in `UnprivilegedPipelineContent`, but that needs to be serializable. So there is a second process-wide lock.
This was previously #15998, closed accidentally.
---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: bb54f0a429de0e8b8861f8071b6cf82f73622664
--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 851230e57ac8775707df5f0f103be5feac81fc41
2017-03-20 00:31:19 +03:00
|
|
|
let shared_lock = SharedRwLock::new();
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
b.iter(|| {
|
|
|
|
let _gc = AutoGCRuleTree::new(&r);
|
|
|
|
|
|
|
|
for _ in 0..(4000 + 400) {
|
servo: Merge #16014 - Per-process lock for CSSOM objects (from servo:style-ref); r=emilio
<!-- Please describe your changes on the following line: -->
Before this PR, every object reflected in CSSOM is in `Arc<RwLock<_>>` to enable safe (synchronized) mutable aliasing. Acquiring all these locks has significant cost during selector matching:
* https://bugzilla.mozilla.org/show_bug.cgi?id=1311469
* https://bugzilla.mozilla.org/show_bug.cgi?id=1335941
* https://bugzilla.mozilla.org/show_bug.cgi?id=1339703
This PR introduce a mechanism to protect many objects with the same `RwLock` that only needs to be acquired once.
In Stylo, there is one such lock per process (in a `lazy_static`), used for everything.
I non-Stylo Servo, I originally intended to have one such lock per document (for author-origin stylesheets, and one per process for user-agent and user sytlesheets since they’re shared across documents, and never mutated anyway). However I failed to have the same document-specific (or pipeline-specific) `Arc` reachable from both `Document` nodes and `LayoutThread`. Recursively following callers lead me to include this `Arc` in `UnprivilegedPipelineContent`, but that needs to be serializable. So there is a second process-wide lock.
This was previously #15998, closed accidentally.
---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: bb54f0a429de0e8b8861f8071b6cf82f73622664
--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 851230e57ac8775707df5f0f103be5feac81fc41
2017-03-20 00:31:19 +03:00
|
|
|
test::black_box(test_insertion_style_attribute(&r, &rules_matched, &shared_lock));
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_insertion_basic_parallel(b: &mut Bencher) {
|
|
|
|
let r = RuleTree::new();
|
|
|
|
|
|
|
|
let rules_matched = parse_rules(
|
|
|
|
".foo { width: 200px; } \
|
|
|
|
.bar { height: 500px; } \
|
|
|
|
.baz { display: block; }");
|
|
|
|
|
|
|
|
b.iter(|| {
|
|
|
|
let _gc = AutoGCRuleTree::new(&r);
|
|
|
|
|
|
|
|
rayon::scope(|s| {
|
|
|
|
for _ in 0..4 {
|
|
|
|
s.spawn(|s| {
|
|
|
|
for _ in 0..1000 {
|
|
|
|
test::black_box(test_insertion(&r,
|
|
|
|
rules_matched.clone()));
|
|
|
|
}
|
|
|
|
s.spawn(|_| {
|
|
|
|
for _ in 0..100 {
|
|
|
|
test::black_box(test_insertion(&r,
|
|
|
|
rules_matched.clone()));
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_expensive_insersion_parallel(b: &mut Bencher) {
|
|
|
|
let r = RuleTree::new();
|
|
|
|
|
|
|
|
let rules_matched = parse_rules(
|
|
|
|
".foo { width: 200px; } \
|
|
|
|
.bar { height: 500px; } \
|
|
|
|
.baz { display: block; }");
|
|
|
|
|
servo: Merge #16014 - Per-process lock for CSSOM objects (from servo:style-ref); r=emilio
<!-- Please describe your changes on the following line: -->
Before this PR, every object reflected in CSSOM is in `Arc<RwLock<_>>` to enable safe (synchronized) mutable aliasing. Acquiring all these locks has significant cost during selector matching:
* https://bugzilla.mozilla.org/show_bug.cgi?id=1311469
* https://bugzilla.mozilla.org/show_bug.cgi?id=1335941
* https://bugzilla.mozilla.org/show_bug.cgi?id=1339703
This PR introduce a mechanism to protect many objects with the same `RwLock` that only needs to be acquired once.
In Stylo, there is one such lock per process (in a `lazy_static`), used for everything.
I non-Stylo Servo, I originally intended to have one such lock per document (for author-origin stylesheets, and one per process for user-agent and user sytlesheets since they’re shared across documents, and never mutated anyway). However I failed to have the same document-specific (or pipeline-specific) `Arc` reachable from both `Document` nodes and `LayoutThread`. Recursively following callers lead me to include this `Arc` in `UnprivilegedPipelineContent`, but that needs to be serializable. So there is a second process-wide lock.
This was previously #15998, closed accidentally.
---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: bb54f0a429de0e8b8861f8071b6cf82f73622664
--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 851230e57ac8775707df5f0f103be5feac81fc41
2017-03-20 00:31:19 +03:00
|
|
|
let shared_lock = SharedRwLock::new();
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
b.iter(|| {
|
|
|
|
let _gc = AutoGCRuleTree::new(&r);
|
|
|
|
|
|
|
|
rayon::scope(|s| {
|
|
|
|
for _ in 0..4 {
|
|
|
|
s.spawn(|s| {
|
|
|
|
for _ in 0..1000 {
|
|
|
|
test::black_box(test_insertion_style_attribute(&r,
|
servo: Merge #16014 - Per-process lock for CSSOM objects (from servo:style-ref); r=emilio
<!-- Please describe your changes on the following line: -->
Before this PR, every object reflected in CSSOM is in `Arc<RwLock<_>>` to enable safe (synchronized) mutable aliasing. Acquiring all these locks has significant cost during selector matching:
* https://bugzilla.mozilla.org/show_bug.cgi?id=1311469
* https://bugzilla.mozilla.org/show_bug.cgi?id=1335941
* https://bugzilla.mozilla.org/show_bug.cgi?id=1339703
This PR introduce a mechanism to protect many objects with the same `RwLock` that only needs to be acquired once.
In Stylo, there is one such lock per process (in a `lazy_static`), used for everything.
I non-Stylo Servo, I originally intended to have one such lock per document (for author-origin stylesheets, and one per process for user-agent and user sytlesheets since they’re shared across documents, and never mutated anyway). However I failed to have the same document-specific (or pipeline-specific) `Arc` reachable from both `Document` nodes and `LayoutThread`. Recursively following callers lead me to include this `Arc` in `UnprivilegedPipelineContent`, but that needs to be serializable. So there is a second process-wide lock.
This was previously #15998, closed accidentally.
---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: bb54f0a429de0e8b8861f8071b6cf82f73622664
--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 851230e57ac8775707df5f0f103be5feac81fc41
2017-03-20 00:31:19 +03:00
|
|
|
&rules_matched,
|
|
|
|
&shared_lock));
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
}
|
|
|
|
s.spawn(|_| {
|
|
|
|
for _ in 0..100 {
|
|
|
|
test::black_box(test_insertion_style_attribute(&r,
|
servo: Merge #16014 - Per-process lock for CSSOM objects (from servo:style-ref); r=emilio
<!-- Please describe your changes on the following line: -->
Before this PR, every object reflected in CSSOM is in `Arc<RwLock<_>>` to enable safe (synchronized) mutable aliasing. Acquiring all these locks has significant cost during selector matching:
* https://bugzilla.mozilla.org/show_bug.cgi?id=1311469
* https://bugzilla.mozilla.org/show_bug.cgi?id=1335941
* https://bugzilla.mozilla.org/show_bug.cgi?id=1339703
This PR introduce a mechanism to protect many objects with the same `RwLock` that only needs to be acquired once.
In Stylo, there is one such lock per process (in a `lazy_static`), used for everything.
I non-Stylo Servo, I originally intended to have one such lock per document (for author-origin stylesheets, and one per process for user-agent and user sytlesheets since they’re shared across documents, and never mutated anyway). However I failed to have the same document-specific (or pipeline-specific) `Arc` reachable from both `Document` nodes and `LayoutThread`. Recursively following callers lead me to include this `Arc` in `UnprivilegedPipelineContent`, but that needs to be serializable. So there is a second process-wide lock.
This was previously #15998, closed accidentally.
---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Source-Repo: https://github.com/servo/servo
Source-Revision: bb54f0a429de0e8b8861f8071b6cf82f73622664
--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 851230e57ac8775707df5f0f103be5feac81fc41
2017-03-20 00:31:19 +03:00
|
|
|
&rules_matched,
|
|
|
|
&shared_lock));
|
servo: Merge #14485 - style: Add a simple rule-tree benchmarks (from servo:rule-tree-bench); r=heycam
<!-- Please describe your changes on the following line: -->
r? @heycam
Numbers on my machine, for the record:
```
test rule_tree::bench::bench_expensive_insersion ... bench: 7,211,081 ns/iter (+/- 1,933,866)
test rule_tree::bench::bench_expensive_insersion_parallel ... bench: 78,728,097 ns/iter (+/- 11,738,010)
test rule_tree::bench::bench_insertion_basic ... bench: 665,333 ns/iter (+/- 68,089)
test rule_tree::bench::bench_insertion_basic_parallel ... bench: 1,587,203 ns/iter (+/- 372,124)
```
Source-Repo: https://github.com/servo/servo
Source-Revision: cb6a870077fc6bca98af688406926832ae3df038
--HG--
rename : servo/components/style/servo/mod.rs => servo/tests/unit/style/rule_tree/mod.rs
2016-12-19 11:47:34 +03:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|