Hi Folks,
TLDR: Why is my app so slow?
What I’m trying to do: I am working on my first Anvil web application and am hoping one of you more experienced developers might be able to point me towards the cause of slow performance. The app is simple in concept and consists of a number of sliders to rank pairs of options against one another (i.e., A is 2 times more important than B). The app uses a repeating element structure to pull the pairs of options from a data table. When the slider is changed, a dictionary of values is appended to a global list object. When the user submits the rankings at the end, the list of responses are pushed to a data table.
Clone link:
https://anvil.works/build#clone:5OKAX77ANUEC343M=WSJBVGQQMAX4YFUDHVYIAT2A
To access the sliders/submission button when running the app, you need to specify a user_id (from a user_id table). Try Foo or Bar for testing.
The problem: As I increase the number of pairs of options, the performance gets slower and slower, to the point where the app is unsuitable for use. Performance becomes unsuitable with even 5 pairs of options. I am hoping to have 25+ options. I believe the code appends the user’s selection data at each change of the slider, which is not quite what I want. However, even without repeatedly changing a given slider, the performance is terrible.
My suspicions: I don’t know what’s causing the decline in speed. Some ideas: (a) Perhaps appending records to a growing list object is just too slow. (b) I use the get_open_form() function to retrieve a value typed in by a user. Perhaps it’s not what I want. © I am trying to navigate global vs local variables, and may be trying to access/write to objects that are too costly to interact with. (d) Any of a million things I don’t know about python or application development.
There may be more efficient ways of doing what I am trying to do. However, I am just trying to make a crude prototype and would love any insights into ways to speed up what I already have in place. Many thanks for your thoughts.