mirror of
https://github.com/amark/gun.git
synced 2025-07-04 03:42:33 +00:00
stub dup gc
This commit is contained in:
parent
6d56aaa233
commit
5ef549a4a8
@ -44,7 +44,7 @@
|
|||||||
<script src="./jquery.js"></script>
|
<script src="./jquery.js"></script>
|
||||||
<script src="./smoothie.js" charset="utf-8"></script>
|
<script src="./smoothie.js" charset="utf-8"></script>
|
||||||
<script>
|
<script>
|
||||||
var up, br = 0, bt = 0;
|
var up, br = 0, bt = 0, tmp;
|
||||||
var fetchData = async function(){
|
var fetchData = async function(){
|
||||||
// fetch the data from server
|
// fetch the data from server
|
||||||
var S = +new Date;
|
var S = +new Date;
|
||||||
@ -58,6 +58,14 @@
|
|||||||
$('#hours').text((data.up.time / 60 / 60).toFixed(1));
|
$('#hours').text((data.up.time / 60 / 60).toFixed(1));
|
||||||
if(data.up.time === up){ console.log("up same as before") } up = data.up.time;
|
if(data.up.time === up){ console.log("up same as before") } up = data.up.time;
|
||||||
|
|
||||||
|
;(async function(){ try{
|
||||||
|
Stats('peers#').line.append(+new Date, data.peers.count);
|
||||||
|
Stats('cpu%');
|
||||||
|
tmp = await (await fetch(new Request(location.origin+'/gun/stats.top.radata'), {method: 'GET',mode: 'cors'})).text();
|
||||||
|
tmp = parseFloat((tmp.split('\n').filter(l => l.indexOf('node')+1)[0]||'').split(/\s+/).slice(-4)[0]||'0');
|
||||||
|
Stats('cpu%').line.append(+new Date, tmp);
|
||||||
|
}catch(e){console.log(e)}}());
|
||||||
|
|
||||||
Stats('memory').line.append(+new Date, data.memory.heapTotal / 1024 / 1024);
|
Stats('memory').line.append(+new Date, data.memory.heapTotal / 1024 / 1024);
|
||||||
try{ Stats('dam # in/s').line.append(+new Date, Math.round(data.dam.in.count / data.over)); }catch(e){}
|
try{ Stats('dam # in/s').line.append(+new Date, Math.round(data.dam.in.count / data.over)); }catch(e){}
|
||||||
try{ Stats('dam in MB/s').line.append(+new Date, data.dam.in.done / 1024 / 1024 / data.over); }catch(e){}
|
try{ Stats('dam in MB/s').line.append(+new Date, data.dam.in.done / 1024 / 1024 / data.over); }catch(e){}
|
||||||
@ -65,6 +73,7 @@
|
|||||||
try{ Stats('dam out MB/s').line.append(+new Date, data.dam.out.done / 1024 / 1024 / data.over); }catch(e){}
|
try{ Stats('dam out MB/s').line.append(+new Date, data.dam.out.done / 1024 / 1024 / data.over); }catch(e){}
|
||||||
|
|
||||||
console.log('data',data);
|
console.log('data',data);
|
||||||
|
|
||||||
//fetch keys in all, these may be dynamically changing
|
//fetch keys in all, these may be dynamically changing
|
||||||
//for each key, check if we already have created a time series, if not, create it and add it
|
//for each key, check if we already have created a time series, if not, create it and add it
|
||||||
// to the chart corredsponding to the unit of measure
|
// to the chart corredsponding to the unit of measure
|
||||||
@ -77,7 +86,7 @@
|
|||||||
// append data [timestamp], [data]
|
// append data [timestamp], [data]
|
||||||
chart.line.append(arr[i][0], arr[i][1]);
|
chart.line.append(arr[i][0], arr[i][1]);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
setInterval(fetchData, 15 * 1000);
|
setInterval(fetchData, 15 * 1000);
|
||||||
fetchData();
|
fetchData();
|
||||||
|
9
gun.js
9
gun.js
@ -182,7 +182,7 @@
|
|||||||
USE('./shim');
|
USE('./shim');
|
||||||
function Dup(opt){
|
function Dup(opt){
|
||||||
var dup = {s:{}}, s = dup.s;
|
var dup = {s:{}}, s = dup.s;
|
||||||
opt = opt || {max: 999, age: /*1000 * 9};//*/ 1000 * 9 * 3};
|
opt = opt || {max: 999, age: 1000 * 9};//*/ 1000 * 9 * 3};
|
||||||
dup.check = function(id){
|
dup.check = function(id){
|
||||||
if(!s[id]){ return false }
|
if(!s[id]){ return false }
|
||||||
return dt(id);
|
return dt(id);
|
||||||
@ -196,6 +196,7 @@
|
|||||||
dup.drop = function(age){
|
dup.drop = function(age){
|
||||||
dup.to = null;
|
dup.to = null;
|
||||||
dup.now = +new Date;
|
dup.now = +new Date;
|
||||||
|
dup.s = s = {};return;
|
||||||
setTimeout.each(Object.keys(s), function(id){ var it = s[id]; // TODO: .keys( is slow
|
setTimeout.each(Object.keys(s), function(id){ var it = s[id]; // TODO: .keys( is slow
|
||||||
if(it && (age || opt.age) > (dup.now - it.was)){ return }
|
if(it && (age || opt.age) > (dup.now - it.was)){ return }
|
||||||
delete s[id];
|
delete s[id];
|
||||||
@ -1157,7 +1158,7 @@
|
|||||||
var stat = console.STAT || {};
|
var stat = console.STAT || {};
|
||||||
//console.log('HEAR:', peer.id, (raw||'').slice(0,250), ((raw||'').length / 1024 / 1024).toFixed(4));
|
//console.log('HEAR:', peer.id, (raw||'').slice(0,250), ((raw||'').length / 1024 / 1024).toFixed(4));
|
||||||
|
|
||||||
console.log(setTimeout.turn.s.length, 'stacks', parseFloat((-(LT - (LT = +new Date))/1000).toFixed(3)), 'sec', parseFloat(((LT-ST)/1000 / 60).toFixed(1)), 'up', stat.peers||0, 'peers', stat.has||0, 'has', stat.memhused, stat.memused, stat.memax, 'heap mem max');
|
console.log(setTimeout.turn.s.length, 'stacks', parseFloat((-(LT - (LT = +new Date))/1000).toFixed(3)), 'sec', parseFloat(((LT-ST)/1000 / 60).toFixed(1)), 'up', stat.peers||0, 'peers', stat.has||0, 'has', stat.memhused||0, stat.memused||0, stat.memax||0, 'heap mem max');
|
||||||
}catch(e){ console.log('DBG err', e) }}
|
}catch(e){ console.log('DBG err', e) }}
|
||||||
|
|
||||||
hear.d += raw.length||0 ; ++hear.c } // STATS!
|
hear.d += raw.length||0 ; ++hear.c } // STATS!
|
||||||
@ -1239,7 +1240,7 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
var say = mesh.say = function(msg, peer){ var tmp;
|
var say = mesh.say = function(msg, peer){ var tmp;
|
||||||
return; // TODO: MANHATTAN STUB //OBVIOUSLY BUG! But squelch relay.
|
//return; // TODO: MANHATTAN STUB //OBVIOUSLY BUG! But squelch relay.
|
||||||
if((tmp = this) && (tmp = tmp.to) && tmp.next){ tmp.next(msg) } // compatible with middleware adapters.
|
if((tmp = this) && (tmp = tmp.to) && tmp.next){ tmp.next(msg) } // compatible with middleware adapters.
|
||||||
if(!msg){ return false }
|
if(!msg){ return false }
|
||||||
var id, hash, raw, ack = msg['@'];
|
var id, hash, raw, ack = msg['@'];
|
||||||
@ -1415,7 +1416,7 @@
|
|||||||
|
|
||||||
var gets = {};
|
var gets = {};
|
||||||
root.on('bye', function(peer, tmp){ this.to.next(peer);
|
root.on('bye', function(peer, tmp){ this.to.next(peer);
|
||||||
if(tmp = console.STAT){ tmp.peers = (tmp.peers || 0) - 1 }
|
if(tmp = console.STAT){ tmp.peers = (tmp.peers || 0) - 1; console.log('bye', tmp.peers) }
|
||||||
if(!(tmp = peer.url)){ return } gets[tmp] = true;
|
if(!(tmp = peer.url)){ return } gets[tmp] = true;
|
||||||
setTimeout(function(){ delete gets[tmp] },opt.lack || 9000);
|
setTimeout(function(){ delete gets[tmp] },opt.lack || 9000);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user