зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1272768) for breaking builds in mozharness
Backed out changeset 5dcc540bd8c8 (bug 1272768) Backed out changeset 580cb0cd5a96 (bug 1272768)
This commit is contained in:
Родитель
e24880f068
Коммит
c85d7b355d
|
@ -261,7 +261,7 @@ class BuildMonitor(MozbuildObject):
|
|||
|
||||
self.log_resource_usage(usage)
|
||||
with open(self._get_state_filename('build_resources.json'), 'w') as fh:
|
||||
json.dump(self.resources.as_dict(), fh, indent=2)
|
||||
json.dump(usage, fh, indent=2)
|
||||
except Exception as e:
|
||||
self.log(logging.WARNING, 'build_resources_error',
|
||||
{'msg': str(e)},
|
||||
|
|
|
@ -10,8 +10,6 @@ import BaseHTTPServer
|
|||
import json
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
class HTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
|
@ -38,7 +36,9 @@ class HTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||
self.send_header('Content-Type', 'application/json; charset=utf-8')
|
||||
self.end_headers()
|
||||
|
||||
self.wfile.write(s.json_files[key])
|
||||
with open(s.json_files[key], 'rb') as fh:
|
||||
self.wfile.write(fh.read())
|
||||
|
||||
return
|
||||
|
||||
if p == '/':
|
||||
|
@ -105,15 +105,7 @@ class BuildViewerServer(object):
|
|||
"""Register a resource JSON file with the server.
|
||||
|
||||
The file will be made available under the name/key specified."""
|
||||
with open(path, 'rb') as fh:
|
||||
self.json_files[key] = fh.read()
|
||||
|
||||
def add_resource_json_url(self, key, url):
|
||||
"""Register a resource JSON file at a URL."""
|
||||
r = requests.get(url)
|
||||
if r.status_code != 200:
|
||||
raise Exception('Non-200 HTTP response code')
|
||||
self.json_files[key] = r.text
|
||||
self.json_files[key] = path
|
||||
|
||||
def run(self):
|
||||
while not self.do_shutdown:
|
||||
|
|
|
@ -579,25 +579,19 @@ class Build(MachCommandBase):
|
|||
help='Port number the HTTP server should listen on.')
|
||||
@CommandArgument('--browser', default='firefox',
|
||||
help='Web browser to automatically open. See webbrowser Python module.')
|
||||
@CommandArgument('--url',
|
||||
help='URL of JSON document to display')
|
||||
def resource_usage(self, address=None, port=None, browser=None, url=None):
|
||||
def resource_usage(self, address=None, port=None, browser=None):
|
||||
import webbrowser
|
||||
from mozbuild.html_build_viewer import BuildViewerServer
|
||||
|
||||
last = self._get_state_filename('build_resources.json')
|
||||
if not os.path.exists(last):
|
||||
print('Build resources not available. If you have performed a '
|
||||
'build and receive this message, the psutil Python package '
|
||||
'likely failed to initialize properly.')
|
||||
return 1
|
||||
|
||||
server = BuildViewerServer(address, port)
|
||||
|
||||
if url:
|
||||
server.add_resource_json_url('url', url)
|
||||
else:
|
||||
last = self._get_state_filename('build_resources.json')
|
||||
if not os.path.exists(last):
|
||||
print('Build resources not available. If you have performed a '
|
||||
'build and receive this message, the psutil Python package '
|
||||
'likely failed to initialize properly.')
|
||||
return 1
|
||||
|
||||
server.add_resource_json_file('last', last)
|
||||
server.add_resource_json_file('last', last)
|
||||
try:
|
||||
webbrowser.get(browser).open_new_tab(server.url)
|
||||
except Exception:
|
||||
|
|
|
@ -67,10 +67,10 @@ function BuildResources(data) {
|
|||
var virt_fields = data.virt_fields;
|
||||
var swap_fields = data.swap_fields;
|
||||
|
||||
function convert(dest, source, sourceKey, destKey, fields) {
|
||||
function convert(dest, source, key, fields) {
|
||||
var i = 0;
|
||||
fields.forEach(function (field) {
|
||||
dest[destKey][field] = source[sourceKey][i];
|
||||
dest[key][field] = source[key][i];
|
||||
i++;
|
||||
});
|
||||
}
|
||||
|
@ -85,16 +85,16 @@ function BuildResources(data) {
|
|||
this.ioTotal = {};
|
||||
var i = 0;
|
||||
io_fields.forEach(function (field) {
|
||||
this.ioTotal[field] = data.overall.io[i];
|
||||
this.ioTotal[field] = data.io[i];
|
||||
i++;
|
||||
}.bind(this));
|
||||
|
||||
data.samples.forEach(function (sample) {
|
||||
data.resources.forEach(function (sample) {
|
||||
var entry = {
|
||||
start: sample.start - offset,
|
||||
end: sample.end - offset,
|
||||
duration: sample.duration,
|
||||
cpu_percent: sample.cpu_percent_mean,
|
||||
cpu_percent: sample.cpu_percent,
|
||||
cpu_times: {},
|
||||
cpu_times_percents: {},
|
||||
io: {},
|
||||
|
@ -102,10 +102,10 @@ function BuildResources(data) {
|
|||
swap: {},
|
||||
};
|
||||
|
||||
convert(entry, sample, "cpu_times_sum", "cpu_times", cpu_fields);
|
||||
convert(entry, sample, "io", "io", io_fields);
|
||||
convert(entry, sample, "virt", "virt", virt_fields);
|
||||
convert(entry, sample, "swap", "swap", swap_fields);
|
||||
convert(entry, sample, "cpu_times", cpu_fields);
|
||||
convert(entry, sample, "io", io_fields);
|
||||
convert(entry, sample, "virt", virt_fields);
|
||||
convert(entry, sample, "swap", swap_fields);
|
||||
|
||||
var total = 0;
|
||||
for (var k in entry.cpu_times) {
|
||||
|
@ -179,13 +179,13 @@ BuildResources.prototype = Object.freeze({
|
|||
},
|
||||
|
||||
get cpuPercent() {
|
||||
return this.data.overall.cpu_percent_mean;
|
||||
return this.data.cpu_percent;
|
||||
},
|
||||
|
||||
get tiers() {
|
||||
var t = [];
|
||||
|
||||
this.data.phases.forEach(function (e) {
|
||||
this.data.tiers.forEach(function (e) {
|
||||
t.push(e.name);
|
||||
});
|
||||
|
||||
|
@ -193,8 +193,8 @@ BuildResources.prototype = Object.freeze({
|
|||
},
|
||||
|
||||
getTier: function (tier) {
|
||||
for (var i = 0; i < this.data.phases.length; i++) {
|
||||
var t = this.data.phases[i];
|
||||
for (var i = 0; i < this.data.tiers.length; i++) {
|
||||
var t = this.data.tiers[i];
|
||||
|
||||
if (t.name == tier) {
|
||||
return t;
|
||||
|
@ -403,7 +403,7 @@ function renderResources(id, resources, what) {
|
|||
|
||||
d3.select("#tt_tier").html(entry.tier);
|
||||
d3.select("#tt_duration").html(entry.duration || "n/a");
|
||||
d3.select("#tt_cpu_percent").html(entry.cpu_percent_mean || "n/a");
|
||||
d3.select("#tt_cpu_percent").html(entry.cpu_percent || "n/a");
|
||||
|
||||
d3.select("#tooltip").style("display", "");
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче