lua-users home
lua-l archive

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


On 9/29/2016 4:00 AM, 云风 Cloud Wu wrote:
> 张伟智 <robotkzhang@gmail.com <mailto:robotkzhang@gmail.com>>于2016年9月
> 27日周二 下午5:02写道:
> 
>     The while loop  call singlestep() until debt decrease to -GCSTEPSIZE.
>     When the g->GCDebt is big, singlestep() will be called for many many
>     times,
> 
> 
> I suggest patch the setpause() (lua 5.3.3):
> 
> diff --git a/src/lgc.c b/src/lgc.c
> index 7c29fb0..df26798 100644
> --- a/src/lgc.c
> +++ b/src/lgc.c
> @@ -942,6 +942,8 @@ static void setpause (global_State *g) {
>              ? estimate * g->gcpause  /* no overflow */
>              : MAX_LMEM;  /* overflow; truncate to maximum */
>    debt = gettotalbytes(g) - threshold;
> +  if (debt > 0)
> +    debt = 0;
>    luaE_setdebt(g, debt);
>  }
> 
> A large positive debt number would stop the world, I think we should
> avoid it.
> 

g->gcpause should be set to 100 when a pause combined with a large
individual step are not desired. If threshold and gettotalbytes(g) are
'accurate', then that is all that is required. If they can be off, then
you would want a check that says:

if (g->gcpause == 100) {
  luaE_setdebt(g, 0);
  return;
}

That would guarantee a there is not a pause and that collection does not
have an unnecessarily large step. The OP used a ratio of 90, which does
suggest that a large, upfront step is desired, since that's the only way
to achieve the intended semantics. Basically, values below 100 and above
0 request partially incremental collection and 0 requests
non-incremental collection and I suppose being able to request those is
useful given that 100 is the appropriate middle ground.

Anyways, is there data that suggests that a value of 100 misbehaves?