New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement GridTemplateAreas with reference counting #19465
Conversation
Heads up! This PR modifies the following files:
|
} | ||
|
||
impl MallocSizeOf for TemplateAreasArc { | ||
/// FIXIME: (cybai) NEED TO FIGURE OUT HOW TO IMPLEMENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIXIME -> FIXME
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thanks :P
507e5f4
to
4c8778f
Compare
|
@tigercosmos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test-failure is legit and means that with your changes TemplateAreas
is no longer big (it's just a pointer now), so you should be able to just remove boxed=True
from it.
/// Arc type for `Arc<TemplateAreas>` | ||
pub struct TemplateAreasArc(pub Arc<TemplateAreas>); | ||
|
||
impl Parse for TemplateAreasArc { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to remove Parse for TemplateAreas
now, right? Alternatively this method could be:
TemplateAreasArc(Arc::new(TemplateAreas::parse(context, input)?))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: The comment doesn't really need to be uppercase :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, Let me updated this into normal cases :P
/// FIXME: (cybai) NEED TO FIGURE OUT HOW TO IMPLEMENT | ||
/// MallocConditionalSizeOf for this Arc | ||
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { | ||
0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
Compare
About measuring |
027f37e
to
e76d8bd
Compare
@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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it needs to be a newtype so it can implement ToCss
and such.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though arguably that should be generically implemented... ToComputedValue
is trickier though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this code block is involved #[derive(MallocSizeOf)]
.
servo/components/style/properties/properties.mako.rs
Lines 1404 to 1408 in 0fa605d
/// Servo's representation for a property declaration. | |
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] | |
#[derive(Clone, PartialEq)] | |
pub enum PropertyDeclaration { | |
% for property in data.longhands: |
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.
☔ The latest upstream changes (presumably #19584) made this pull request unmergeable. Please resolve the merge conflicts. |
c013964
to
b361e79
Compare
c6dac38
to
bb7237e
Compare
@nnethercote @emilio I just updated the PR with keeping the |
Travis build failed with #19634 |
bb7237e
to
6a23362
Compare
Rebased and fixed the build error. |
r? @nnethercote and @emilio |
☔ The latest upstream changes (presumably #19838) made this pull request unmergeable. Please resolve the merge conflicts. |
0c79fd8
to
6c48285
Compare
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>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd put the comment above the derive
line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
6c48285
to
9004fff
Compare
Looks good, thanks! @bors-servo r+ |
📌 Commit 9004fff has been approved by |
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 -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
Use
Arc
to implement refcounting forGridTemplateAreas
r? emilio
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is