daml icon indicating copy to clipboard operation
daml copied to clipboard

FromInterface is slow on 2.x/3.x, should fix for 3.x

Open dylant-da opened this issue 1 year ago • 0 comments

FromInterface now performs upgrades automatically, this means that it traverses the entire contract value when called. (It actually traverses twice, as it reuses importValue to do the transformation, which means we must call toValue first) This primitive is assumed to simply be a downcast, and as such, does not run in Update. It is possible users will set up code like so

case myInterface where
  (fromInterface @Template1 -> t) -> ...
  (fromInterface @Template2 -> t) -> ...
  (fromInterface @Template3 -> t) -> ...

which would perform very badly with upgrades.

This ticket is to explore how much of an issue this is, change the primitive if needed, and perhaps optimise it to only traverse once. Note however, that the engine is the fastest part of the canton transaction pipeline, so this may be a non-issue

dylant-da avatar Sep 25 '24 08:09 dylant-da