Closed Bug 1398854 Opened 7 years ago Closed 7 years ago

Report the memory taken by CSS rules and declaration blocks

Categories

(Core :: CSS Parsing and Computation, defect, P3)

53 Branch
defect

Tracking

()

RESOLVED FIXED
Tracking Status
firefox-esr52 --- wontfix
firefox55 --- wontfix
firefox56 --- wontfix
firefox57 --- affected

People

(Reporter: bzbarsky, Assigned: n.nethercote)

References

Details

(Whiteboard: [MemShrink])

Looking at dmd output on gmail, I was seeing two large sources of unreported stylesheet memory, both allocated from _$LT$style..stylesheets..rule_parser..NestedRuleParser$LT$$u27$a$C$$u20$$u27$b$C$$u20$R$GT$$u20$as$u20$cssparser..rules_and_declarations..QualifiedRuleParser$LT$$u27$i$GT$$GT$::parse_block::h399bd1e34421d327 (geckoservo.cgu-0.rs:?)

These two source are the rules themselves and their declaration blocks.  We report the memory those things point to, but not their own memory.

The reason for not reporting the rules is that in CssRule's malloc_size_of_children impl (in servo/components/style/stylesheets/mod.rs) we do:

            CssRule::Style(ref lock) => {
                lock.read_with(guard).malloc_size_of_children(guard, malloc_size_of)
            },

In this case "lock" is an Arc<Locked<StyleRule>>.  The read_with() call dereferences the Arc, so we call malloc_size_of_children on the StyleRule.  But we're not measuring the memory the Arc itself points to.

Similarly, in style_rule.rs we have:

        n += self.block.read_with(guard).malloc_size_of_children(malloc_size_of);

which doesn't measure the memory pointed to by self.block (another Arc<Locked>).

These two bits add up to about 4.5MB on gmail.

I have local hacks to measure them, but really we should base this fix on bug 1398737 and then implement stuff for Arc<Locked<T>> that does the right thing (whether directly, or by implementing thigns for Arc<T> and Locked<T> separately).  Then we can look for cases where we're doing foo.read_with(guard).size_of() and switch to foo.size_of() instead, right?
Whiteboard: [MemShrink]
Blocks: 1392314
Assignee: nobody → n.nethercote
Priority: -- → P3
This landed on the Gecko side.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.