lua-users home
lua-l archive

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




Le mer. 28 nov. 2018 à 20:30, Gé Weijers <ge@weijers.org> a écrit :


On Wed, Nov 28, 2018 at 4:40 AM Philippe Verdy <verdy_p@wanadoo.fr> wrote:
So Lua alone is not sufficient: the pseudo threads created by coroutine.create have unlimited time resource if they never yield (because the routines are not preempted at all by any scheduler enforcing the time quota) and they also have unlimited access to the same allocator (there's no equivalent to the Luac function lua_setallocator, and in fact no way to create such allocator in Lua, but we could still have the way to have a __alloc metamethod in thread object types that would be used to measure the memory resources requested by the thread in order to limit them by just returning a Boolean authorizing or not the use of the global allocator

The Lua team designed an extension language that's powerful and small, and you want it to be something else, a multithreaded language with advanced scheduling and fine control over memory allocation, and because it's not you complain it's lacking in that respect. That's like buying a small roadster car and then complaining you can't haul building materials with it.

That's not what I requested. a full scheduler is not needed in the language, but the language should allow building one entirely written in Lua.

What is needed is a way to control in Lua programs (essentially in a parent thread controling all the other threads it creates and monitors) the resource usage and inform the VM which metered operations are allowed or not, and the VM should provide such basic metrics: the timeslot which is requested or the amount of memory requested or no longer in use. Nothing more. Now we can design a parent thread to do whatever it wants to apply its own policy for the children threads it creates and controls so none of these children threads can abusely take all the resources needed by other competing children threads (including the parent thread itself which can be protected from being blocked by its children).