<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[186701] trunk/Source/JavaScriptCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/186701">186701</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2015-07-10 19:30:04 -0700 (Fri, 10 Jul 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>It should be easy to measure total compile times.
https://bugs.webkit.org/show_bug.cgi?id=146857
Reviewed by Sam Weinig.
This gives DFG::Plan the ability to track total compile times, and return them in a map
of stats that jsc.cpp can display.
I want to do some work to bring down DFG compile times. This will help me measure whether
I'm making a difference or not.
* dfg/DFGPlan.cpp:
(JSC::DFG::Plan::Plan):
(JSC::DFG::Plan::~Plan):
(JSC::DFG::Plan::computeCompileTimes):
(JSC::DFG::Plan::reportCompileTimes):
(JSC::DFG::Plan::compileInThread):
(JSC::DFG::Plan::compileInThreadImpl):
(JSC::DFG::Plan::cancel):
(JSC::DFG::Plan::compileTimeStats):
(JSC::DFG::dumpAndVerifyGraph): Deleted.
(JSC::DFG::profilerCompilationKindForMode): Deleted.
* dfg/DFGPlan.h:
(JSC::DFG::Plan::compileTimeStats):
* jsc.cpp:
(jscmain):
* runtime/Options.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGPlancpp">trunk/Source/JavaScriptCore/dfg/DFGPlan.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGPlanh">trunk/Source/JavaScriptCore/dfg/DFGPlan.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejsccpp">trunk/Source/JavaScriptCore/jsc.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeOptionsh">trunk/Source/JavaScriptCore/runtime/Options.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (186700 => 186701)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-07-11 00:40:19 UTC (rev 186700)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-07-11 02:30:04 UTC (rev 186701)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2015-07-10 Filip Pizlo <fpizlo@apple.com>
+
+ It should be easy to measure total compile times.
+ https://bugs.webkit.org/show_bug.cgi?id=146857
+
+ Reviewed by Sam Weinig.
+
+ This gives DFG::Plan the ability to track total compile times, and return them in a map
+ of stats that jsc.cpp can display.
+
+ I want to do some work to bring down DFG compile times. This will help me measure whether
+ I'm making a difference or not.
+
+ * dfg/DFGPlan.cpp:
+ (JSC::DFG::Plan::Plan):
+ (JSC::DFG::Plan::~Plan):
+ (JSC::DFG::Plan::computeCompileTimes):
+ (JSC::DFG::Plan::reportCompileTimes):
+ (JSC::DFG::Plan::compileInThread):
+ (JSC::DFG::Plan::compileInThreadImpl):
+ (JSC::DFG::Plan::cancel):
+ (JSC::DFG::Plan::compileTimeStats):
+ (JSC::DFG::dumpAndVerifyGraph): Deleted.
+ (JSC::DFG::profilerCompilationKindForMode): Deleted.
+ * dfg/DFGPlan.h:
+ (JSC::DFG::Plan::compileTimeStats):
+ * jsc.cpp:
+ (jscmain):
+ * runtime/Options.h:
+
</ins><span class="cx"> 2015-07-04 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><span class="cx"> DFG fragile frozen values are fundamentally broken
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGPlancpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGPlan.cpp (186700 => 186701)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGPlan.cpp        2015-07-11 00:40:19 UTC (rev 186700)
+++ trunk/Source/JavaScriptCore/dfg/DFGPlan.cpp        2015-07-11 02:30:04 UTC (rev 186701)
</span><span class="lines">@@ -91,7 +91,14 @@
</span><span class="cx">
</span><span class="cx"> namespace JSC { namespace DFG {
</span><span class="cx">
</span><del>-static void dumpAndVerifyGraph(Graph& graph, const char* text, bool forceDump = false)
</del><ins>+namespace {
+
+double totalDFGCompileTime;
+double totalFTLCompileTime;
+double totalFTLDFGCompileTime;
+double totalFTLLLVMCompileTime;
+
+void dumpAndVerifyGraph(Graph& graph, const char* text, bool forceDump = false)
</ins><span class="cx"> {
</span><span class="cx"> GraphDumpMode modeForFinalValidate = DumpGraph;
</span><span class="cx"> if (verboseCompilationEnabled(graph.m_plan.mode) || forceDump) {
</span><span class="lines">@@ -103,7 +110,7 @@
</span><span class="cx"> validate(graph, modeForFinalValidate);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static Profiler::CompilationKind profilerCompilationKindForMode(CompilationMode mode)
</del><ins>+Profiler::CompilationKind profilerCompilationKindForMode(CompilationMode mode)
</ins><span class="cx"> {
</span><span class="cx"> switch (mode) {
</span><span class="cx"> case InvalidCompilationMode:
</span><span class="lines">@@ -120,6 +127,8 @@
</span><span class="cx"> return Profiler::DFG;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+} // anonymous namespace
+
</ins><span class="cx"> Plan::Plan(PassRefPtr<CodeBlock> passedCodeBlock, CodeBlock* profiledDFGCodeBlock,
</span><span class="cx"> CompilationMode mode, unsigned osrEntryBytecodeIndex,
</span><span class="cx"> const Operands<JSValue>& mustHandleValues)
</span><span class="lines">@@ -142,6 +151,12 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool Plan::computeCompileTimes() const
+{
+ return reportCompileTimes()
+ || Options::reportTotalCompileTimes();
+}
+
</ins><span class="cx"> bool Plan::reportCompileTimes() const
</span><span class="cx"> {
</span><span class="cx"> return Options::reportCompileTimes()
</span><span class="lines">@@ -154,10 +169,10 @@
</span><span class="cx">
</span><span class="cx"> double before = 0;
</span><span class="cx"> CString codeBlockName;
</span><del>- if (reportCompileTimes()) {
</del><ins>+ if (computeCompileTimes())
</ins><span class="cx"> before = monotonicallyIncreasingTimeMS();
</span><ins>+ if (reportCompileTimes())
</ins><span class="cx"> codeBlockName = toCString(*codeBlock);
</span><del>- }
</del><span class="cx">
</span><span class="cx"> SamplingRegion samplingRegion("DFG Compilation (Plan)");
</span><span class="cx"> CompilationScope compilationScope;
</span><span class="lines">@@ -170,6 +185,19 @@
</span><span class="cx"> RELEASE_ASSERT(path == CancelPath || finalizer);
</span><span class="cx"> RELEASE_ASSERT((path == CancelPath) == (stage == Cancelled));
</span><span class="cx">
</span><ins>+ double after = 0;
+ if (computeCompileTimes())
+ after = monotonicallyIncreasingTimeMS();
+
+ if (Options::reportTotalCompileTimes()) {
+ if (isFTL(mode)) {
+ totalFTLCompileTime += after - before;
+ totalFTLDFGCompileTime += m_timeBeforeFTL - before;
+ totalFTLLLVMCompileTime += after - m_timeBeforeFTL;
+ } else
+ totalDFGCompileTime += after - before;
+ }
+
</ins><span class="cx"> if (reportCompileTimes()) {
</span><span class="cx"> const char* pathName;
</span><span class="cx"> switch (path) {
</span><span class="lines">@@ -192,10 +220,9 @@
</span><span class="cx"> #endif
</span><span class="cx"> break;
</span><span class="cx"> }
</span><del>- double now = monotonicallyIncreasingTimeMS();
- dataLog("Optimized ", codeBlockName, " using ", mode, " with ", pathName, " into ", finalizer ? finalizer->codeSize() : 0, " bytes in ", now - before, " ms");
</del><ins>+ dataLog("Optimized ", codeBlockName, " using ", mode, " with ", pathName, " into ", finalizer ? finalizer->codeSize() : 0, " bytes in ", after - before, " ms");
</ins><span class="cx"> if (path == FTLPath)
</span><del>- dataLog(" (DFG: ", m_timeBeforeFTL - before, ", LLVM: ", now - m_timeBeforeFTL, ")");
</del><ins>+ dataLog(" (DFG: ", m_timeBeforeFTL - before, ", LLVM: ", after - m_timeBeforeFTL, ")");
</ins><span class="cx"> dataLog(".\n");
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -433,7 +460,7 @@
</span><span class="cx"> FTL::State state(dfg);
</span><span class="cx"> FTL::lowerDFGToLLVM(state);
</span><span class="cx">
</span><del>- if (reportCompileTimes())
</del><ins>+ if (computeCompileTimes())
</ins><span class="cx"> m_timeBeforeFTL = monotonicallyIncreasingTimeMS();
</span><span class="cx">
</span><span class="cx"> if (Options::llvmAlwaysFailsBeforeCompile()) {
</span><span class="lines">@@ -612,6 +639,19 @@
</span><span class="cx"> stage = Cancelled;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+HashMap<CString, double> Plan::compileTimeStats()
+{
+ HashMap<CString, double> result;
+ if (Options::reportTotalCompileTimes()) {
+ result.add("Compile Time", totalDFGCompileTime + totalFTLCompileTime);
+ result.add("DFG Compile Time", totalDFGCompileTime);
+ result.add("FTL Compile Time", totalFTLCompileTime);
+ result.add("FTL (DFG) Compile Time", totalFTLDFGCompileTime);
+ result.add("FTL (LLVM) Compile Time", totalFTLLLVMCompileTime);
+ }
+ return result;
+}
+
</ins><span class="cx"> } } // namespace JSC::DFG
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(DFG_JIT)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGPlanh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGPlan.h (186700 => 186701)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGPlan.h        2015-07-11 00:40:19 UTC (rev 186700)
+++ trunk/Source/JavaScriptCore/dfg/DFGPlan.h        2015-07-11 02:30:04 UTC (rev 186701)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -38,7 +38,9 @@
</span><span class="cx"> #include "DeferredCompilationCallback.h"
</span><span class="cx"> #include "Operands.h"
</span><span class="cx"> #include "ProfilerCompilation.h"
</span><ins>+#include <wtf/HashMap.h>
</ins><span class="cx"> #include <wtf/ThreadSafeRefCounted.h>
</span><ins>+#include <wtf/text/CString.h>
</ins><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="cx">
</span><span class="lines">@@ -102,7 +104,10 @@
</span><span class="cx">
</span><span class="cx"> RefPtr<DeferredCompilationCallback> callback;
</span><span class="cx">
</span><ins>+ JS_EXPORT_PRIVATE static HashMap<CString, double> compileTimeStats();
+
</ins><span class="cx"> private:
</span><ins>+ bool computeCompileTimes() const;
</ins><span class="cx"> bool reportCompileTimes() const;
</span><span class="cx">
</span><span class="cx"> enum CompilationPath { FailPath, DFGPath, FTLPath, CancelPath };
</span><span class="lines">@@ -118,6 +123,8 @@
</span><span class="cx">
</span><span class="cx"> class Plan : public RefCounted<Plan> {
</span><span class="cx"> // Dummy class to allow !ENABLE(DFG_JIT) to build.
</span><ins>+public:
+ static HashMap<CString, double> compileTimeStats() { return HashMap<CString, double>(); }
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(DFG_JIT)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejsccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jsc.cpp (186700 => 186701)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jsc.cpp        2015-07-11 00:40:19 UTC (rev 186700)
+++ trunk/Source/JavaScriptCore/jsc.cpp        2015-07-11 02:30:04 UTC (rev 186701)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include "CodeBlock.h"
</span><span class="cx"> #include "Completion.h"
</span><span class="cx"> #include "CopiedSpaceInlines.h"
</span><ins>+#include "DFGPlan.h"
</ins><span class="cx"> #include "Disassembler.h"
</span><span class="cx"> #include "Exception.h"
</span><span class="cx"> #include "ExceptionHelpers.h"
</span><span class="lines">@@ -1556,6 +1557,13 @@
</span><span class="cx"> printf("JSC OSR EXIT FUZZ: encountered %u dynamic checks.\n", numberOfOSRExitFuzzChecks());
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><ins>+ auto compileTimeStats = DFG::Plan::compileTimeStats();
+ Vector<CString> compileTimeKeys;
+ for (auto& entry : compileTimeStats)
+ compileTimeKeys.append(entry.key);
+ std::sort(compileTimeKeys.begin(), compileTimeKeys.end());
+ for (CString key : compileTimeKeys)
+ printf("%40s: %.3lf ms\n", key.data(), compileTimeStats.get(key));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return result;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeOptionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Options.h (186700 => 186701)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Options.h        2015-07-11 00:40:19 UTC (rev 186700)
+++ trunk/Source/JavaScriptCore/runtime/Options.h        2015-07-11 02:30:04 UTC (rev 186701)
</span><span class="lines">@@ -144,6 +144,7 @@
</span><span class="cx"> v(bool, verboseCompilationQueue, false, nullptr) \
</span><span class="cx"> v(bool, reportCompileTimes, false, "dumps JS function signature and the time it took to compile") \
</span><span class="cx"> v(bool, reportFTLCompileTimes, false, "dumps JS function signature and the time it took to FTL compile") \
</span><ins>+ v(bool, reportTotalCompileTimes, false, nullptr) \
</ins><span class="cx"> v(bool, verboseCFA, false, nullptr) \
</span><span class="cx"> v(bool, verboseFTLToJSThunk, false, nullptr) \
</span><span class="cx"> v(bool, verboseFTLFailure, false, nullptr) \
</span></span></pre>
</div>
</div>
</body>
</html>