Closed Bug 1461012 Opened 6 years ago Closed 6 years ago

Add CC optimization for PrecompiledScript

Categories

(Core :: XPConnect, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla62
Tracking Status
firefox62 --- fixed

People

(Reporter: mccr8, Assigned: kmag)

References

Details

Attachments

(1 file)

One of the reasons that we're hitting slow code in bug 1449033 is that the single PrecompiledScript has a black wrapper, but it does not mark its mScript field black. This feels a little riskier than the patches that just skip the expensive tracing so maybe this should only go on Nightly.
Assignee: nobody → kmaglione+bmo
Does that mean that the regression introduced by rev 1b4d5be72031 reported by bug 1449033 won't be fixed for Firefox 60?
(In reply to mathieuu from comment #1)
> Does that mean that the regression introduced by rev 1b4d5be72031 reported
> by bug 1449033 won't be fixed for Firefox 60?

By "the patches that just skip the expensive tracing" I mean the patches in bug 1460636 and bug 1460385. They seem to fix the problem for me, though I haven't tried the addon in bug 1449033 yet, which seems to be hit by the problem more. My preference would be to backport those to 60 rather than whatever happens here.
I'm not familiar with PrecompiledScript ownership model, but can we detect certainly alive such objects when mozilla::dom::TraceBlackJS is called, and just trace the scripts as black from the beginning?
If that is not the case, why? Could we change the ownership somehow so that mozilla::dom::TraceBlackJS could be used for tracing?
PrecompiledScript is owned by a weak set in JS, so I don't think we can do that. You'd have to add some weak reference from C++ for TraceBlackJS to use.
Or add a private slot to the wrapper pointing to the script so that when the wrapper is traced black, so will the script?
I suppose we could keep a linked list of them and trace them whenever they have a black wrapper, but I don't think that would have any benefits over just doing the same checks from CanSkip.
(In reply to Olli Pettay [:smaug] from comment #6)
> Or add a private slot to the wrapper pointing to the script so that when the
> wrapper is traced black, so will the script?

I suppose we could, but the CanSkip hook already does that, and also lets us skip the whole PrecompiledScript object, so there probably wouldn't be any real benefit.
The advantage is that having the GC mark the objects black from the start is more efficient than having the GC first mark the object grey, then going through the inefficient UnmarkGray code to mark them gray. (GC marking is much faster.) I'm not sure how much of a difference it makes in practice.
Well, the wrapper might not yet be black when mozilla::dom::TraceBlackJS is called.
But doing things in mozilla::dom::TraceBlackJS, when possible, is faster since then object is traced just once (black). No need for marking first gray and then later in CanSkip to black.
If the scripts can be huge and tracing them slow, this is something to think about.
OK. Well, there doesn't seem to be much measurable overhead from this approach with the RES add-on, but if it turns out to still be a problem, I suppose those might be options.
I probably won't get to this review until Monday, but it is probably a good idea anyways to have a Nightly or two with bug 1460636 but not this one to see if the other bug is sufficient.
Priority: -- → P3
Comment on attachment 8975192 [details]
Bug 1461012: Add CC optimizations for PrecompiledScript objects.

https://reviewboard.mozilla.org/r/243542/#review249736
Attachment #8975192 - Flags: review?(continuation) → review+
https://hg.mozilla.org/mozilla-central/rev/4e701e816acb
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla62
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: