Is there a performance increase for extensions/widgets
Posted: Wed Mar 18, 2015 3:29 pm
So in a performance-critical application, would it make sense to build much of the app's functionality in an extension?
Questions and answers about the LiveCode platform.
https://forums.livecode.com/
Code: Select all
variable tIndex as Integer
variable tAccumulate as Integer
put 0 into tAccumulate
repeat with tIndex from 0 up to pLimit
add tIndex to tAccumulate
end repeat
Code: Select all
int tIndex, tAccumulate;
tAccumulate = 0;
for(tIndex = 0; tIndex < pLimit;)
tAccumulate += tIndex
Code: Select all
variable tIndex as Integer
variable tAccumulate as Integer
put 0 into tAccumulate
repeat with tIndex from 0 up to pLimit
add tIndex to tAccumulate
end repeat
Code: Select all
repeat with i = 0 to pLimit
add i to tSum
end repeat
Right now the LCB VM is slower than the LCS VM for similar code
meant that LCB code was slower when making calls to native libraries, or under all circumstances. It seems like the obvious optimization of strict typing should increase performance, but apparently not (enough).Right now the LCB VM is slower than the LCS VM for similar code. From the last tests I did about 50-60% of this slow-down is attributable to how syntax binds to the functions it executes. When you compile an LCB source-file, syntax is compiled to a list of methods which might match dynamically at runtime. At the moment 99% of these methods are written as foreign C functions and thus the VM has to execute these dynamically which is quite a slow operation at the moment (as you might expect, constructing a call frame for a native function dynamically at runtime based on type information stored abstractly and then calling it is quite a bit more work than if the dispatch is written and then compiled in C). (I actually have a prototype patch from a while ago that mitigates this a lot for the builtin syntax we currently have in LCB - although I've not updated it in a while as at this stage we are aiming for correctness over performance).
Sounds good.LCMark wrote: [*]There is (albeit basic at the moment) C foreign function interface - i.e. you can bind to a foreign C function with native parameter types and call it from LCB code..
Hmm.... how will you allow us to do things like blocks and assign delegates? I had been expecting I would still need to write intermediary code between any asynchronous APIs (just about anything non-trivial) and LCB but maybe I'm wrong.LCMark wrote:What we're aiming for though is ensuring that you rarely, if ever, have to write bridging code in a lower-level language. We want to make the foreign interoperation rich enough that you never have to leave LCB, and the LCB language rich enough itself that you can do anything with it that you could with a lower level language but in an as much as possible 'safe' way.