lua-users home
lua-l archive

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


On Thu, Oct 04, 2012 at 03:13:39PM -0400, John Craws wrote:
<snip>
> The problem occurs when one of the Lua files uses require(). With the
> default loaders, there is no way (that I see) to share the result, so
> each thread has to load the module. Consequently, the .so and .lua
> files are reopened and reloaded every time. Is there a way to share
> the result and have require() load once for all threads/instances (as
> it does for multiple calls for the same module in the same
> thread/instance)?

The real issue here is mostly the .so reloading, isn't it? I mean, a new
copy of the Lua bytecode is necessary in each and every instance,
regardless. And keeping yet another copy in an internal cache is arguably
more wasteful than just reading it from the file again--which is probably
already in the disk buffer cache anyhow. (Counterpoint--chroot'ing issues.)

But regarding the .so, it's always been my assumption that it won't actually
get reloaded. AFAIU, the Linux dynamic linker should only load it from disk
once, and then increment a reference counter. But I've never actually
confirmed this.