Hi Team,
I curious to understand what happens under the hood when Daml executes such statements involving primitive
from the GHC, such as :
import GHC.Types (primitive)
explode : Text -> [Text]
explode = primitive @"BEExplodeText"
Also, is there a performance impact or benefit of calling such lower level primitive functions ?
Thanks in advance!
Brian
In our implementation of the Daml-LF runtime, for example, BEExplodeText
lands here.
Executing hand-written Scala code is faster than evaluating Daml-LF expressions. However, this style of primitive implementation essentially places a barrier that prevents tail-call optimization across that barrier, making primitives poor candidates for higher-order functions, though we have permitted some exceptions as a compromise, each requiring some complicated special-casing in the interpreter in order to avoid this problem.
If you mean “is there a performance benefit to using primitive
directly instead of invoking this explode
function”, no, there isn’t.
1 Like