lua-users home
lua-l archive

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


张伟智 <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.