debug info

This commit is contained in:
Mark Nadal 2019-09-19 17:00:16 -07:00
parent ef29f181fe
commit 7cd19b3d67
4 changed files with 18 additions and 6 deletions

5
gun.js
View File

@ -1972,12 +1972,14 @@
if('[' === tmp){
try{msg = JSON.parse(raw);}catch(e){opt.log('DAM JSON parse error', e)}
if(!msg){ return }
console.log('hear batch length of', msg.length);
(function go(){
var S = +new Date; // STATS!
var m, c = 100; // hardcoded for now?
while(c-- && (m = msg.shift())){
mesh.hear(m, peer);
}
console.log(+new Date - S, 'hear batch');
(mesh.hear.long || (mesh.hear.long = [])).push(+new Date - S);
if(!msg.length){ return }
puff(go, 0);
@ -1988,6 +1990,7 @@
try{msg = msg || JSON.parse(raw);
}catch(e){return opt.log('DAM JSON parse error', e)}
if(!msg){ return }
if(msg.DBG_s){ console.log(+new Date - msg.DBG_s, 'to hear') }
if(!(id = msg['#'])){ id = msg['#'] = Type.text.random(9) }
if(dup.check(id)){ return }
dup.track(id, true).it = msg; // GUN core also dedups, so `true` is needed. // Does GUN core need to dedup anymore?
@ -2004,7 +2007,9 @@
}
return;
}
var S = +new Date;
root.on('in', msg);
!msg.nts && console.log(+new Date - S, 'msg', msg['#']);
return;
}
}

View File

@ -20,10 +20,12 @@
var souls = Object.keys(root.graph||empty);
var toss = Math.ceil(souls.length * 0.01);
//var start = Gun.state(), i = toss;
var S = +new Date;
Gun.list.map(souls, function(soul){
if(--toss < 0){ return }
root.gun.get(soul).off();
});
console.log(+new Date - S, 'gc');
//console.log("evicted", i, 'nodes in', ((Gun.state() - start)/1000).toFixed(2), 'sec.');
}
/*

View File

@ -19,7 +19,7 @@
function ename(t){ return encodeURIComponent(t).replace(/\*/g, '%2A') }
function atomic(v){ return u !== v && (!v || 'object' != typeof v) }
var map = Gun.obj.map;
var LOG = false;//true;
var LOG = true;
if(!opt.store){
return opt.log("ERROR: Radisk needs `opt.store` interface with `{get: fn, put: fn (, list: fn)}`!");

View File

@ -15,13 +15,14 @@ Gun.on('create', function(root){
this.to.next(msg);
var id = msg['#'] || Gun.text.random(3), track = !msg['@'], acks = track? 0 : u; // only ack non-acks.
if(msg.rad && !track){ return } // don't save our own acks
var start = (+new Date); // STATS!
var S = (+new Date); // STATS!
Gun.graph.is(msg.put, null, function(val, key, node, soul){
if(track){ ++acks }
//console.log('put:', soul, key, val);
val = Radisk.encode(val, null, esc)+'>'+Radisk.encode(Gun.state.is(node, key), null, esc);
rad(soul+esc+key, val, (track? ack : u));
});
console.log(+new Date - S, 'put loop');
function ack(err, ok){
acks--;
if(ack.err){ return }
@ -31,11 +32,12 @@ Gun.on('create', function(root){
return;
}
if(acks){ return }
try{opt.store.stats.put.time[statp % 50] = (+new Date) - start; ++statp;
try{opt.store.stats.put.time[statp % 50] = (+new Date) - S; ++statp;
opt.store.stats.put.count++;
}catch(e){} // STATS!
//console.log("PAT!", id);
console.log(+new Date - S, 'put'); S = +new Date;
root.on('in', {'@': id, ok: 1});
console.log(+new Date - S, 'put sent');
}
});
@ -67,12 +69,13 @@ Gun.on('create', function(root){
o.limit = (tmp <= (o.pack || (1000 * 100)))? tmp : 1;
}
if(has['-'] || (soul||{})['-']){ o.reverse = true }
var start = (+new Date); // STATS! // console.log("GET!", id, JSON.stringify(key));
var S = (+new Date); // STATS! // console.log("GET!", id, JSON.stringify(key));
rad(key||'', function(err, data, o){
try{opt.store.stats.get.time[statg % 50] = (+new Date) - start; ++statg;
try{opt.store.stats.get.time[statg % 50] = (+new Date) - S; ++statg;
opt.store.stats.get.count++;
if(err){ opt.store.stats.get.err = err }
}catch(e){} // STATS!
console.log(+new Date - S, 'got'); S = +new Date;
if(data){
if(typeof data !== 'string'){
if(o.atom){
@ -83,7 +86,9 @@ Gun.on('create', function(root){
}
if(!graph && data){ each(data, '') }
}
console.log(+new Date - S, 'got prep'); S = +new Date;
root.on('in', {'@': id, put: graph, err: err? err : u, rad: Radix});
console.log(+new Date - S, 'got sent');
}, o);
function each(val, has, a,b){
if(!val){ return }