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 upImplement GridTemplateAreas with reference counting #19465
Conversation
highfive
commented
Dec 2, 2017
|
Heads up! This PR modifies the following files:
|
highfive
commented
Dec 2, 2017
| } | ||
|
|
||
| impl MallocSizeOf for TemplateAreasArc { | ||
| /// FIXIME: (cybai) NEED TO FIGURE OUT HOW TO IMPLEMENT |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
@tigercosmos |
|
The test-failure is legit and means that with your changes |
| /// Arc type for `Arc<TemplateAreas>` | ||
| pub struct TemplateAreasArc(pub Arc<TemplateAreas>); | ||
|
|
||
| impl Parse for TemplateAreasArc { |
This comment has been minimized.
This comment has been minimized.
emilio
Dec 3, 2017
Member
We should be able to remove Parse for TemplateAreas now, right? Alternatively this method could be:
TemplateAreasArc(Arc::new(TemplateAreas::parse(context, input)?))
This comment has been minimized.
This comment has been minimized.
CYBAI
Dec 3, 2017
•
Author
Collaborator
I remember I impl this trait due to getting errors about lack of this trait.
I'll try to remove it to see if it's necessary.
Or, I'll try to update the method as returning a TemplateAreasArc.
Thanks.
This comment has been minimized.
This comment has been minimized.
CYBAI
Dec 3, 2017
Author
Collaborator
Hmm... yeah, I'll get error messages like following
error[E0599]: no function or associated item named `parse` found for type `values::Either<values::specified::position::TemplateAreasArc, values::None_>` in the current scope
--> /servo/target/geckolib/debug/build/style-abfaa561961fdc53/out/properties.rs:40333:13
|
40333 | specified::GridTemplateAreas::parse(context, input)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the method `parse` exists but the following trait bounds were not satisfied:
`values::specified::position::TemplateAreasArc : parser::Parse`
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following traits define an item `parse`, perhaps you need to implement one of them:
candidate #1: `parser::Parse`
candidate #2: `bitflags::<unnamed>::str::StrExt`
candidate #3: `style_traits::Separator`
error: aborting due to previous error
Let me try to update the method body like what you wrote.
| } | ||
|
|
||
| impl MallocSizeOf for TemplateAreasArc { | ||
| /// FIXME: (cybai) NEED TO FIGURE OUT HOW TO IMPLEMENT |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| /// FIXME: (cybai) NEED TO FIGURE OUT HOW TO IMPLEMENT | ||
| /// MallocConditionalSizeOf for this Arc | ||
| fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { | ||
| 0 |
This comment has been minimized.
This comment has been minimized.
emilio
Dec 3, 2017
Member
@nnethercote, what's the best way to measure this? For now measuring as 0 may be fine, since this is pretty rare, but in case it comes up again...
|
@emilio Yeah, I just tried to remove the |
0032052
to
027f37e
|
About measuring |
|
@nnethercote I just tried to use cc @emilio |
| #[cfg(feature = "gecko")] | ||
| impl MallocSizeOf for TemplateAreasArc { | ||
| fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { | ||
| self.0.conditional_size_of(ops) |
This comment has been minimized.
This comment has been minimized.
nnethercote
Dec 5, 2017
Contributor
This isn't quite right. TemplateAreasArc is basically the same as Arc, so it should implement the same traits: one or more of MallocUnconditionalShallowSizeOf, MallocUnconditionalSizeOf, MallocConditionalShallowSizeOf, MallocConditionalSizeOf. It should not implement MallocSizeOf or MallocShallowSizeOf. See components/malloc_size_of/lib.rs for more details.
Having said that: does TemplateAreasArc need to be a newtype? Could it just be a typedef for Arc<TemplateAreas>? Maybe you need a newtype so you can define additional methods?
TemplateAreasArc
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
emilio
Dec 5, 2017
Member
Though arguably that should be generically implemented... ToComputedValue is trickier though.
This comment has been minimized.
This comment has been minimized.
CYBAI
Dec 9, 2017
Author
Collaborator
@nnethercote Due to enum PropertyDeclaration, we must impl MallocSizeOf for TemplateAreasArc so I cannot only impl MallocConditionalSizeOf for it.
How do you think about it?
cc @emilio
This comment has been minimized.
This comment has been minimized.
nnethercote
Dec 10, 2017
Contributor
Is #[derive(MallocSizeOf)] involved? It works well for tree-like structures, but less well for graph-like structures. One possibility is to change the relevant MallocSizeOf impl from a derived one to a manually written one that does something appropriate (and different) for the Arc. Another possibility is to keep the derive impl and use the ignore_malloc_size_of attribute on the relevant Arc field.
This comment has been minimized.
This comment has been minimized.
CYBAI
Dec 11, 2017
Author
Collaborator
Yes, this code block is involved #[derive(MallocSizeOf)].
servo/components/style/properties/properties.mako.rs
Lines 1404 to 1408 in 0fa605d
I think adding another checking into mako for only this case might not be good.
I'll try to use ignore_malloc_size_of attribute for it, thanks.
|
|
c013964
to
b361e79
c6dac38
to
bb7237e
|
@nnethercote @emilio I just updated the PR with keeping the |
|
Travis build failed with #19634 |
|
Rebased and fixed the build error. |
|
r? @nnethercote and @emilio |
|
|
0c79fd8
to
6c48285
|
Ping for review from @nnethercote and @emilio |
| @@ -624,6 +625,23 @@ impl Parse for TemplateAreas { | |||
|
|
|||
| trivial_to_computed_value!(TemplateAreas); | |||
|
|
|||
| #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] | |||
| /// Arc type for `Arc<TemplateAreas>` | |||
This comment has been minimized.
This comment has been minimized.
|
Apologies for the long delay, I was on PTO. The memory measurements parts of this patch look fine to me. Emilio will need to approve the rest of it, though. |
|
r? @emilio |
|
Looks good, thanks! @bors-servo r+ |
|
|
Implement GridTemplateAreas with reference counting Use `Arc` to implement refcounting for `GridTemplateAreas` r? emilio --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #19428 - [x] These changes do not require tests <!-- 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/19465) <!-- Reviewable:end -->
|
|
CYBAI commentedDec 2, 2017
•
edited by emilio
Use
Arcto implement refcounting forGridTemplateAreasr? emilio
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is