open-formulieren / open-forms

Smart and dynamic forms
https://open-forms.readthedocs.io
Other
37 stars 26 forks source link

Fix performance regression in FormioData data structure #4768

Closed sergei-maertens closed 1 month ago

sergei-maertens commented 1 month ago

Closes #4744

Changes

Optimized key access in the FormioData data structure.

Performance results - the last column are the numbers for this PR. The gains are massive compared to master and they improve even on 2.7.x.

Form step version: master (0ea7bfa) version: 2.7.x Perf patch
Inleiding 1540 736 448
Verklaring van waarheid 1520 751 464
Uw gegevens 1727 879 551
Uw situatie 1730 827 483
Gezinssamenstelling 1660 823 558
Uw inkomsten 1790 991 637
Uw inkomsten overzicht 1740 836 565
Inkomsten partner 1840 909 585
Inkomsten partner overzicht 1720 864 540
Bezit en schulden 1620 859 508
Bezit en schulden overzicht 1600 817 637
Post 1560 769 485
Overzicht 10350 4850 3330

Checklist

Check off the items that are completed or not relevant.

sergei-maertens commented 1 month ago

So one particularly interesting observation is that in the hottest code path and logic rule evaluation there seems to be much more room for improvement.

With the master branch, 58% of time was spent in glom, and there were about 18,5K calls to it. In this patch, 34% of time is spent in glom, and there are still about 15K calls - so only about 3K calls are stripped away. It could be that many of those led to exception handling and that caused the slowdown, but I can't even begin to imagine what performance is left uncovered if we can bring those 15K to 1K calls, for example.

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 96.57%. Comparing base (751991d) to head (d2bd3cf). Report is 4 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #4768 +/- ## ======================================= Coverage 96.56% 96.57% ======================================= Files 746 746 Lines 25210 25223 +13 Branches 3322 3325 +3 ======================================= + Hits 24345 24358 +13 Misses 602 602 Partials 263 263 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sergei-maertens commented 1 month ago

Validated and approved by DH - it's not up to OF 2.6.x levels yet, but a vast improvement over 2.7.x.

sergei-maertens commented 1 month ago

Backports: