Bug 1118686 - TraceLogger: Cap the maximum number of entries in the graph tree, r=bbouvier
authorHannes Verschore <hv1989@gmail.com>
Tue, 13 Jan 2015 13:37:27 +0100
changeset 223567 c3ced50b2827a7478860e6a034445cfa045feae7
parent 223566 335c09bb1c951a0e12bc1370b6ddc3b209518974
child 223568 58dd19c8bd07f8c21ad7ba983841496319b950c3
push id28098
push userkwierso@gmail.com
push dateWed, 14 Jan 2015 00:52:19 +0000
treeherdermozilla-central@e978b8bc5c45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1118686
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1118686 - TraceLogger: Cap the maximum number of entries in the graph tree, r=bbouvier
js/src/vm/TraceLoggingGraph.cpp
js/src/vm/TraceLoggingGraph.h
--- a/js/src/vm/TraceLoggingGraph.cpp
+++ b/js/src/vm/TraceLoggingGraph.cpp
@@ -279,17 +279,17 @@ TraceLoggerGraph::entryToSystemEndian(Tr
 
 void
 TraceLoggerGraph::startEvent(uint32_t id, uint64_t timestamp)
 {
     if (failed || enabled == 0)
         return;
 
     if (!tree.hasSpaceForAdd()) {
-        if (!tree.ensureSpaceBeforeAdd()) {
+        if (tree.size() >= treeSizeFlushLimit() || !tree.ensureSpaceBeforeAdd()) {
             if (!flush()) {
                 fprintf(stderr, "TraceLogging: Couldn't write the data to disk.\n");
                 enabled = 0;
                 failed = true;
                 return;
             }
         }
     }
--- a/js/src/vm/TraceLoggingGraph.h
+++ b/js/src/vm/TraceLoggingGraph.h
@@ -197,16 +197,21 @@ class TraceLoggerGraph
     bool init(uint64_t timestamp);
 
     // Link a textId with a particular text.
     void addTextId(uint32_t id, const char *text);
 
     // Create a tree out of all the given events.
     void log(ContinuousSpace<EventEntry> &events);
 
+    static size_t treeSizeFlushLimit() {
+        // Allow tree size to grow to 100MB.
+        return 100 * 1024 * 1024 / sizeof(TreeEntry);
+    }
+
   private:
     bool failed;
     bool enabled;
     mozilla::DebugOnly<uint32_t> nextTextId;
 
     FILE *dictFile;
     FILE *treeFile;
     FILE *eventFile;