Open Bug 1413266 Opened 7 years ago Updated 2 years ago

Make sure use counters are submitted on shutdown

Categories

(Core :: DOM: Core & HTML, enhancement, P2)

enhancement

Tracking

()

People

(Reporter: gfritzsche, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [measurement:client:tracking])

Attachments

(1 file)

Per bug 1409865, comment 28 ff, we are not sure that use counters get properly reported on shutdown.

Looking at callers of nsDocument::ReportUseCounters(), nsDocument::~nsDocument() seems to be the main one.
http://searchfox.org/mozilla-central/search?q=symbol:_ZN10nsDocument17ReportUseCountersENS_20UseCounterReportKindE&redirect=false

With some initial logging/checking, we haven't seen this report values on Firefox shutdown.

This could mean under-counting of some usage scenarios.
Ideally use counters would be submitted from "profile-before-change" at the latest.
Whiteboard: [measurement:client:tracking]
Cameron, do you know how this is supposed to work during shutdown & across processes?
Flags: needinfo?(cam)
As far as I know we don't do anything special to account for shutdown or e10s in the use counter reporting code.  We should be invoking the nsDocument destructor for all documents before the process exits (unless there's a shutdown hang that prevents a document from being destroyed, I guess).  nsDocument::ReportUseCounters just translates to Telemetry::Accumulate calls.  Can we lose telemetry data if we call Telemetry::Accumulate too late (after "profile-before-change")?

Did your logging/checking look at the telemetry that's reported, or did you set sDebugUseCounters (in nsDocument::ReportUseCounters) to true?
Flags: needinfo?(cam) → needinfo?(gfritzsche)
With the attached patch, the following behaves fine:
- start Fx
- open http://webassembly.org/demo/
- close tab
- in about:memory, minimize memory usage

Then i see the following logged:
> ...
> JavaScript warning: http://webassembly.org/demo/Tanks/Build/UnityLoader.js, line 0: Successfully compiled asm.js code
> ...
> *** nsDocument::ReportUseCounters()
> *** internal_Accumulate(CONTENT_DOCUMENTS_DESTROYED, 1)
> *** internal_Accumulate(TOP_LEVEL_CONTENT_DOCUMENTS_DESTROYED, 1)
> *** internal_Accumulate(USE_COUNTER2_JS_ASMJS_DOCUMENT, 1)
> *** internal_Accumulate(USE_COUNTER2_JS_ASMJS_PAGE, 1)
> *** internal_Accumulate(USE_COUNTER2_JS_WASM_DOCUMENT, 1)
> *** internal_Accumulate(USE_COUNTER2_JS_WASM_PAGE, 1)
> ...
> *** TelemetryHistogram::CreateHistogramSnapshots()
> ...

Now, when i do e.g.:
- start Fx
- open http://webassembly.org/demo/
- close Fx

Then i see:
> ...
> JavaScript warning: http://webassembly.org/demo/Tanks/Build/UnityLoader.js, line 0: Successfully compiled asm.js code
> ...
> *** TelemetryHistogram::CreateHistogramSnapshots()
> ...

Notably i don't see any of the relevant use counters being recorded at shutdown.
Am i missing something?
Flags: needinfo?(gfritzsche)
If doing this in time on shutdown is not a good option, we could also think about submitting use counters and page/doc counts eagerly, on first use.
Flags: needinfo?(cam)
(In reply to Cameron McCormack (:heycam) from comment #2)
> Can we lose telemetry data if we call
> Telemetry::Accumulate too late (after "profile-before-change")?

Yes, specifically if its submitted after the "profile-before-change-telemetry" notification (which fires after "profile-before-change").
Everything accumulated after will get stored, but doesn't get saved/send with a ping.
Seems like you're working on this, Georg, so assigning to you.
Assignee: nobody → gfritzsche
Priority: -- → P2
Hey, i'm not working on this, just raising a potential issue with this instrumentation.
I'm happy to help figure this out.
Assignee: gfritzsche → nobody
Component: DOM → DOM: Core & HTML

We report use counters earlier a bit after bug 1568950, this bug may benefit from it.

Flags: needinfo?(cam)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: