temporary fix for logs

This commit is contained in:
Mark Nadal 2019-09-30 01:12:57 -07:00
parent b3399a4c01
commit 247ddee578
5 changed files with 30 additions and 36 deletions

32
gun.js
View File

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

View File

@ -19,14 +19,12 @@
function GC(){
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;
//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.');
//console.log(+new Date - S, 'gc');
}
/*
root.on('in', function(msg){

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 = true;
var LOG = false;
if(!opt.store){
return opt.log("ERROR: Radisk needs `opt.store` interface with `{get: fn, put: fn (, list: fn)}`!");
@ -48,10 +48,7 @@
val = r.batch(key);
LOG && console.log(+new Date - S, 'rad mem');
if(u !== val){
LOG && (S = +new Date);
var v = r.range(val, o);
LOG && console.log(+new Date - S, 'rad range');
cb(u, v, o);
cb(u, r.range(val, o), o);
if(atomic(val)){ return }
// if a node is requested and some of it is cached... the other parts might not be.
}
@ -273,7 +270,7 @@
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);
console.log(+new Date - S, 'rad read acked');
LOG && console.log(+new Date - S, 'rad read acked');
}
g.ack = function(as){
if(!as.ack){ return }

View File

@ -30,7 +30,7 @@ Gun.on('create', function(root){
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');
//console.log(+new Date - S, 'put loop');
function ack(err, ok){
acks--;
if(ack.err){ return }
@ -43,9 +43,9 @@ Gun.on('create', function(root){
try{opt.store.stats.put.time[statp % 50] = (+new Date) - S; ++statp;
opt.store.stats.put.count++;
}catch(e){} // STATS!
console.log(+new Date - S, 'put'); S = +new Date;
//console.log(+new Date - S, 'put'); S = +new Date;
root.on('in', {'@': id, ok: 1});
console.log(+new Date - S, 'put sent');
//console.log(+new Date - S, 'put sent');
}
});
@ -82,30 +82,29 @@ Gun.on('create', function(root){
if(o.atom){ tmp = (tmp.next||empty)[o.atom] }
if(tmp && tmp.rad){ return }
}
var S = (+new Date); // STATS! // console.log("GET!", id, JSON.stringify(key));
var S = (+new Date); // STATS!
rad(key||'', function(err, data, o){
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!
//if(u === data && o.chunks > 1){ return } // if we already sent a chunk, ignore ending empty responses. // this causes tests to fail.
console.log(+new Date - S, 'got'); S = +new Date;
//console.log(+new Date - S, 'got'); S = +new Date;
if(data){
if(typeof data !== 'string'){
if(o.atom){
data = u;
Radix.map(data, each)
} else {
Radix.map(data, each)
}
}
if(!graph && data){ each(data, '') }
}
console.log(+new Date - S, 'got prep'); S = +new Date;
//console.log(+new Date - S, 'got prep'); S = +new Date;
root.on('in', {'@': id, put: graph, '%': o.more? 1 : u, err: err? err : u, _: each});
console.log(+new Date - S, 'got sent');
//console.log(+new Date - S, 'got sent');
}, o);
console.log(+new Date - S, 'get call');
//console.log(+new Date - S, 'get call');
function each(val, has, a,b){
if(!val){ return }
has = (key+has).split(esc);

View File

@ -1,6 +1,6 @@
{
"name": "gun",
"version": "0.2019.915",
"version": "0.2019.929",
"description": "A realtime, decentralized, offline-first, graph data synchronization engine.",
"main": "index.js",
"browser": "gun.js",