From 7cd19b3d676f80127cba7ce8e01fc72bcc9df4d6 Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Thu, 19 Sep 2019 17:00:16 -0700 Subject: [PATCH] debug info --- gun.js | 5 +++++ lib/evict.js | 2 ++ lib/radisk.js | 2 +- lib/store.js | 15 ++++++++++----- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/gun.js b/gun.js index 043bf192..554eb197 100644 --- a/gun.js +++ b/gun.js @@ -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; } } diff --git a/lib/evict.js b/lib/evict.js index 6aa2582a..89d3c3ff 100644 --- a/lib/evict.js +++ b/lib/evict.js @@ -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.'); } /* diff --git a/lib/radisk.js b/lib/radisk.js index 5f6a5f09..1f2ba3ac 100644 --- a/lib/radisk.js +++ b/lib/radisk.js @@ -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)}`!"); diff --git a/lib/store.js b/lib/store.js index 56c4dcda..124f0eb5 100644 --- a/lib/store.js +++ b/lib/store.js @@ -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 }