diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-09-03 11:14:01 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-09-03 11:14:01 -0300 |
commit | 6828f6d42786de735d6696da8cccbb47c8bad347 (patch) | |
tree | 4645194f43ebcfbd7a00af35278b1e688148760c | |
parent | daa5fe3e31d8ca28a8770df135cbad7fa6fdfa4b (diff) | |
download | lua-6828f6d42786de735d6696da8cccbb47c8bad347.tar.gz lua-6828f6d42786de735d6696da8cccbb47c8bad347.tar.bz2 lua-6828f6d42786de735d6696da8cccbb47c8bad347.zip |
new parameter 'majorinc' to control frequency of major collections
in generational mode
-rw-r--r-- | lapi.c | 7 | ||||
-rw-r--r-- | lbaselib.c | 8 | ||||
-rw-r--r-- | lgc.c | 4 | ||||
-rw-r--r-- | lstate.c | 7 | ||||
-rw-r--r-- | lstate.h | 3 | ||||
-rw-r--r-- | lua.h | 9 |
6 files changed, 25 insertions, 13 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 2.133 2010/07/25 15:18:19 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.134 2010/08/04 18:40:28 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -976,6 +976,11 @@ LUA_API int lua_gc (lua_State *L, int what, int data) { | |||
976 | g->gcpause = data; | 976 | g->gcpause = data; |
977 | break; | 977 | break; |
978 | } | 978 | } |
979 | case LUA_GCSETMAJORINC: { | ||
980 | res = g->gcmajorinc; | ||
981 | g->gcmajorinc = data; | ||
982 | break; | ||
983 | } | ||
979 | case LUA_GCSETSTEPMUL: { | 984 | case LUA_GCSETSTEPMUL: { |
980 | res = g->gcstepmul; | 985 | res = g->gcstepmul; |
981 | g->gcstepmul = data; | 986 | g->gcstepmul = data; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.246 2010/07/02 11:38:13 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.247 2010/08/23 18:03:11 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -142,11 +142,11 @@ static int luaB_rawset (lua_State *L) { | |||
142 | 142 | ||
143 | static int luaB_collectgarbage (lua_State *L) { | 143 | static int luaB_collectgarbage (lua_State *L) { |
144 | static const char *const opts[] = {"stop", "restart", "collect", | 144 | static const char *const opts[] = {"stop", "restart", "collect", |
145 | "count", "step", "setpause", "setstepmul", "isrunning", | 145 | "count", "step", "setpause", "setstepmul", |
146 | "gen", "inc", NULL}; | 146 | "setmajorinc", "isrunning", "gen", "inc", NULL}; |
147 | static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, | 147 | static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, |
148 | LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL, | 148 | LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL, |
149 | LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC}; | 149 | LUA_GCSETMAJORINC, LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC}; |
150 | int o = optsnum[luaL_checkoption(L, 1, "collect", opts)]; | 150 | int o = optsnum[luaL_checkoption(L, 1, "collect", opts)]; |
151 | int ex = luaL_optint(L, 2, 0); | 151 | int ex = luaL_optint(L, 2, 0); |
152 | int res = lua_gc(L, o, ex); | 152 | int res = lua_gc(L, o, ex); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.100 2010/06/25 12:18:10 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.101 2010/06/30 14:11:17 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -960,7 +960,7 @@ static void generationalcollection (lua_State *L) { | |||
960 | else { | 960 | else { |
961 | luaC_runtilstate(L, ~bitmask(GCSpause)); /* run complete cycle */ | 961 | luaC_runtilstate(L, ~bitmask(GCSpause)); /* run complete cycle */ |
962 | luaC_runtilstate(L, bitmask(GCSpause)); | 962 | luaC_runtilstate(L, bitmask(GCSpause)); |
963 | if (g->totalbytes > g->lastmajormem/100 * g->gcpause) | 963 | if (g->totalbytes > g->lastmajormem/100 * g->gcmajorinc) |
964 | g->lastmajormem = 0; /* signal for a major collection */ | 964 | g->lastmajormem = 0; /* signal for a major collection */ |
965 | } | 965 | } |
966 | g->GCdebt = stddebt(g); | 966 | g->GCdebt = stddebt(g); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.84 2010/04/30 14:22:23 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.85 2010/04/30 18:36:22 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -29,6 +29,10 @@ | |||
29 | #define LUAI_GCPAUSE 200 /* 200% */ | 29 | #define LUAI_GCPAUSE 200 /* 200% */ |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | #if !defined(LUAI_GCMAJOR) | ||
33 | #define LUAI_GCMAJOR 200 /* 200% */ | ||
34 | #endif | ||
35 | |||
32 | #if !defined(LUAI_GCMUL) | 36 | #if !defined(LUAI_GCMUL) |
33 | #define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ | 37 | #define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ |
34 | #endif | 38 | #endif |
@@ -254,6 +258,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
254 | g->weak = g->ephemeron = g->allweak = NULL; | 258 | g->weak = g->ephemeron = g->allweak = NULL; |
255 | g->totalbytes = sizeof(LG); | 259 | g->totalbytes = sizeof(LG); |
256 | g->gcpause = LUAI_GCPAUSE; | 260 | g->gcpause = LUAI_GCPAUSE; |
261 | g->gcmajorinc = LUAI_GCMAJOR; | ||
257 | g->gcstepmul = LUAI_GCMUL; | 262 | g->gcstepmul = LUAI_GCMUL; |
258 | for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL; | 263 | for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL; |
259 | if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) { | 264 | if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) { |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.h,v 2.64 2010/04/29 17:31:31 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 2.65 2010/05/03 17:39:48 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -136,6 +136,7 @@ typedef struct global_State { | |||
136 | UpVal uvhead; /* head of double-linked list of all open upvalues */ | 136 | UpVal uvhead; /* head of double-linked list of all open upvalues */ |
137 | Mbuffer buff; /* temporary buffer for string concatenation */ | 137 | Mbuffer buff; /* temporary buffer for string concatenation */ |
138 | int gcpause; /* size of pause between successive GCs */ | 138 | int gcpause; /* size of pause between successive GCs */ |
139 | int gcmajorinc; /* how much to wait for a major GC (only in gen. mode) */ | ||
139 | int gcstepmul; /* GC `granularity' */ | 140 | int gcstepmul; /* GC `granularity' */ |
140 | lua_CFunction panic; /* to be called in unprotected errors */ | 141 | lua_CFunction panic; /* to be called in unprotected errors */ |
141 | struct lua_State *mainthread; | 142 | struct lua_State *mainthread; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.272 2010/07/25 15:02:41 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.273 2010/07/25 15:18:19 roberto Exp roberto $ |
3 | ** Lua - A Scripting Language | 3 | ** Lua - A Scripting Language |
4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) | 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) |
5 | ** See Copyright Notice at the end of this file | 5 | ** See Copyright Notice at the end of this file |
@@ -271,9 +271,10 @@ LUA_API int (lua_status) (lua_State *L); | |||
271 | #define LUA_GCSTEP 5 | 271 | #define LUA_GCSTEP 5 |
272 | #define LUA_GCSETPAUSE 6 | 272 | #define LUA_GCSETPAUSE 6 |
273 | #define LUA_GCSETSTEPMUL 7 | 273 | #define LUA_GCSETSTEPMUL 7 |
274 | #define LUA_GCISRUNNING 8 | 274 | #define LUA_GCSETMAJORINC 8 |
275 | #define LUA_GCGEN 9 | 275 | #define LUA_GCISRUNNING 9 |
276 | #define LUA_GCINC 10 | 276 | #define LUA_GCGEN 10 |
277 | #define LUA_GCINC 11 | ||
277 | 278 | ||
278 | LUA_API int (lua_gc) (lua_State *L, int what, int data); | 279 | LUA_API int (lua_gc) (lua_State *L, int what, int data); |
279 | 280 | ||