lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Jan 12, 2015 at 12:24 PM, Paul K <paul@zerobrane.com> wrote:
> Hi Oliver,
>
>> This takes care that send() will give other coroutines a chance to run, which is good as otherwise one coroutine may send all the time and no other can be resumed.
>> But why is this behaviour coupled to a probabilistic value?
>
> I think it's mostly for convenience. If you want to say "try this no
> more than 10 times", you need to keep the state somewhere (that you
> already tried X times).


i vaguely remember writing this, but can't be sure that i actually
added this specific code.

Yes, it's a quick solution to a soft problem: if you still have data
to send, it's convenient to allow other tasks to advance, but
typically not the best to do it every small block, so a way out is to
leave it to chance.

if i had determined that doing 10 loops and then yield()ing, then it
would be the same as using chunks 10 times bigger, but i didn't want
to string-intern so big binary objects.... in the end it was just a
workable solution and i think nobody questioned it until now.

i'm sure other heuristics could give better numbers under some
benchmarks, but this wasn't totally bad, so it stayed.



-- 
Javier