[Tarantool-patches] [PATCH 15/20] net.box: rewrite request implementation in C

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Thu Aug 5 00:20:04 MSK 2021


>>> +static int
>>> +netbox_new_request(struct lua_State *L)
>>> +{
>>> +	struct netbox_request *request = lua_newuserdata(L, sizeof(*request));
>>
>> 9. Does it help perf if the requests are allocated on mempool?
> 
> I tried to allocate requests on mempool. To achieve that, we have to
> turn them into C data. It resulted in a performance degradation, see the
> parallel thread:

It does not necessarily need to be cdata. You can use
lua_newuserdata(L, sizeof(void *)) and store pointers at the requests which
you allocate on mempool. The downside is that there will be +1 dereference for
each access. The upside is that Lua might have optimizations for small userdata
objects. For example, ffi.new() for objects < 128 bytes is order of magnitude
faster than for bigger objects. Something similar might exist for userdata.


More information about the Tarantool-patches mailing list