lua-users home
lua-l archive

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


I've been studying source code of 5.3.4 for some time. I am confused abount the gc parameter "step multiplier".

According to lua default setting,

#define STEPMULADJ      200
#define LUAI_GCMUL  200 // GC runs 'twice the speed' of memory allocation

If lua malloc X bytes,   global->GCdebt increase X.
Howerver, during propagate peroid, if traverse Y bytes£¬

In luaC_step function:
debt = (debt / g->gcstepmul) * STEPMULADJ

Ignoring integer dividing precision loss, debt/work ratio is 1:1

I cann't see why "GC runs 'twice the speed' of memory allocation"

According to my test, the default setting works fine. These must be something wrong with my calculation.

Can somebody help me? Thanks a lot.