Re: Luajit string concatenation performance

  • From: Mike Pall <mike-1305@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 22 May 2013 22:22:12 +0200

madigest i wrote:
> I have had strange performance problems with many of my
> different Lua programs that handle big strings. I finally made a
> small test program to demonstrate the problem.

That's not a helpful benchmark. You're concatenating interned
strings in a loop, which is known to be O(n^2). Don't do that.
Plain strings are probably the wrong data structure for your use
case, anyway.

The only thing you're measuring is system memory mapping/growth
performance and memory copy overhead. sbrk() vs. mmap()/mremap()
have different performance characteristics, e.g. page clearing
overhead and growth pattern dependency.

Oh, and none of that is compiled, because you use string.gmatch.
Also, os.time() measures wall clock time, not per-process CPU
time, like os.clock().

--Mike

Other related posts: