rindex 1M !!!

This commit is contained in:
Mark Nadal 2019-03-23 18:07:07 -07:00
parent bc742aab0d
commit d3b048085d
3 changed files with 21 additions and 22 deletions

32
gun.js
View File

@ -1360,22 +1360,18 @@
// #soul.has=value>state // #soul.has=value>state
// ~who#where.where=what>when@was // ~who#where.where=what>when@was
// TODO: BUG! Put probably cannot handle plural chains! // TODO: BUG! Put probably cannot handle plural chains!
var gun = this, at = (gun._), root = at.root.$, ctx = root._, tmp; var gun = this, at = (gun._), root = at.root.$, ctx = root._, M = 100, tmp;
/*if(tmp = ctx.puts){ if(!ctx.puta){ if(tmp = ctx.puts){ if(tmp > M){ // without this, when synchronous, writes to a 'not found' pile up, when 'not found' resolves it recursively calls `put` which incrementally resolves each write. Stack overflow limits can be as low as 10K, so this limit is hardcoded to 1% of 10K.
if(tmp > 100){ // without this, when synchronous, writes to a 'not found' pile up, when 'not found' resolves it recursively calls `put` which incrementally resolves each write. Stack overflow limits can be as low as 10K, so this limit is hardcoded to 1% of 10K. (ctx.stack || (ctx.stack = [])).push([gun, data, cb, as]);
(ctx.stack || (ctx.stack = [])).push([gun, data, cb, as]); if(ctx.puto){ return }
clearTimeout(ctx.puto); ctx.puto = setTimeout(function drain(){
ctx.puto = setTimeout(function(){ var d = ctx.stack.splice(0,M), i = 0, at; ctx.puta = true;
var stack = ctx.stack, i = 0, tmp; while(at = d[i++]){ at[0].put(at[1], at[2], at[3]) } delete ctx.puta;
ctx.stack = ctx.puts = ctx.puto = null; if(ctx.stack.length){ return ctx.puto = setTimeout(drain, 0) }
while(tmp = stack[i++]){ ctx.stack = ctx.puts = ctx.puto = null;
tmp[0].put(tmp[1], tmp[2], tmp[3]); }, 0);
} return gun;
}, ctx.opt.wait || 1); } ++ctx.puts } else { ctx.puts = 1 } }
return gun;
}
++ctx.puts;
} else { ctx.puts = 1 }*/
as = as || {}; as = as || {};
as.data = data; as.data = data;
as.via = as.$ = as.via || as.$ || gun; as.via = as.$ = as.via || as.$ || gun;
@ -1470,7 +1466,7 @@
if(!ack.lack){ this.off() } // One response is good enough for us currently. Later we may want to adjust this. if(!ack.lack){ this.off() } // One response is good enough for us currently. Later we may want to adjust this.
if(!as.ack){ return } if(!as.ack){ return }
as.ack(ack, this); as.ack(ack, this);
// --C; //--C;
}, as.opt); }, as.opt);
//C++; //C++;
// NOW is a hack to get synchronous replies to correctly call. // NOW is a hack to get synchronous replies to correctly call.
@ -1487,7 +1483,7 @@
}, as); }, as);
if(as.res){ as.res() } if(as.res){ as.res() }
} function no(v,k){ if(v){ return true } } } function no(v,k){ if(v){ return true } }
//console.debug(999,1); var C = 0; setInterval(function(){ try{ debugg.innerHTML = C }catch(e){console.log(e)} }, 500); //console.debug(999,1); var C = 0; setInterval(function(){ try{ debug.innerHTML = C }catch(e){console.log(e)} }, 500);
function map(v,k,n, at){ var as = this; function map(v,k,n, at){ var as = this;
var is = Gun.is(v); var is = Gun.is(v);

View File

@ -13,8 +13,8 @@
<button onclick="read()">read</button> <button onclick="read()">read</button>
<input id="wait" placeholder="wait" type="number"> <input id="wait" placeholder="wait" type="number">
<input id="burst" placeholder="burst" type="number"> <input id="burst" placeholder="burst" type="number">
<div id='debugs'></div>
<div id='debug'></div> <div id='debug'></div>
<div id='debugg'></div>
<script> <script>
Gun.TESTING = true; Gun.TESTING = true;
@ -32,7 +32,7 @@ burst.onchange = function(){ spam.burst = this.value }
function spam(){ function spam(){
//spam.max = 100000; spam.left = spam.max; spam.wait = 1; spam.burst = 250; spam.c = 0; spam.s = (+new Date); //spam.max = 100000; spam.left = spam.max; spam.wait = 1; spam.burst = 250; spam.c = 0; spam.s = (+new Date);
//spam.max = 100000; spam.left = spam.max; spam.wait = 1; spam.burst = 100; spam.c = 0; spam.s = (+new Date); //spam.max = 100000; spam.left = spam.max; spam.wait = 1; spam.burst = 100; spam.c = 0; spam.s = (+new Date);
spam.max = 1000000; spam.left = spam.max; spam.wait = 50; spam.burst = 1; spam.c = 0; spam.s = (+new Date); spam.max = 1000000; spam.left = spam.max; spam.wait = 1; spam.burst = 250; spam.c = 0; spam.s = (+new Date);
//spam.max = 100; spam.left = spam.max; spam.wait = 1; spam.burst = 1; spam.c = 0; spam.s = (+new Date); //spam.max = 100; spam.left = spam.max; spam.wait = 1; spam.burst = 1; spam.c = 0; spam.s = (+new Date);
var to = setInterval(function(){ var b = spam.burst; var to = setInterval(function(){ var b = spam.burst;
if(spam.c >= spam.max){ clearTimeout(to); return; } if(spam.c >= spam.max){ clearTimeout(to); return; }
@ -56,7 +56,7 @@ function spam(){
if(spam.end){ spam.end = true } if(spam.end){ spam.end = true }
var t = (+new Date) - spam.s, tmp, sec; var t = (+new Date) - spam.s, tmp, sec;
var status = 'saved\n'+ (tmp = (spam.max - spam.left)) +' in '+ (sec = (t/1000)) +' seconds\n'+ Math.round(tmp / sec) +' per second'; var status = 'saved\n'+ (tmp = (spam.max - spam.left)) +' in '+ (sec = (t/1000)) +' seconds\n'+ Math.round(tmp / sec) +' per second';
debug.innerText = status; debugs.innerText = status;
}, 500); }, 500);
} }
</script> </script>

View File

@ -14,8 +14,10 @@
<input id="find" placeholder="find contacts..."> <input id="find" placeholder="find contacts...">
<ul> <ul>
</ul> </ul>
<div id='debug'></div>
<script> <script>
try{localStorage.clear()}catch(e){} try{localStorage.clear()}catch(e){};
indexedDB.deleteDatabase('radata');
//var gun = Gun('http://localhost:8765/gun'); //var gun = Gun('http://localhost:8765/gun');
var gun = Gun({localStorage: false}); var gun = Gun({localStorage: false});
@ -40,6 +42,7 @@
},9) },9)
}); });
}); });
console.log("end forEach:", (+new Date) - start);
}); });
var to; var to;