Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix performance regressions and overhead for Python runner actions #3809

Merged
merged 10 commits into from
Oct 24, 2017

Conversation

Kami
Copy link
Member

@Kami Kami commented Oct 24, 2017

In the past I spent quite a lot of time working on optimizing the run time of simple and short Python runner actions (there was a lot of overhead added by start up time, mostly by some very slow imports).

I managed to get it down to 0.2 seconds or so, but we recently moved some modules around and added some function definitions to some modules which introduced big performance overheads (run time is now back at ~2 seconds).

The reason for that was a broken test - the test which should ensure that we don't introduce performance regressions didn't work correctly because it didn't actually check that the script it tries to run exists (it broke when we moved wrapper script from st2actions to st2common).

As a first step, I of course fixed this test so things like that won't happen again - 69a63f5.

I also managed to track down performance regressions we introduced and get run time down to around 0.5s - 9f7feba. This is still not where we were originally, but with changes here and changes in #3803 (merged in time for v2.6), run time is down back to 0.2-0.3 seconds again.

Before:

(virtualenv)vagrant@vagrant-ubuntu-trusty-64:/data/stanley$ python /data/stanley/st2common/st2common/runners/python_action_wrapper.py --is-subprocess
usage: python_action_wrapper.py [-h] --pack PACK --file-path FILE_PATH
                                [--config CONFIG] [--parameters PARAMETERS]
                                [--user USER] [--parent-args PARENT_ARGS]
python_action_wrapper.py: error: argument --pack is required
(virtualenv)vagrant@vagrant-ubuntu-trusty-64:/data/stanley$ time python /data/stanley/st2common/st2common/runners/python_action_wrapper.py --is-subprocess
usage: python_action_wrapper.py [-h] --pack PACK --file-path FILE_PATH
                                [--config CONFIG] [--parameters PARAMETERS]
                                [--user USER] [--parent-args PARENT_ARGS]
python_action_wrapper.py: error: argument --pack is required

real	0m1.779s
user	0m0.371s
sys	0m0.691s
(virtualenv)vagrant@vagrant-ubuntu-trusty-64:/data/stanley$ python /data/stanley/st2common/st2common/runners/python_action_wrapper.py --is-subprocess
usage: python_action_wrapper.py [-h] --pack PACK --file-path FILE_PATH
                                [--config CONFIG] [--parameters PARAMETERS]
                                [--user USER] [--parent-args PARENT_ARGS]
python_action_wrapper.py: error: argument --pack is required
(virtualenv)vagrant@vagrant-ubuntu-trusty-64:/data/stanley$ time python /data/stanley/st2common/st2common/runners/python_action_wrapper.py --is-subprocess
usage: python_action_wrapper.py [-h] --pack PACK --file-path FILE_PATH
                                [--config CONFIG] [--parameters PARAMETERS]
                                [--user USER] [--parent-args PARENT_ARGS]
python_action_wrapper.py: error: argument --pack is required

real	0m1.779s
user	0m0.371s
sys	0m0.691s

After:

(virtualenv)vagrant@vagrant-ubuntu-trusty-64:/data/stanley$ time python /data/stanley/st2common/st2common/runners/python_action_wrapper.py --is-subprocess
usage: python_action_wrapper.py [-h] --pack PACK --file-path FILE_PATH
                                [--parameters PARAMETERS] [--user USER]
                                [--parent-args PARENT_ARGS]
python_action_wrapper.py: error: argument --pack is required

real	0m0.517s
user	0m0.070s
sys	0m0.225s

/cc @bigmstone @m4dcoder - just a heads up - some imports like eventlet, etc. can add a lot of overhead and that's why the imports were organized as they were before to avoid this overhead in python runner wrapper script

Kami added 6 commits October 24, 2017 11:18
moved this script from st2actions into st2common.

Since test was broken, we didn't correctly detect the timing and
performance issues. It looks like we introduced a bunch of new
performance issues which now need to be tracked down again.
some very expensive imports inline so they are not imported by functions
inside that module which don't need that functionality.
@Kami Kami added this to the 2.5.0 milestone Oct 24, 2017
@Kami Kami merged commit 8283f71 into master Oct 24, 2017
@Kami Kami deleted the fix_timing_test branch October 24, 2017 11:19
@koenbud
Copy link

koenbud commented Oct 26, 2017

Great to see this getting attention. In some environments a couple of seconds has a lot of impact. Thanks for the progress.

@Kami
Copy link
Member Author

Kami commented Oct 27, 2017

@koenbud Yeah - I also fixed / improved the test so hopefully regressions like that won't happen in the future anymore.

@humblearner humblearner modified the milestones: 2.5.0, 2.5.1 Nov 8, 2017
@Kami Kami modified the milestones: 2.5.1, 2.5.0 Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants