Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Konstantin Osipov <kostja@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH 1/1] buffer: port static allocator to Lua
Date: Sun, 19 May 2019 01:15:07 +0300	[thread overview]
Message-ID: <06507d82-1888-1d52-7a21-fc4661626acb@tarantool.org> (raw)
In-Reply-To: <20190518191224.GF9448@atlas>



On 18/05/2019 22:12, Konstantin Osipov wrote:
> * Vladislav Shpilevoy <v.shpilevoy@tarantool.org> [19/05/15 16:34]:
> 
> 1) scalar looks clearly as a separate patch. while I like the idea
>    I don't appreciate the urgency and a huge patch.

Done in a separate commit, see v2 thread. Urgency is motivated by
SWIM Lua API dependency on that - I do not want to push SWIM Lua
with ugly "ffi.new('int[1]')" construction.

> 
> 2) The static alloc patch is OK to push
> 
> 3) Since you care about performance so much, I don't understand
>    why you do concat (..) in Lua static alloc. Did you check it's
>    a compile-time, not a run-time concat? 

I did not check whether it is compile time, because Lua has no a
compiler. But I made a benchmark - even with concat it is orders of
magnitude faster.

Nonetheless, probably you could be right, and it would be better to
avoid concatenation - then impact would be even greater.

Firstly, I tried to avoid concatenation and pass the array type
always. But I faced a problem, that ffi.cast does not allow some
C conversions. I needed to be able to do
ffi.cast('type[size]', <cdata void *>) - in C I would not have
problems, but in Lua I do. I started looking into FFI implementation,
and found how to allow that conversion, but then I decided that
it is not worth doing without a benchmark: concact vs no concat.

Appeared, that noconcat version is ~5% faster. In the summary,
original patch makes small allocations +10000% faster, without
concat it would be +10005%. Not sure, if this difference is worth
splitting static_alloc() into multiple functions, nor moving
ffi.sizeof() + ffi.cast() operations onto the caller's shoulders.

So I decided to keep it is as. Otherwise it becomes too complicated.

>> +    if ffi.C.EVP_CipherUpdate(self.ctx, wpos, scalar.ai, input, input:len()) ~= 1 then
> 
> I don't understand, if you need a scalar and an array of scalars,
> and you have scalar and scalar_array variables, why would you ever
> use an array in scalar?

I use array types [1] in scalar, because it is the only way to
get a pointer onto a type in Lua.

> Wouldn't it be better to have two unions
> instead of one for the sake of clarity?

I have - scalar_array is two unions. I thought about their
separation in something like buffer.scalar1, buffer.scalar2, but
looks ugly, unnatural.

But here I do not insist. If you want, I can split them into two
variables. Should I?

See V2 thread.

      reply	other threads:[~2019-05-18 22:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-15 13:33 [tarantool-patches] " Vladislav Shpilevoy
2019-05-18 18:41 ` [tarantool-patches] " Vladislav Shpilevoy
2019-05-18 19:12 ` Konstantin Osipov
2019-05-18 22:15   ` Vladislav Shpilevoy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=06507d82-1888-1d52-7a21-fc4661626acb@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 1/1] buffer: port static allocator to Lua' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox