diff options
author | Benoit Germain <b n t DOT g e r m a i n AT g m a i l DOT c o m> | 2013-09-26 21:11:24 +0200 |
---|---|---|
committer | Benoit Germain <b n t DOT g e r m a i n AT g m a i l DOT c o m> | 2013-09-26 21:11:24 +0200 |
commit | f823c6887e28c815234f8b4bd355887b4f554857 (patch) | |
tree | 862b37cc93d6779c3c2577e78ed6ff5389412f90 /docs | |
parent | c97ad8630ea9dcb92b4e9db16c4dbade1de18884 (diff) | |
download | lanes-f823c6887e28c815234f8b4bd355887b4f554857.tar.gz lanes-f823c6887e28c815234f8b4bd355887b4f554857.tar.bz2 lanes-f823c6887e28c815234f8b4bd355887b4f554857.zip |
Reduce memory footprint, simplify module order setup in conjuction with Lanes, and send over native functions a bit faster as well
* Lanes no longer has to internally require modules inside the keeper
states because they no longer need a lookup database. the lookup name is
stored as-is and actually converted in the destination state
*
optimisation: bypass cache when sending native functions over
* removed
all the KEEPER_MODEL_LUA code, as it can no longer work anyway
Diffstat (limited to 'docs')
-rw-r--r-- | docs/index.html | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/docs/index.html b/docs/index.html index 1c60aaa..ac4fa6b 100644 --- a/docs/index.html +++ b/docs/index.html | |||
@@ -70,7 +70,7 @@ | |||
70 | </p> | 70 | </p> |
71 | 71 | ||
72 | <p> | 72 | <p> |
73 | This document was revised on 24-Sept-13, and applies to version <tt>3.6.4</tt>. | 73 | This document was revised on 26-Sept-13, and applies to version <tt>3.6.5</tt>. |
74 | </p> | 74 | </p> |
75 | </font> | 75 | </font> |
76 | </center> | 76 | </center> |
@@ -314,7 +314,7 @@ | |||
314 | </td> | 314 | </td> |
315 | <td> | 315 | <td> |
316 | (Since v3.5.2) If equal to <tt>true</tt>, Lanes wraps all calls to the state's allocator function inside a mutex. Useful when running Lanes with LuaJIT, whose allocator is not threadsafe. | 316 | (Since v3.5.2) If equal to <tt>true</tt>, Lanes wraps all calls to the state's allocator function inside a mutex. Useful when running Lanes with LuaJIT, whose allocator is not threadsafe. |
317 | Default is <tt>nil</tt>. | 317 | Default is <tt>true</tt> when Lanes detects it is run by LuaJIT, else <tt>nil</tt>. |
318 | </td> | 318 | </td> |
319 | </tr> | 319 | </tr> |
320 | 320 | ||
@@ -603,8 +603,6 @@ | |||
603 | Specifying it when <code>libs_str</code> doesn't cause the <code>package</code> library to be loaded will generate an error. | 603 | Specifying it when <code>libs_str</code> doesn't cause the <code>package</code> library to be loaded will generate an error. |
604 | <br> | 604 | <br> |
605 | If not specified, the created lane will receive the current values of <tt>package</tt>. Only <tt>path</tt>, <tt>cpath</tt>, <tt>preload</tt> and <tt>loaders</tt> (Lua 5.1)/<tt>searchers</tt> (Lua 5.2) are transfered. | 605 | If not specified, the created lane will receive the current values of <tt>package</tt>. Only <tt>path</tt>, <tt>cpath</tt>, <tt>preload</tt> and <tt>loaders</tt> (Lua 5.1)/<tt>searchers</tt> (Lua 5.2) are transfered. |
606 | <br> | ||
607 | IMPORTANT: The contents of whatever package table is actually provided to the lane won't be known to the keeper states: they will stick to whatever was found in the main state's package table when Lane was required. | ||
608 | </td> | 606 | </td> |
609 | </tr> | 607 | </tr> |
610 | </table> | 608 | </table> |
@@ -1251,10 +1249,7 @@ events to a common Linda, but... :).</font> | |||
1251 | </ul> | 1249 | </ul> |
1252 | </li> | 1250 | </li> |
1253 | <li> | 1251 | <li> |
1254 | C functions (<tt>lua_CFunction</tt>) referring to <tt>LUA_ENVIRONINDEX</tt> or <tt>LUA_REGISTRYINDEX</tt> might not work right in the target | 1252 | C functions (<tt>lua_CFunction</tt>) referring to <tt>LUA_ENVIRONINDEX</tt> or <tt>LUA_REGISTRYINDEX</tt> might not do what you expect in the target, since they will actually use a different environment. |
1255 | <ul> | ||
1256 | <li>Rather completely re-initialize a module with <tt>require</tt> in the target lane.</li> | ||
1257 | </ul> | ||
1258 | </li> | 1253 | </li> |
1259 | <li> | 1254 | <li> |
1260 | Lua 5.2 functions may have a special <tt>_ENV</tt> upvalue if they perform 'global namespace' lookups. Unless special care is taken, this upvalue defaults to the table found at <tt>LUA_RIDX_GLOBALS</tt>. | 1255 | Lua 5.2 functions may have a special <tt>_ENV</tt> upvalue if they perform 'global namespace' lookups. Unless special care is taken, this upvalue defaults to the table found at <tt>LUA_RIDX_GLOBALS</tt>. |
@@ -1319,7 +1314,7 @@ events to a common Linda, but... :).</font> | |||
1319 | <br> | 1314 | <br> |
1320 | When a lane generator creates a lane and performs initializations described by the list of base libraries and the list of required modules, it recursively scans the table created by the initialisation of the module, looking for all values that are C functions. | 1315 | When a lane generator creates a lane and performs initializations described by the list of base libraries and the list of required modules, it recursively scans the table created by the initialisation of the module, looking for all values that are C functions. |
1321 | <br> | 1316 | <br> |
1322 | Each time a function is encountered, the sequence of keys that reached that function is contatenated in a (hopefully) unique name. The [name, function] and [function, name] pairs are both stored in a lookup table in all involved Lua states (main Lua state, keeper states, lanes states). | 1317 | Each time a function is encountered, the sequence of keys that reached that function is contatenated in a (hopefully) unique name. The [name, function] and [function, name] pairs are both stored in a lookup table in all involved Lua states (main Lua state and lanes states). |
1323 | <br> | 1318 | <br> |
1324 | Then when a function is transfered from one state to another, all we have to do is retrieve the name associated to a function in the source Lua state, then with that name retrieve the equivalent function that already exists in the destination state. | 1319 | Then when a function is transfered from one state to another, all we have to do is retrieve the name associated to a function in the source Lua state, then with that name retrieve the equivalent function that already exists in the destination state. |
1325 | <br> | 1320 | <br> |
@@ -1336,7 +1331,7 @@ events to a common Linda, but... :).</font> | |||
1336 | string2 = string | 1331 | string2 = string |
1337 | </pre></td></tr></table> | 1332 | </pre></td></tr></table> |
1338 | When iterating over all keys of the global table, Lanes has no guarantee that it will hit <tt>"string"</tt> before or after <tt>"string2"</tt>. However, the values associated to <tt>string.match</tt> and <tt>string2.match</tt> are the same C function. | 1333 | When iterating over all keys of the global table, Lanes has no guarantee that it will hit <tt>"string"</tt> before or after <tt>"string2"</tt>. However, the values associated to <tt>string.match</tt> and <tt>string2.match</tt> are the same C function. |
1339 | Lanes doesn't expect a C function value to be encountered more than once. In the event it occurs, when the lookup table is populated with a [function, name] pair, an existing pair won't be updated if it is already found. In other words, the first name that was computed is retained. | 1334 | Lanes doesn't normally expect a C function value to be encountered more than once. In the event it occurs, the shortest name that was computed is retained. |
1340 | If Lanes processed <tt>"string2"</tt> first, it means that if the Lua state that contains the <tt>"string2"</tt> global name sends function <tt>string.match</tt>, <tt>lookup_func_name</tt> would return name <tt>"string2.match"</tt>, with the obvious effect that <tt>push_resolved_func</tt> | 1335 | If Lanes processed <tt>"string2"</tt> first, it means that if the Lua state that contains the <tt>"string2"</tt> global name sends function <tt>string.match</tt>, <tt>lookup_func_name</tt> would return name <tt>"string2.match"</tt>, with the obvious effect that <tt>push_resolved_func</tt> |
1341 | won't find <tt>"string2.match"</tt> in the destination lookup database, thus failing the transfer (even though this function exists, but is referenced under name <tt>"string.match"</tt>). | 1336 | won't find <tt>"string2.match"</tt> in the destination lookup database, thus failing the transfer (even though this function exists, but is referenced under name <tt>"string.match"</tt>). |
1342 | </li> | 1337 | </li> |
@@ -1345,7 +1340,7 @@ events to a common Linda, but... :).</font> | |||
1345 | When Lua is built with compatibility options (such as LUA_COMPAT_ALL), this causes several base libraries to register functions under multiple names. | 1340 | When Lua is built with compatibility options (such as LUA_COMPAT_ALL), this causes several base libraries to register functions under multiple names. |
1346 | This, with the randomizer, can cause the first encountered name of a function to be different on different VMs, which breaks function transfer. | 1341 | This, with the randomizer, can cause the first encountered name of a function to be different on different VMs, which breaks function transfer. |
1347 | Even under Lua 5.1, this may cause trouble if some module registers a function under several keys. | 1342 | Even under Lua 5.1, this may cause trouble if some module registers a function under several keys. |
1348 | To circumvent this, Lanes has to select one name among all candidates, and the rule for this is to keep the 'smaller' one: first in bytes, then in lexical order. | 1343 | To circumvent this, Lanes has to select one name among all candidates, and the rule for this is to keep the 'smaller' one: first in byte count, then in lexical order. |
1349 | </li> | 1344 | </li> |
1350 | </ul> | 1345 | </ul> |
1351 | Another more immediate reason of failed transfer is when the destination state doesn't know about the C function that has to be transferred. This occurs if a function is transferred in a lane before it had a chance to scan the module. | 1346 | Another more immediate reason of failed transfer is when the destination state doesn't know about the C function that has to be transferred. This occurs if a function is transferred in a lane before it had a chance to scan the module. |