lua-users home
lua-l archive

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


Am 21.03.2014 21:44 schröbte Luiz Henrique de Figueiredo:
Lua 5.3.0 (work2) is now available for testing at
	http://www.lua.org/work/lua-5.3.0-work2.tar.gz

Enjoy. All feedback welcome. Thanks.

I'm experiencing a strange slowdown in 5.3 when creating lots of closures. Example script is attached. It runs in under half a second on 5.1 and 5.2, but needs minutes in 5.3 ...

Ubuntu Linux 13.10 on x86_64 in case that matters.

--lhf


Philipp

#!/usr/bin/lua

local N = 1024*128

local loadstring = loadstring or load

local function create_closures( n, i )
  local locs = {}
  for j = 1, i do
    locs[ j ] = "_"..j
  end
  locs = table.concat( locs, ", " )
  local code = [[
local ]] .. locs .. [[ = ...
return function() return ]] .. locs .. [[ end ]]
  local f = assert( loadstring( code ) )
  local t = {}
  for i = 1, n do
    if i % 1024 == 0 then print( i ) end
    t[ i ] = f()
  end
  return t
end

local t = create_closures( N, 10 )
collectgarbage()
collectgarbage()
local full = collectgarbage( "count" )
for i = 1, #t do
  t[ i ] = false
end
collectgarbage()
collectgarbage()
local clean = collectgarbage( "count" )
print( "closure(10 upvalues):", (full-clean)*1024/N, "bytes" )