Re: time to create / memory footprint of VM

  • From: Mike Pall <mike-1207@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sun, 15 Jul 2012 13:47:35 +0200

Tobias Oberstein wrote:
> Could someone give me a rough estimate on
>
> - time it takes to instantiate a new VM

 2 microseconds for lua_open()                    (no libraries)
30 microseconds for lua_open() + luaL_newstate()  (with all default libs)

(On Linux/x64 at 3 GHz)

You can cut down on the overhead if you don't need all libraries.

> - the minimal memory footprint of a newly created VM instance

 8 KB without any libraries
23 KB with all libraries

That's the minimum footprint with a shared allocator across all
instances (i.e. the system allocator, not the builtin one).

> Say I have a process creating 10k VMs. How long will it take, how
> much memory consume?

That's not a useful scale for VM instances. Use one VM for each
thread and divide them up with coroutines. Each coroutines needs
only around 400 bytes, including a minimal stack.

--Mike

Other related posts: