Add a MOZ_CCTIMER environment variable (mirroring MOZ_GCTIMER) to dump CC stats to the console

RESOLVED FIXED in Firefox 51

Status

()

Core
DOM: Core & HTML
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: terrence, Assigned: terrence)

Tracking

(Blocks: 1 bug)

Trunk
mozilla51
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox51 fixed)

Details

Attachments

(1 attachment)

(Assignee)

Description

2 years ago
Created attachment 8779005 [details] [diff] [review]
implement_MOZ_CCTIMER-v0.diff

It surprised me that there's currently no easy way to get CC logs out of the CC and into a file for easy grepping, searching, and statisticsing. In the GC we have an extremely useful environment flag called MOZ_GCTIMER that lets us do just this.

The attached patch adds a similar flag for the CC. I've tested this locally and it gets me enough data to move forward. Given how useful the GC flag has been, I hope we can take this (or something like it) for the CC.
Attachment #8779005 - Flags: review?(continuation)
Comment on attachment 8779005 [details] [diff] [review]
implement_MOZ_CCTIMER-v0.diff

Review of attachment 8779005 [details] [diff] [review]:
-----------------------------------------------------------------

I guess this is fine.

::: dom/base/nsJSEnvironment.cpp
@@ +1287,5 @@
>      Clear();
>      mMaxSliceTimeSinceClear = 0;
> +
> +    char* env = getenv("MOZ_CCTIMER");
> +    if (env) {

Please invert the test and do an early return here.

@@ +1295,5 @@
> +        mFile = stdout;
> +      } else if (strcmp(env, "stderr") == 0) {
> +        mFile = stderr;
> +      } else {
> +        mFile = fopen(env, "a");

This eventually won't work with content process sandboxing, FWIW. I wonder if there's some existing way to just dump the console output to a file.

@@ +1616,5 @@
>    uint32_t cleanups = sForgetSkippableBeforeCC ? sForgetSkippableBeforeCC : 1;
>    uint32_t minForgetSkippableTime = (sMinForgetSkippableTime == UINT32_MAX)
>      ? 0 : sMinForgetSkippableTime;
>  
> +  if (sPostGCEventsToConsole || gCCStats.mFile) {

This will make us post them to the console even if that pref isn't set, but I suppose that's okay.
Attachment #8779005 - Flags: review?(continuation) → review+
(Assignee)

Comment 2

2 years ago
Oh, good catch! We should probably build the string in the || branch and have a separate case for each output mechanism.

Comment 4

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/160102be757f
Status: ASSIGNED → RESOLVED
Last Resolved: 2 years ago
status-firefox51: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
Blocks: 1303123
You need to log in before you can comment on or make changes to this bug.