After a "bad collections", avoid switching back back to generational

After a major bad collection (one that collects too few objects),
next collection will be major again. In that case, avoid switching
back to generational mode (as it will have to switch again to
incremental to do next major collection).
This commit is contained in:
Roberto Ierusalimschy
2019-01-30 11:44:42 -02:00
parent 264659bd53
commit 2c32bff609
6 changed files with 135 additions and 51 deletions

6
lapi.c
View File

@@ -1141,22 +1141,21 @@ LUA_API int lua_gc (lua_State *L, int what, ...) {
break;
}
case LUA_GCGEN: {
int oldmode = g->gckind;
int minormul = va_arg(argp, int);
int majormul = va_arg(argp, int);
res = isdecGCmodegen(g) ? LUA_GCGEN : LUA_GCINC;
if (minormul != 0)
g->genminormul = minormul;
if (majormul != 0)
setgcparam(g->genmajormul, majormul);
luaC_changemode(L, KGC_GEN);
res = (oldmode == KGC_GEN) ? LUA_GCGEN : LUA_GCINC;
break;
}
case LUA_GCINC: {
int oldmode = g->gckind;
int pause = va_arg(argp, int);
int stepmul = va_arg(argp, int);
int stepsize = va_arg(argp, int);
res = isdecGCmodegen(g) ? LUA_GCGEN : LUA_GCINC;
if (pause != 0)
setgcparam(g->gcpause, pause);
if (stepmul != 0)
@@ -1164,7 +1163,6 @@ LUA_API int lua_gc (lua_State *L, int what, ...) {
if (stepsize != 0)
g->gcstepsize = stepsize;
luaC_changemode(L, KGC_INC);
res = (oldmode == KGC_GEN) ? LUA_GCGEN : LUA_GCINC;
break;
}
default: res = -1; /* invalid option */