the prelude - we're using Lua as a scripting language of our
embedded web-server. the problem is there are a lot of short
living and somtimes big enough scripts loading very often. that
is performance problem. we've written file cache wich holds the
source of used Lua scripts ant their compiled representation
dumped just after loading. it sounds to be good, but the most
scripts use 'require'. well, we've written 'require'
replacement. it's easy, 'cuz we dont't use 'dofile' or something
like that. so, everything seems to be going well. but... I'm
thinking about Lua 5.1 integration into our software. there is
new packaging strategy, new 'require', I guess, and maybe
something else changed, too. It's not right way to hack
everytime the standard library and VM.
the better way is having the hook which should be called from
VM/libraries when they need the file be loaded I guess. And the
coolest feature is the possibility to write that hook in Lua
itself :) does anybody agree with me?
Not exactly, the main problem is that the Lua VM is not living
forever. it's started on demand and dies as soon as request
processed. I can create the pool of the VMs, it's not a
problem but it leads to another problem - how can I share
`package' table between all VMs? How can I share the code
compiled and being executed in one VM with another one? How can
I invalidate compiled code when disk file has been changed? How
can I throw away the expired code from the cache? I'm afraid
only by full replacement of the `require' function as it is
now. maybe I'm wrong.