<!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>[203633] trunk/Websites/perf.webkit.org</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/203633">203633</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2016-07-22 23:11:33 -0700 (Fri, 22 Jul 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>REGRESSION(<a href="http://trac.webkit.org/projects/webkit/changeset/203035">r203035</a>): Marking points as an outlier no longer updates charts
https://bugs.webkit.org/show_bug.cgi?id=160106

Reviewed by Darin Adler.

The bug was caused by MeasurementSet's fetchBetween clearing previously registered callbacks when noCache
option is specified.

* public/v3/components/time-series-chart.js:
(TimeSeriesChart.prototype.setSourceList): Clear this._fetchedTimeSeries when changing chart options.
e.g. need to start including or excluding outliers.
(TimeSeriesChart.prototype.fetchMeasurementSets): Don't skip the fetching when noCache is true.

* public/v3/models/measurement-set.js:
(MeasurementSet): Added this._callbackMap as an instance variable to keep track of all callbacks on every
cluster since we may need to call each callback multiple times per cluster when noCache option is used.
(MeasurementSet.prototype.fetchBetween): Moved the code to add _primaryClusterPromise to _allFetches here
so that now this function and _ensureClusterPromise are only functions that touch _allFetches.
(MeasurementSet.prototype._ensureClusterPromise): Extracted out of fetchBetween. Queue up all callbacks
for each cluster when creating a new promise.
(MeasurementSet.prototype._fetchPrimaryCluster): Removed the code to add _primaryClusterPromise now that
it's done in fetchBetween.

* public/v3/remote.js:
(RemoteAPI.postJSONWithStatus): Removed superfluous call to console.log.

* unit-tests/measurement-set-tests.js: Updated the test case for noCache. The callback registered before
fetchBetween is called with noCache=true is now invoked so callCount must be 3 instead of 2.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebsitesperfwebkitorgChangeLog">trunk/Websites/perf.webkit.org/ChangeLog</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv3componentstimeserieschartjs">trunk/Websites/perf.webkit.org/public/v3/components/time-series-chart.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv3modelsmeasurementsetjs">trunk/Websites/perf.webkit.org/public/v3/models/measurement-set.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv3remotejs">trunk/Websites/perf.webkit.org/public/v3/remote.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgunittestsmeasurementsettestsjs">trunk/Websites/perf.webkit.org/unit-tests/measurement-set-tests.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebsitesperfwebkitorgChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/ChangeLog (203632 => 203633)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/ChangeLog        2016-07-23 06:01:15 UTC (rev 203632)
+++ trunk/Websites/perf.webkit.org/ChangeLog        2016-07-23 06:11:33 UTC (rev 203633)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2016-07-22  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        REGRESSION(r203035): Marking points as an outlier no longer updates charts
+        https://bugs.webkit.org/show_bug.cgi?id=160106
+
+        Reviewed by Darin Adler.
+
+        The bug was caused by MeasurementSet's fetchBetween clearing previously registered callbacks when noCache
+        option is specified.
+
+        * public/v3/components/time-series-chart.js:
+        (TimeSeriesChart.prototype.setSourceList): Clear this._fetchedTimeSeries when changing chart options.
+        e.g. need to start including or excluding outliers.
+        (TimeSeriesChart.prototype.fetchMeasurementSets): Don't skip the fetching when noCache is true.
+
+        * public/v3/models/measurement-set.js:
+        (MeasurementSet): Added this._callbackMap as an instance variable to keep track of all callbacks on every
+        cluster since we may need to call each callback multiple times per cluster when noCache option is used.
+        (MeasurementSet.prototype.fetchBetween): Moved the code to add _primaryClusterPromise to _allFetches here
+        so that now this function and _ensureClusterPromise are only functions that touch _allFetches.
+        (MeasurementSet.prototype._ensureClusterPromise): Extracted out of fetchBetween. Queue up all callbacks
+        for each cluster when creating a new promise.
+        (MeasurementSet.prototype._fetchPrimaryCluster): Removed the code to add _primaryClusterPromise now that
+        it's done in fetchBetween.
+
+        * public/v3/remote.js:
+        (RemoteAPI.postJSONWithStatus): Removed superfluous call to console.log.
+
+        * unit-tests/measurement-set-tests.js: Updated the test case for noCache. The callback registered before
+        fetchBetween is called with noCache=true is now invoked so callCount must be 3 instead of 2.
+
</ins><span class="cx"> 2016-07-19  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Perf dashboard always re-generate measurement set JSON
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv3componentstimeserieschartjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v3/components/time-series-chart.js (203632 => 203633)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v3/components/time-series-chart.js        2016-07-23 06:01:15 UTC (rev 203632)
+++ trunk/Websites/perf.webkit.org/public/v3/components/time-series-chart.js        2016-07-23 06:11:33 UTC (rev 203633)
</span><span class="lines">@@ -83,6 +83,7 @@
</span><span class="cx">     {
</span><span class="cx">         this._sourceList = sourceList;
</span><span class="cx">         this.fetchMeasurementSets(false);
</span><ins>+        this._fetchedTimeSeries = null;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     fetchMeasurementSets(noCache)
</span><span class="lines">@@ -90,7 +91,7 @@
</span><span class="cx">         var fetching = false;
</span><span class="cx">         for (var source of this._sourceList) {
</span><span class="cx">             if (source.measurementSet) {
</span><del>-                if (source.measurementSet.hasFetchedRange(this._startTime, this._endTime))
</del><ins>+                if (!noCache &amp;&amp; source.measurementSet.hasFetchedRange(this._startTime, this._endTime))
</ins><span class="cx">                     continue;
</span><span class="cx">                 source.measurementSet.fetchBetween(this._startTime, this._endTime, this._didFetchMeasurementSet.bind(this, source.measurementSet), noCache);
</span><span class="cx">                 fetching = true;
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv3modelsmeasurementsetjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v3/models/measurement-set.js (203632 => 203633)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v3/models/measurement-set.js        2016-07-23 06:01:15 UTC (rev 203632)
+++ trunk/Websites/perf.webkit.org/public/v3/models/measurement-set.js        2016-07-23 06:11:33 UTC (rev 203633)
</span><span class="lines">@@ -16,6 +16,7 @@
</span><span class="cx">         this._clusterStart = null;
</span><span class="cx">         this._clusterSize = null;
</span><span class="cx">         this._allFetches = {};
</span><ins>+        this._callbackMap = new Map;
</ins><span class="cx">         this._primaryClusterPromise = null;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -61,22 +62,38 @@
</span><span class="cx">             this._primaryClusterPromise = null;
</span><span class="cx">             this._allFetches = {};
</span><span class="cx">         }
</span><del>-        if (!this._primaryClusterPromise || noCache)
</del><ins>+        if (!this._primaryClusterPromise)
</ins><span class="cx">             this._primaryClusterPromise = this._fetchPrimaryCluster(noCache);
</span><span class="cx">         var self = this;
</span><span class="cx">         this._primaryClusterPromise.catch(callback);
</span><span class="cx">         return this._primaryClusterPromise.then(function () {
</span><del>-            var promiseList = [];
-            self.findClusters(startTime, endTime).map(function (clusterEndTime) {
-                if(!self._allFetches[clusterEndTime])
-                    self._allFetches[clusterEndTime] = self._fetchSecondaryCluster(clusterEndTime);
-                self._allFetches[clusterEndTime].then(callback, callback);
-                promiseList.push(self._allFetches[clusterEndTime]);
-            });
-            return Promise.all(promiseList);
</del><ins>+            self._allFetches[self._primaryClusterEndTime] = self._primaryClusterPromise;
+            return Promise.all(self.findClusters(startTime, endTime).map(function (clusterEndTime) {
+                return self._ensureClusterPromise(clusterEndTime, callback);
+            }));
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    _ensureClusterPromise(clusterEndTime, callback)
+    {
+        if (!this._callbackMap.has(clusterEndTime))
+            this._callbackMap.set(clusterEndTime, new Set);
+        var callbackSet = this._callbackMap.get(clusterEndTime);
+        callbackSet.add(callback);
+
+        var promise = this._allFetches[clusterEndTime];
+        if (promise)
+            promise.then(callback, callback);
+        else {
+            promise = this._fetchSecondaryCluster(clusterEndTime);
+            for (var existingCallback of callbackSet)
+                promise.then(existingCallback, existingCallback);
+            this._allFetches[clusterEndTime] = promise;
+        }
+
+        return promise;
+    }
+
</ins><span class="cx">     _constructUrl(useCache, clusterEndTime)
</span><span class="cx">     {
</span><span class="cx">         if (!useCache) {
</span><span class="lines">@@ -96,7 +113,6 @@
</span><span class="cx">         if (noCache) {
</span><span class="cx">             return RemoteAPI.getJSONWithStatus(self._constructUrl(false, null)).then(function (data) {
</span><span class="cx">                 self._didFetchJSON(true, data);
</span><del>-                self._allFetches[self._primaryClusterEndTime] = self._primaryClusterPromise;
</del><span class="cx">             });
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -110,7 +126,6 @@
</span><span class="cx">             return Promise.reject(error);
</span><span class="cx">         }).then(function (data) {
</span><span class="cx">             self._didFetchJSON(true, data);
</span><del>-            self._allFetches[self._primaryClusterEndTime] = self._primaryClusterPromise;
</del><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv3remotejs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v3/remote.js (203632 => 203633)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v3/remote.js        2016-07-23 06:01:15 UTC (rev 203632)
+++ trunk/Websites/perf.webkit.org/public/v3/remote.js        2016-07-23 06:11:33 UTC (rev 203633)
</span><span class="lines">@@ -9,7 +9,6 @@
</span><span class="cx"> 
</span><span class="cx"> RemoteAPI.postJSONWithStatus = function (path, data)
</span><span class="cx"> {
</span><del>-    console.log(document.cookie);
</del><span class="cx">     return this.getJSONWithStatus(path, data || {});
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgunittestsmeasurementsettestsjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/unit-tests/measurement-set-tests.js (203632 => 203633)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/unit-tests/measurement-set-tests.js        2016-07-23 06:01:15 UTC (rev 203632)
+++ trunk/Websites/perf.webkit.org/unit-tests/measurement-set-tests.js        2016-07-23 06:11:33 UTC (rev 203633)
</span><span class="lines">@@ -373,7 +373,7 @@
</span><span class="cx"> 
</span><span class="cx">                 return waitForMeasurementSet();
</span><span class="cx">             }).then(function () {
</span><del>-                assert.equal(callCount, 2);
</del><ins>+                assert.equal(callCount, 3);
</ins><span class="cx">                 assert.equal(noCacheFetchCount, 2);
</span><span class="cx">                 assert.equal(set._sortedClusters.length, 2);
</span><span class="cx">                 assert.equal(requests.length, 4);
</span></span></pre>
</div>
</div>

</body>
</html>