koreader / lj-wpaclient

wpa_supplicant client library for LuaJIT
7 stars 3 forks source link

Load ffi symbols individually, in protected mode #10

Closed NiLuJe closed 1 year ago

NiLuJe commented 1 year ago

To avoid conflicts with koreader-base once and for all...


This change is Reviewable

NiLuJe commented 1 year ago

Do you have any idea of the performance impact?

IIRC, error handling in Lua involves a setjmp/longjmp pair, so, depends on how good the CPUs are at jumps (plus the extra context switches it involves) ;).

But even regardless of the pcall implementation details, it is mechanically slower, if only because of the multiplication of function calls ;).

That said, we're, comparatively, doing this for a limited number of calls, once (at require-time), so I don't expect a significant impact (and it essentially future-proofs this against future conflicting additions in base).

(i.e., I'd be warier if we were doing this globally).

Frenzie commented 1 year ago

Well yeah, even if it were more than a hundred times slower it'd probably still be fast and unproblematic. Just curious. ;-)