[SSSD] Embedding Lua into SSSD

Pavel Březina pbrezina at redhat.com
Mon Aug 24 08:54:46 UTC 2015


On 08/21/2015 07:01 PM, Nikolai Kondrashov wrote:
> Hi everyone,
>
> I might be in a strange and careless mood today, but here is something I
> wanted to suggest since the time I saw the amount of logic that goes
> into SSSD
> and is implemented in C.
>
> What if we implement some of the complicated logic inside SSSD in Lua [1]?
>
> Lua is a language specifically designed to be embedded. It grew into
> popularity after it was embedded into World Of Warcraft. It was also
> embedded
> and is still being embedded into a bunch of other games. However, games
> is far
> from the only application for Lua.
>
> Lua is a simple and lightweight language, yet with lots of flexibility -
> grasping the essence of the whole reference manual [2] takes one evening
> and
> it's an entertaining read. The VM is small and fast. In fact some people
> use
> it on microcontrollers [3].
>
> I personally embedded it into two C-based projects, one of which was
> already
> quite big, and another was a rewrite of a smallish, but complicated C
> project.
> In both cases, where before things were tedious and hard, they have become
> easy and fun. The first project was on an embedded platform. I also had
> some
> other, but smaller stuff done with it.
>
> Generally, Lua gets put into the middle with outside interfaces and
> performance-critical parts implemented in C. With a very simple
> interface to
> and from C one can put boundaries wherever necessary. Yes, the interface is
> simpler than Python's.
>
> The process is this: you implement some C libraries (shared/static)
> which are
> loadable from Lua (Lua->C interface) and then create a VM or several, load
> some Lua code and call into it (C->Lua interface).
>
> Some of the benefits are:
>
>      Clearer logic (higher level language)
>      Much less memory leaks and very little memory management (mostly in
> Lua->C
>      interface).
>      Faster development cycle (no compilation, edit and retry on a live
> daemon)
>      Potentially easy plugin interface (yay for admin scripts!)
>
> Some of the drawbacks are:
>
>      More difficult to do low level stuff (so we just don't do that)
>      Lower performance than C (still good enough for games, and we can
> have the
>      critical parts in C easily)
>      Needs learning and development investment.
>
> Regarding the development investment, due to low cost of C/Lua interface
> implementation, it is practical to replace the relevant C code
> piece-by-piece,
> provided pieces are not too small (say, 2KLOC and up).
>
> Lastly, don't take this too seriously. I realise that this is disruptive
> and
> hard. However if you ever feel like SSSD has grown too big and complex,
> ping
> me, or just try Lua yourself :)
>
> Nick
>
> [1] http://www.lua.org/
> [2] http://www.lua.org/manual/5.3/manual.html
> [3] http://www.eluaproject.net/

Hi,
can you tell us what features of Lua do you like and might help simplify 
SSSD? I don't know the language, just fast scrolled over the manual and 
seen few examples. It seems to be similar to javascript.




More information about the sssd-devel mailing list