[LNT] r263880 - [profile] Add an admin page to view the current profile stats
James Molloy via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 19 07:46:49 PDT 2016
Author: jamesm
Date: Sat Mar 19 09:46:48 2016
New Revision: 263880
URL: http://llvm.org/viewvc/llvm-project?rev=263880&view=rev
Log:
[profile] Add an admin page to view the current profile stats
This page shows graphs of the total profile size (in MB) and a histogram of the age distribution of the profiles in the cache.
This allows for monitoring of the profile cache makeup. It takes its input from two JSON files that are not yet populated but will be soon.
Added:
lnt/trunk/lnt/server/ui/profile_views.py
lnt/trunk/lnt/server/ui/templates/profile_admin.html
Modified:
lnt/trunk/lnt/server/ui/app.py
lnt/trunk/lnt/server/ui/templates/layout.html
Modified: lnt/trunk/lnt/server/ui/app.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/app.py?rev=263880&r1=263879&r2=263880&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/app.py (original)
+++ lnt/trunk/lnt/server/ui/app.py Sat Mar 19 09:46:48 2016
@@ -24,6 +24,7 @@ import lnt.server.ui.globals
import lnt.server.ui.views
from lnt.testing.util.commands import warning, error
import lnt.server.ui.regression_views
+import lnt.server.ui.profile_views
from lnt.server.ui.api import load_api_resources
import lnt.server.db.rules_manager
Added: lnt/trunk/lnt/server/ui/profile_views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/profile_views.py?rev=263880&view=auto
==============================================================================
--- lnt/trunk/lnt/server/ui/profile_views.py (added)
+++ lnt/trunk/lnt/server/ui/profile_views.py Sat Mar 19 09:46:48 2016
@@ -0,0 +1,41 @@
+from flask import render_template, current_app
+import os, json
+from lnt.server.ui.decorators import v4_route, frontend
+from lnt.server.ui.globals import v4_url_for
+
+ at frontend.route('/profile/admin')
+def profile_admin():
+ profileDir = current_app.old_config.profileDir
+
+ history_path = os.path.join(profileDir, '_profile-history.json')
+ age_path = os.path.join(profileDir, '_profile-age.json')
+
+ try:
+ history = json.loads(open(history_path).read())
+ except:
+ history = []
+ try:
+ age = json.loads(open(age_path).read())
+ except:
+ age = []
+
+ # Convert from UNIX timestamps to Javascript timestamps.
+ history = [[x * 1000, y] for x,y in history]
+ age = [[x * 1000, y] for x,y in age]
+
+ # Calculate a histogram bucket size that shows ~20 bars on the screen
+ num_buckets = 20
+
+ range = max(a[0] for a in age) - min(a[0] for a in age)
+ bucket_size = float(range) / float(num_buckets)
+
+ # Construct the histogram.
+ hist = {}
+ for x,y in age:
+ z = int(float(x) / bucket_size)
+ hist.setdefault(z, 0)
+ hist[z] += y
+ age = [[k * bucket_size, hist[k]] for k in sorted(hist.keys())]
+
+ return render_template("profile_admin.html",
+ history=history, age=age, bucket_size=bucket_size)
Modified: lnt/trunk/lnt/server/ui/templates/layout.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/layout.html?rev=263880&r1=263879&r2=263880&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/layout.html (original)
+++ lnt/trunk/lnt/server/ui/templates/layout.html Sat Mar 19 09:46:48 2016
@@ -172,6 +172,7 @@
<ul class="dropdown-menu">
<li><a href="{{ url_for('log') }}">Logs</a></li>
<li><a href="{{ url_for('rules') }}">Rules</a></li>
+ <li><a href="{{ url_for('profile_admin') }}">Profiles</a></li>
<li><a href="{{ url_for('.static', filename='docs/index.html') }}">Documentation</a></li>
</ul>
</li>
Added: lnt/trunk/lnt/server/ui/templates/profile_admin.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/profile_admin.html?rev=263880&view=auto
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/profile_admin.html (added)
+++ lnt/trunk/lnt/server/ui/templates/profile_admin.html Sat Mar 19 09:46:48 2016
@@ -0,0 +1,55 @@
+{% set nosidebar = True %}
+{% import "utils.html" as utils %}
+
+{% extends "layout.html" %}
+{% set components = [] %}
+
+{% block head %}
+ <script language="javascript" type="text/javascript"
+ src="{{ url_for('.static',
+ filename='flot/jquery.flot.min.js') }}"> </script>
+
+{% endblock %}
+
+{% block title %}Profile admin{% endblock %}
+
+{% block onload %}init_page(){% endblock %}
+
+ {% block javascript %}
+function byteFormatter(val, axis) {
+ if (val > 1000000)
+ return (val / 1000000).toFixed(axis.tickDecimals) + " GB";
+ else if (val > 1000)
+ return (val / 1000).toFixed(axis.tickDecimals) + " MB";
+ else
+ return val.toFixed(axis.tickDecimals) + " kB";
+}
+
+function init_page() {
+ $.plot('#history', [ {{ history|tojson }} ], {
+ xaxis: {mode: 'time'},
+ yaxis: {
+ tickDecimals: 1,
+ tickFormatter: byteFormatter
+ },
+ lines: {steps: true}
+ });
+
+ $.plot('#age', [ {{ age|tojson }} ], {
+ bars: {show: true, barWidth: {{bucket_size}} },
+ xaxis: {mode: 'time'},
+ yaxis: {tickDecimals:1, tickFormatter: byteFormatter}
+ });
+
+}
+{% endblock %}
+
+{% block body %}
+ <h1>Profiles</h1>
+ <h3>Disk space utilization</h3>
+ <div id="history" style="width:80%;height:300px;"></div>
+
+ <h3>Age profile</h3>
+ <div id="age" style="width:80%;height:300px;"></div>
+{% endblock %}
+
More information about the llvm-commits
mailing list