
robotframework - issue #497
Document that timeouts might cause performance problems if tests are executed with Python
Robot Framework Version: Robot Framework 2.1.2 (Python 2.6.2 on win32)
I have a keyword that is cpu-bound, it uses the difflib module to compare two files (130MB each). When i dont set the timeout on the testcase this test completes in about three minutes. When I set a timeout it never completes. I might be hitting the problem described in [1] and [2].
I have attached MindlessLibrary.py one keyword that spins mindlessly and a test case file defining two testcases. The first test case has no test timeout set and will finish in approximately 50 seconds. The second test case sets a test timeout of 4 minutes. This test will hit the test timeout.
I am logging this issue here so that we know about the problem.
Instead of running the keywords in a separate thread in Python we could run them in a child process using the multiprocessing module.
[1] http://www.dabeaz.com/python/GIL.pdf [2] http://www.dabeaz.com/blog/2010/01/python-gil-visualized.html
- testcases.txt 165
Comment #1
Posted on Mar 11, 2010 by Massive OxUnfortunately we need to support Python 2.5 and multiprocessing module is available only from 2.6 onwards. I checked the links and based on what I read, there is nothing we can do to fix the problem. Anyway the issue is valid and we need to document it.
Thanks for really good problem analysis.
Comment #2
Posted on Mar 23, 2010 by Massive OxThis needs to be documented in user guide where timeouts are documented.
Comment #3
Posted on Mar 29, 2010 by Massive OxAdded documentation to User Guide r2783 and r2784.
Comment #4
Posted on Mar 29, 2010 by Massive Ox(No comment was entered for this change.)
Comment #5
Posted on May 6, 2010 by Grumpy MonkeyThis issue is included in RF 2.5 alpha 1.
Comment #6
Posted on Sep 19, 2011 by Grumpy KangarooComment deleted
- robotprocess.py 3.11KB
Comment #7
Posted on Sep 19, 2011 by Grumpy KangarooI tested the mindlesslibrary on my computer. "No Timeout" test case finished in 1 min,"With Test Timeout" test case takes about 25mins, sometimes more.one time it took about 80mins.
I add a new file robotprocess.py under robot/utils, and changed the file robot/running/timeouts.py. using multiprocessing module,only support python 2.6 and higher. if the python version is lower than 2.6, it will use robotthread.py, otherwise,it will use robotprocess.py.
- robotprocess.py 3.11KB
Comment #8
Posted on Sep 19, 2011 by Grumpy ElephantThanks for the patch!
Unfortunately we can not apply it for the following reasons.
Unit tests don't pass when the patch is applied.
Also I think it is not enough to just change things to work with processes as there is no shared state with the processes (threads share state) -- there is no code for sharing robot or the test cases etc.
Thus I don't think that you can make for example a test case with timeout with this mechanism.
Comment #9
Posted on Oct 10, 2011 by Happy RhinoApparently another reason timeouts are so slow in Robot is that our thread stopping hack is based on sys.settrace:
"""Other non-solutions include using sys.settrace in the thread. In addition to making the thread code horribly slow, this will also fail to work when the thread calls into C functions."""
http://eli.thegreenplace.net/2011/08/22/how-not-to-set-a-timeout-on-a-computation-in-python
Comment #10
Posted on Jan 11, 2012 by Grumpy ElephantIssue 871 should fix the slowdown in most cases.
Comment #11
Posted on Jun 25, 2014 by Happy RhinoRemoving Type-Documentation in favor of Type-Defect and Type-Enhancement to ease migrating issues to GitHub.
Status: Done
Labels:
Priority-Medium
Target-2.5
alpha1
Type-Enhancement