Hi,
I’m trying to resolve performance issues with pretty big forms (~2k questions) with lots of revisions (~100). I have some first little successes that I plan to submit as PRs soon.
What I’m left with is two major pain points that seem inherently complex:
- in the
ReportsViewSet
: building theFormPack
. With my forms this part of thereports/{uid}
query takes ~20s. - in the
AssetViewSet
: getting thecontent_hash
. The wholeassets/{uid}
request takes ~10s. The trace suggests that over 90% of the time is spent inkpi/models/asset_version.py:57(content_hash)
.
The only option for improvement I see here is caching. So, the main question: are AssetVersion
s immutable?
I’ve skimmed the code and I don’t see them being updated anywhere, but I’d prefer for someone with knowledge of KT to weight in before I start implementing things.
On that note:
- caching for the
content_hash
seams easy enough: save the value to a db field on the first request where it’s not cached yet. - I’m not sure what’s the best approach for the
FormPack
. There is a non-trivial amount of logic in there that I guess can change. On top of that it’s not a simple data object, it has classes too. Maybememcached
is a better approach here? With a key that includes the formpack lib git hash? Another option would be two fields in db: cached serialized value + git hash of formpack lib + celery beat job that populates/updates the cache when needed.
Best,
Michał