The registry, a table, is SLOW. Can we use upvalues instead?
You can use a thread as an array instead of upvalues.
Use lua_newthread to create a new thread, hold L both in C and lua registry (prevent GC) ,
and then you can use lua C api directly to push values into that L . I think is better than use a table in registry or upvalues .
(Remember call lua_checkstack when you push values to thead )
I think the C API to manage stack of L is cheaper than registry .
You can use lua_xmove to move all the values from thread into lua .