From 4e3f4c7c36b047733b3a97592d055437454c4337 Mon Sep 17 00:00:00 2001 From: Zachary Lentz Date: Fri, 13 May 2022 11:13:54 -0700 Subject: [PATCH] DOC: start some performance docs to investigate/finish in more detail later --- docs/source/index.rst | 1 + docs/source/performance.rst | 55 +++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 docs/source/performance.rst diff --git a/docs/source/index.rst b/docs/source/index.rst index 2bde50b79..251494b30 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -36,6 +36,7 @@ as well as a straightforward python framework to build complex applications. application.rst channel.rst utilities/index.rst + performance.rst .. toctree:: :maxdepth: 1 diff --git a/docs/source/performance.rst b/docs/source/performance.rst new file mode 100644 index 000000000..d96caea7f --- /dev/null +++ b/docs/source/performance.rst @@ -0,0 +1,55 @@ +========================================== +Tips for Performance of Large Applications +========================================== + +This page is dedicated to best practices for large pydm applications. +We'll define a large application as one that has more than a few +thousand PVs and dynamically manages hundreds to thousands of +dynamically allocated and dynamically shown widgets. + +These applications are typically constructed in the following manner: +- One entry python file with a ``Display`` subclass for pydm to find +- One "frame" ui file linked with this ``Display`` that contains some + static resources and an empty layout. +- One or more "template" ui file that represents a repeated element + in the aforementioned ``Display``. + +This is a reasonably good approach for creating applications to view +and manage large numbers of repeated items on your beamline. There +are a few things to keep in mind in these and in related situations +to make sure your application loads quickly and stays responsive. + +Dynamically Showing Many widgets +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Calling .show() or setVisible(True) on hundreds or thousands of widgets +at once has a large performance penalty, causing the GUI to freeze from +the perspective of the user. This should be avoided as much as possible. + +TODO things to investigate before finishing this docs section: +- Hiding unseen widgets in scroll areas +- Working into template repeater some sort of paint ten-at-a-time + functionality +- Including some filtering help in pydm + +Rules vs No Rules +^^^^^^^^^^^^^^^^^ +The rules engine is very helpful when editing displays in designer, but +behind the scenes we can create problems if we overload the engine- +particularly if it takes more than 1/30th of a second to evaluate all +widget rules. + +TODO things to investigate before finishing this docs section: +- Example alternatives to rules (signal/slot setups) +- Some built-in help for these sorts of constructs in the template + repeater + +Template Macros +^^^^^^^^^^^^^^^ +Macros are very helpful for re-using ui files in a simple way, but +has a large performance penalty if we're repeatedly using it hundreds +or thousands of time at startup. + +TODO things to investigate before finishing this docs section: +- Example alternatives to loading ui files +- Some built-in help for loading a pydm ui subdisplay in a way where + we can initialize everything in init using init args and re-use classes