Skip to content
This repository has been archived by the owner on Oct 18, 2018. It is now read-only.

Commit

Permalink
Remove code for Firefox versions <13 because we don't support those a…
Browse files Browse the repository at this point in the history
…nymore (#150)
  • Loading branch information
whimboo committed Aug 15, 2012
1 parent 4de96d6 commit 27f72e5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 144 deletions.
71 changes: 0 additions & 71 deletions extension/lib/config.js
Expand Up @@ -42,77 +42,6 @@ const APPLICATION = {
const EXTENSION = {
memory_poll_interval_default: 5000,

gc_app_data: {
"10" : {
// CC timestamp: 1325854683540071, collected: 75 (75 waiting for GC),
// suspected: 378, duration: 19 ms.
// GC mode: full, timestamp: 1325854678521066, duration: 32 ms.
"cc" : [
{ label: "collected", regex: " ([^,]+)" },
{ label: "duration", regex: " (\\d+)" },
{ label: "suspected", regex: " (\\d+)" },
],
"gc" : [
{ label: "duration", regex: " (\\d+)" },
{ label: "mode", regex: " (\\w+)" },
]
},
"11" : {
// CC(T+9.6) collected: 1821 (1821 waiting for GC), suspected: 18572,
// duration: 31 ms.
// GC(T+0.0) Type:Glob, Total:27.9, Wait:0.6, Mark:13.4, Sweep:12.6, FinObj:3.7,
// FinStr:0.2, FinScr:0.5, FinShp:2.1, DisCod:0.3, DisAnl:3.0,
// XPCnct:0.8, Destry:0.0, End:2.1, +Chu:16, -Chu:0, Reason:DestC
"cc" : [
{ label: "collected", regex: " ([^,]+)" },
{ label: "duration", regex: " (\\d+)" },
{ label: "suspected", regex: " (\\d+)" },
],
"gc" : [
{ label: "Total", regex: "([\\d\\.]+)" },
{ label: "Type", regex: "(\\w+)" },
{ label: "Reason", regex: "\\s*(\\w+)" },
]
},
"13" : {
// GC(T+0.0) TotalTime: 254.2ms, Type: global, MMU(20ms): 0%, MMU(50ms): 0%,
// Reason: MAYBEGC, +chunks: 0, -chunks: 0 mark: 160.2,
// mark-roots: 5.8, mark-other: 3.6, sweep: 92.0, sweep-obj: 7.9,
// sweep-string: 12.2, sweep-script: 1.2, sweep-shape: 6.7,
// discard-code: 6.8, discard-analysis: 46.4, xpconnect: 3.5,
// deallocate: 0.4
// GC(T+141.6) TotalTime: 21.4ms, Type: global, MMU(20ms): 39%, MMU(50ms): 75%,
// MaxPause: 12.0, +chunks: 0, -chunks: 0
// Slice 0 @ 12.0ms (Pause: 12.0, Reason: PAGE_HIDE): mark: 11.6,
// mark-roots: 1.5
// Slice 2 @ 222.2ms (Pause: 7.2, Reason: INTER_SLICE_GC): mark: 1.2,
// mark-delayed: 0.1, mark-other: 1.0, sweep: 5.2,
// sweep-obj: 1.0, sweep-string: 0.1,
// sweep-script: 0.1, sweep-shape: 0.9,
// discard-code: 0.1, discard-analysis: 1.1,
// xpconnect: 0.7, deallocate: 0.1
// Totals: mark: 14.9, mark-roots: 1.5, mark-delayed: 0.3,
// mark-other: 1.0, sweep: 5.2, sweep-obj: 1.0,
// sweep-string: 0.1, sweep-script: 0.1, sweep-shape: 0.9,
// discard-code: 0.1, discard-analysis: 1.1,
// xpconnect: 0.7, deallocate: 0.1
// CC(T+0.0) collected: 76 (76 waiting for GC), suspected: 555, duration: 16 ms.
// ForgetSkippable 42 times before CC, min: 0 ms, max: 21 ms,
// avg: 1 ms, total: 50 ms, removed: 7787
"cc" : [
{ label: "collected", regex: " ([^,\\n]+)" },
{ label: "duration", regex: " (\\d+)" },
{ label: "suspected", regex: " (\\d+)" },
],
"gc" : [
{ label: "MaxPause", regex: " ([\\d\\.]+)" },
{ label: "TotalTime", regex: " ([\\d\\.]+)" },
{ label: "Type", regex: " (\\w+)" },
{ label: "Reason", regex: "\\s*(\\w+)" },
]
}
},

widget_tooltips : {
resident_label: "Memory used by the process that is present in physical memory. " +
"It does not necessarily have to match the process manager.",
Expand Down
84 changes: 12 additions & 72 deletions extension/lib/garbage-collector.js
Expand Up @@ -35,26 +35,8 @@ const reporter = EventEmitter.compose({
if (!this._isEnabled)
this._enable();

// When we have to parse console messages find the right data
switch (config.application.branch) {
case 10:
this._collector_data = config.extension.gc_app_data["10"];
break;
case 11:
case 12:
this._collector_data = config.extension.gc_app_data["11"];
break;
default:
this._collector_data = config.extension.gc_app_data["13"];
}

if (config.application.branch >= 14) {
Services.obs.addObserver(this, config.application.topic_cc_statistics, false);
Services.obs.addObserver(this, config.application.topic_gc_statistics, false);
}
else {
Services.console.registerListener(this);
}
Services.obs.addObserver(this, config.application.topic_cc_statistics, false);
Services.obs.addObserver(this, config.application.topic_gc_statistics, false);
},

get pref_gc_notifications() {
Expand All @@ -64,12 +46,8 @@ const reporter = EventEmitter.compose({
unload: function Reporter_unload() {
this._removeAllListeners();

if (config.application.branch >= 14) {
Services.obs.removeObserver(this, config.application.topic_cc_statistics, false);
Services.obs.removeObserver(this, config.application.topic_gc_statistics, false);
} else {
Services.console.unregisterListener(this);
}
Services.obs.removeObserver(this, config.application.topic_cc_statistics, false);
Services.obs.removeObserver(this, config.application.topic_gc_statistics, false);
},

_enable: function Reporter__enable() {
Expand All @@ -91,58 +69,20 @@ const reporter = EventEmitter.compose({
let data = { };
let type = aTopic;

if (config.application.branch >= 14) {
try {
data = JSON.parse(aData);
} catch (e) {
Cu.reportError("Failure parsing JSON data: " + aData);
}

// Use milliseconds instead of microseconds for the timestamp
if ('timestamp' in data) {
data['timestamp'] = Math.round(data['timestamp'] / 1000);
}
}
else {
// If it's not a GC/CC message return immediately
var sections = /^(CC|GC)/i.exec(aSubject.message);
if (sections === null)
return;

type = (sections[1].toLowerCase() === "cc") ? config.application.topic_cc_statistics
: config.application.topic_gc_statistics;
data = this.parseConsoleMessage(sections[1].toLowerCase(), aSubject.message);
try {
data = JSON.parse(aData);
} catch (e) {
Cu.reportError("Failure parsing JSON data: " + aData);
}

// Use milliseconds instead of microseconds for the timestamp
if ('timestamp' in data)
data['timestamp'] = Math.round(data['timestamp'] / 1000);

// Once the console listener can be removed, we can emit directly
require("timer").setTimeout(function (aScope) {
aScope._emit(type, data);
}, 0, this);
},

/**
* Parse the console message for all wanted entries
*/
parseConsoleMessage : function Reporter_parseConsoleMessage(aType, aMessage) {
/**
* Inline function to retrieve the value for a given key
*/
function getValueFor(aKey, aRegex) {
var regexp = new RegExp(aKey + ":" + aRegex, "i");
var matches = regexp.exec(aMessage);

return matches ? matches[1] : undefined;
}

let data = {
timestamp: Date.now()
};

this._collector_data[aType].forEach(function (aEntry) {
data[aEntry.label] = getValueFor(aEntry.label, aEntry.regex)
});

return data;
}
})();

Expand Down
2 changes: 1 addition & 1 deletion extension/lib/main.js
Expand Up @@ -56,7 +56,7 @@ exports.main = function (options, callbacks) {
case "log_folder":
// Show the memchaser directory.
let nsLocalFile = CC("@mozilla.org/file/local;1",
"nsILocalFile", "initWithPath");
"nsILocalFile", "initWithPath");
new nsLocalFile(logger.dir.path).reveal();
break;
case "logger_status":
Expand Down

0 comments on commit 27f72e5

Please sign in to comment.