Re: Huge performance loss when processing lots of data

  • From: Mike Pall <mike-1207@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 3 Jul 2012 20:31:47 +0200

Chris wrote:
> I have sample code that shows the problem here:
> http://luadev.com/uploads/slowdata01.lua

Quoting http://luajit.org/ext_ffi_api.html#ffi_new

  "Please note that an anonymous struct declaration implicitly
  creates a new and distinguished ctype every time you use it for
  ffi.new(). This is probably not what you want, especially if you
  create more than one cdata object. Different anonymous structs
  are not considered assignment-compatible by the C standard, even
  though they may have the same fields! Also, they are considered
  different types by the JIT-compiler, which may cause an
  excessive number of traces. It's strongly suggested to either
  declare a named struct or typedef with ffi.cdef() or to create a
  single ctype object for an anonymous struct with ffi.typeof()."

--Mike

Other related posts: