Skip to content

Commit

Permalink
getwork latency graph
Browse files Browse the repository at this point in the history
  • Loading branch information
forrestv committed Oct 27, 2012
1 parent 0ade627 commit c0a834a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions p2pool/bitcoin/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ def go():
else:
return bitcoind.rpc_getmemorypool()
try:
start = time.time()
work = yield go()
end = time.time()
except jsonrpc.Error_for_code(-32601): # Method not found
use_getblocktemplate = not use_getblocktemplate
try:
start = time.time()
work = yield go()
end = time.time()
except jsonrpc.Error_for_code(-32601): # Method not found
print >>sys.stderr, 'Error: Bitcoin version too old! Upgrade to v0.5 or newer!'
raise deferral.RetrySilentlyException()
Expand All @@ -51,6 +55,7 @@ def go():
height=work['height'],
last_update=time.time(),
use_getblocktemplate=use_getblocktemplate,
latency=end - start,
))

@deferral.retry('Error submitting primary block: (will retry)', 10, 10)
Expand Down
4 changes: 4 additions & 0 deletions p2pool/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ def get_total_pool_rate(t):
'desired_version_rates': graph.DataStreamDescription(dataview_descriptions, multivalues=True,
multivalue_undefined_means_0=True, default_func=build_desired_rates),
'traffic_rate': graph.DataStreamDescription(dataview_descriptions, is_gauge=False, multivalues=True),
'getwork_latency': graph.DataStreamDescription(dataview_descriptions),
}, hd_obj)
task.LoopingCall(lambda: _atomic_write(hd_path, json.dumps(hd.to_obj()))).start(100)
@wb.pseudoshare_received.watch
Expand Down Expand Up @@ -431,6 +432,9 @@ def add_point():
hd.datastreams['desired_versions'].add_datum(t, dict((str(k), v/vs_total) for k, v in vs.iteritems()))
hd.datastreams['desired_version_rates'].add_datum(t, dict((str(k), v/vs_total*pool_total) for k, v in vs.iteritems()))
task.LoopingCall(add_point).start(5)
@node.bitcoind_work.changed.watch
def _(new_work):
hd.datastreams['getwork_latency'].add_datum(time.time(), new_work['latency'])
new_root.putChild('graph_data', WebInterface(lambda source, view: hd.datastreams[source].dataviews[view].get_data(time.time())))

web_root.putChild('static', static.File(os.path.join(os.path.dirname(sys.argv[0]), 'web-static')))
Expand Down
7 changes: 7 additions & 0 deletions web-static/graphs.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ <h2>Desired version rates</h2>
<h2>Traffic rate</h2>
<svg id="traffic_rate"></svg>

<h2>Getwork Latency</h2>
<svg id="getwork_latency"></svg>

<script type="text/javascript">
function compose() {
var funcs = arguments;
Expand Down Expand Up @@ -409,6 +412,10 @@ <h2>Traffic rate</h2>
d3.json("/web/graph_data/traffic_rate/last_" + lowerperiod, function(data) {
plot(d3.select('#traffic_rate'), 'B/s', 'B', data_to_lines(data, function(line){ return parseInt(line.label) }), true);
});

plot_later(d3.select("#getwork_latency"), "s", null, [
{"url": "/web/graph_data/getwork_latency/last_" + lowerperiod, "color": "#FF0000", "label": "Getwork Latency"}
], false);
}

d3.json('/local_stats', function(local_stats) {
Expand Down

0 comments on commit c0a834a

Please sign in to comment.