lua-users home
lua-l archive

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


>   An initial test indicates that v3.0a might work OK except for
>   a slowdown by a factor of almost 4 :

  We have detected a "performance bug" in v3.0a which might be responsible
for that. Waldemar Celes has got the same problem, and the profile of his
program starts with:

 18.93%   luaI_travfallbacks
 15.55%   checkfunc
  7.68%   lua_execute

  The problem seems to be in function luaL_arg_check (file auxlib.c). It is
always calling lua_getobjname: This last function is part of the debuger
interface, and it is very very slow (and calls luaI_travfallbacks, which
in turn calls checkfunc). The "bug" is that luaL_arg_check needs to call
lua_getobjname *only* if there is an error, which is very rare. Therefore,
it should be coded like:

void luaL_arg_check(int cond, int numarg, char *extramsg)
{
  if (!cond) {
    char *funcname;
    lua_getobjname(lua_stackedfunction(0), &funcname);
    if (funcname == NULL)
      funcname = "???";
    if (extramsg == NULL)
      luaL_verror("bad argument #%d to function `%s'", numarg, funcname);
    else
      luaL_verror("bad argument #%d to function `%s' (%s)",
                      numarg, funcname, extramsg);
  }
}

(that is, with the call to lua_getobjname inside the "if"). Please try that.


-- Roberto