digital-asset / daml

The Daml smart contract language
https://www.digitalasset.com/developers
797 stars 200 forks source link

Investigate slow down in Scala codegen #13764

Open stefanobaghino-da opened 2 years ago

stefanobaghino-da commented 2 years ago

Affected Daml version

> 2.0 && <= 2.1.1

Bug description

According to a user report, the Scala codegen suffers from a 5-10x slower execution time on the same Daml code base.

The slow down has been observed when comparing the 2.0 and the 2.1.1 release.

Possible causes could be the refactoring of the Scala codegen that happened as part of https://github.com/digital-asset/daml/pull/13439 and https://github.com/digital-asset/daml/pull/13440.

Unless the fix is trivial, further work on this should be prioritized based on whether it affects the Java bindings and what is the projected slowdown depending on the project's size.

jberthold-da commented 2 years ago

Snapshot 2.1.0-snapshot.20220329.9638.0.f24a39d2 seems to be the first one containing the slowdown (runs >30 sec on a dar file from our project), previous 2.1.0-snapshot.20220328.9630.0.66c37bad is still running fast (6 sec on the same input).

stefanobaghino-da commented 2 years ago

@jberthold-da's report seems to point at #13439 being the culprit. The refactoring seems mostly innocuous but there are a couple of changes that could have inadvertently had an effect.

stefanobaghino-da commented 2 years ago

Here are points I believe it could make sense looking in as part of the investigation:

S11001001 commented 2 years ago

@jberthold-da also mentioned that the same set of files is generated, and their contents only differ in the generated variable names.

cbley-da commented 1 year ago

Is this still relevant and if so, is there an easy way to reproduce with an example app?

S11001001 commented 1 year ago

Is this still relevant

@cbley-da Almost certainly.

is there an easy way to reproduce with an example app?

I suspect it needs to have very many (on the order of 1000 or so) template-linked data types to observe. As well as comparison to how fast it was prior to the regression. So, no.

S11001001 commented 1 year ago

@cbley-da For what it's worth, my best guess. Just a guess. Reproducing and verifying the fix is still the hard part.

stefanobaghino-da commented 1 year ago

@cbley-da Almost certainly.

While I think it's relevant in the sense that the problem might still be there, the customer who was chiefly asking for a speed up has not reported it any further and no real complain about this has reached us. Consider that the Scala codegen is not supported externally and the customer using it had a very peculiar and complex Daml code base. Evaluate whether this is the best use of your time based on whether you believe this is going to make your life better going forward.