more logs

This commit is contained in:
Mark Nadal 2019-09-20 00:55:09 -07:00
parent 7cd19b3d67
commit 814d330b8a
3 changed files with 25 additions and 1 deletions

12
gun.js
View File

@ -811,16 +811,20 @@
// Maybe... in case the in-memory key we have is a local write // Maybe... in case the in-memory key we have is a local write
// we still need to trigger a pull/merge from peers. // we still need to trigger a pull/merge from peers.
} else { } else {
var S = +new Date;
node = Gun.obj.copy(node); node = Gun.obj.copy(node);
console.log(+new Date - S, 'copy node');
} }
node = Gun.graph.node(node); node = Gun.graph.node(node);
tmp = (at||empty).ack; tmp = (at||empty).ack;
var S = +new Date;
root.on('in', { root.on('in', {
'@': msg['#'], '@': msg['#'],
how: 'mem', how: 'mem',
put: node, put: node,
$: gun $: gun
}); });
console.log(+new Date - S, 'root got send');
//if(0 < tmp){ return } //if(0 < tmp){ return }
root.on('get', msg); root.on('get', msg);
} }
@ -2023,6 +2027,7 @@
if(this.to){ this.to.next(msg) } // compatible with middleware adapters. if(this.to){ this.to.next(msg) } // compatible with middleware adapters.
if(!msg){ return false } if(!msg){ return false }
var id, hash, tmp, raw; var id, hash, tmp, raw;
var S = +new Date;
var meta = msg._||(msg._=function(){}); var meta = msg._||(msg._=function(){});
if(!(id = msg['#'])){ id = msg['#'] = Type.text.random(9) } if(!(id = msg['#'])){ id = msg['#'] = Type.text.random(9) }
if(!(hash = msg['##']) && u !== msg.put){ hash = msg['##'] = Type.obj.hash(msg.put) } if(!(hash = msg['##']) && u !== msg.put){ hash = msg['##'] = Type.obj.hash(msg.put) }
@ -2036,12 +2041,15 @@
} }
} }
} }
console.log(+new Date - S, 'mesh say prep');
dup.track(id).it = msg; // track for 9 seconds, default. Earth<->Mars would need more! dup.track(id).it = msg; // track for 9 seconds, default. Earth<->Mars would need more!
if(!peer){ peer = (tmp = dup.s[msg['@']]) && (tmp = tmp.it) && (tmp = tmp._) && (tmp = tmp.via) } if(!peer){ peer = (tmp = dup.s[msg['@']]) && (tmp = tmp.it) && (tmp = tmp._) && (tmp = tmp.via) }
if(!peer && mesh.way){ return mesh.way(msg) } if(!peer && mesh.way){ return mesh.way(msg) }
if(!peer || !peer.id){ message = msg; if(!peer || !peer.id){ message = msg;
if(!Type.obj.is(peer || opt.peers)){ return false } if(!Type.obj.is(peer || opt.peers)){ return false }
var S = +new Date;
Type.obj.map(peer || opt.peers, each); // in case peer is a peer list. Type.obj.map(peer || opt.peers, each); // in case peer is a peer list.
console.log(+new Date - S, 'mesh say loop');
return; return;
} }
if(!peer.wire && mesh.wire){ mesh.wire(peer) } if(!peer.wire && mesh.wire){ mesh.wire(peer) }
@ -2065,8 +2073,10 @@
peer.batch = peer.tail = null; peer.batch = peer.tail = null;
if(!tmp){ return } if(!tmp){ return }
if(!tmp.length){ return } // if(3 > tmp.length){ return } // TODO: ^ if(!tmp.length){ return } // if(3 > tmp.length){ return } // TODO: ^
var S = +new Date;
try{tmp = (1 === tmp.length? tmp[0] : JSON.stringify(tmp)); try{tmp = (1 === tmp.length? tmp[0] : JSON.stringify(tmp));
}catch(e){return opt.log('DAM JSON stringify error', e)} }catch(e){return opt.log('DAM JSON stringify error', e)}
console.log(+new Date - S, 'mesh flush', tmp.length);
if(!tmp){ return } if(!tmp){ return }
send(tmp, peer); send(tmp, peer);
} }
@ -2076,12 +2086,14 @@
// for now - find better place later. // for now - find better place later.
function send(raw, peer){ try{ function send(raw, peer){ try{
var wire = peer.wire; var wire = peer.wire;
var S = +new Date;
if(peer.say){ if(peer.say){
peer.say(raw); peer.say(raw);
} else } else
if(wire.send){ if(wire.send){
wire.send(raw); wire.send(raw);
} }
console.log(+new Date - S, 'wire send', raw.length);
mesh.say.d += raw.length||0; ++mesh.say.c; // STATS! mesh.say.d += raw.length||0; ++mesh.say.c; // STATS!
}catch(e){ }catch(e){
(peer.queue = peer.queue || []).push(raw); (peer.queue = peer.queue || []).push(raw);

View File

@ -44,9 +44,14 @@
if(val instanceof Function){ if(val instanceof Function){
var o = cb || {}; var o = cb || {};
cb = val; cb = val;
var S; LOG && (S = +new Date);
val = r.batch(key); val = r.batch(key);
LOG && console.log(+new Date - S, 'rad mem');
if(u !== val){ if(u !== val){
cb(u, r.range(val, o), o); LOG && (S = +new Date);
var v = r.range(val, o);
LOG && console.log(+new Date - S, 'rad range');
cb(u, v, o);
if(atomic(val)){ return } if(atomic(val)){ return }
// if a node is requested and some of it is cached... the other parts might not be. // if a node is requested and some of it is cached... the other parts might not be.
} }
@ -230,7 +235,9 @@
r.read = function(key, cb, o){ r.read = function(key, cb, o){
o = o || {}; o = o || {};
if(RAD && !o.next){ // cache if(RAD && !o.next){ // cache
var S; LOG && (S = +new Date);
var val = RAD(key); var val = RAD(key);
LOG && console.log(+new Date - S, 'rad cached');
//if(u !== val){ //if(u !== val){
//cb(u, val, o); //cb(u, val, o);
if(atomic(val)){ cb(u, val, o); return } if(atomic(val)){ cb(u, val, o); return }
@ -243,6 +250,7 @@
file = (u === file)? u : decodeURIComponent(file); file = (u === file)? u : decodeURIComponent(file);
tmp = o.next || key || (o.reverse? o.end || '\uffff' : o.start || ''); tmp = o.next || key || (o.reverse? o.end || '\uffff' : o.start || '');
if(!file || (o.reverse? file < tmp : file > tmp)){ if(!file || (o.reverse? file < tmp : file > tmp)){
LOG && console.log(+new Date - S, 'rad read lex'); S = +new Date;
if(o.next || o.reverse){ g.file = file } if(o.next || o.reverse){ g.file = file }
if(tmp = Q[g.file]){ if(tmp = Q[g.file]){
tmp.push({key: key, ack: cb, file: g.file, opt: o}); tmp.push({key: key, ack: cb, file: g.file, opt: o});
@ -263,7 +271,9 @@
g.info = info; g.info = info;
if(disk){ RAD = g.disk = disk } if(disk){ RAD = g.disk = disk }
disk = Q[g.file]; delete Q[g.file]; disk = Q[g.file]; delete Q[g.file];
LOG && console.log(+new Date - S, 'rad read it in, now ack to:', disk.length); S = +new Date;
map(disk, g.ack); map(disk, g.ack);
console.log(+new Date - S, 'rad read acked');
} }
g.ack = function(as){ g.ack = function(as){
if(!as.ack){ return } if(!as.ack){ return }
@ -282,6 +292,7 @@
r.read(tmp, as.ack, o); r.read(tmp, as.ack, o);
} }
if(o.reverse){ g.lex.reverse = true } if(o.reverse){ g.lex.reverse = true }
LOG && (S = +new Date);
r.list(g.lex); r.list(g.lex);
} }
function rev(a,b){ return b } function rev(a,b){ return b }

View File

@ -90,6 +90,7 @@ Gun.on('create', function(root){
root.on('in', {'@': id, put: graph, err: err? err : u, rad: Radix}); root.on('in', {'@': id, put: graph, err: err? err : u, rad: Radix});
console.log(+new Date - S, 'got sent'); console.log(+new Date - S, 'got sent');
}, o); }, o);
console.log(+new Date - S, 'get call');
function each(val, has, a,b){ function each(val, has, a,b){
if(!val){ return } if(!val){ return }
has = (key+has).split(esc); has = (key+has).split(esc);