Permalink
Browse files

Revert "Fix merge conflicts"

This reverts commit fa75abc.
  • Loading branch information...
1 parent fa75abc commit 4de96d6375650e20c7d8f689ecba8da13ab2aaf8 @whimboo whimboo committed Aug 15, 2012
Showing with 144 additions and 13 deletions.
  1. +71 −0 extension/lib/config.js
  2. +72 −12 extension/lib/garbage-collector.js
  3. +1 −1 extension/lib/main.js
View
@@ -42,6 +42,77 @@ 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.",
@@ -35,8 +35,26 @@ const reporter = EventEmitter.compose({
if (!this._isEnabled)
this._enable();
- Services.obs.addObserver(this, config.application.topic_cc_statistics, false);
- Services.obs.addObserver(this, config.application.topic_gc_statistics, false);
+ // 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);
+ }
},
get pref_gc_notifications() {
@@ -46,8 +64,12 @@ const reporter = EventEmitter.compose({
unload: function Reporter_unload() {
this._removeAllListeners();
- Services.obs.removeObserver(this, config.application.topic_cc_statistics, false);
- Services.obs.removeObserver(this, config.application.topic_gc_statistics, false);
+ 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);
+ }
},
_enable: function Reporter__enable() {
@@ -69,20 +91,58 @@ const reporter = EventEmitter.compose({
let data = { };
let type = aTopic;
- try {
- data = JSON.parse(aData);
- } catch (e) {
- Cu.reportError("Failure parsing JSON data: " + aData);
+ 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);
}
-
- // 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;
}
})();
View
@@ -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":

0 comments on commit 4de96d6

Please sign in to comment.