[openstack-dev] [trove] timeouts in gate-trove-python34-db
Victor Stinner
vstinner at redhat.com
Mon May 16 13:38:29 UTC 2016
Le 16/05/2016 13:52, Amrith Kumar a écrit :
>> IMHO the strange mock detector code must be removed. It is very
>> slow and I don't understand its purpose.
>
> [amrith] It serves and has served a very useful purpose and that is
> to detect bad tests where code has (and we've had lots of trouble
> with this) established a Mock() but failed to delete it.
There are many options to disable (unregister, stop, call it as you
want) mocks automatically. As I wrote, fixtures & oslotest give you
tools to do that automatically. It's also a base feature of the mock
module: "with mock.patch(...): ...". Sorry, I don't know enough the
Trove code base (code of the unit tests) to say which option is the best.
> I'd rather figure out why it is slower in Python3 because it may be
> indicative of something that may impact other parts of the code as
> well. We're having this whole discussion about Python performance and
> the Go language, I think it is not a good idea to delete code which
> is performing poorly because it is performing slowly.
Sorry but Go doesn't solve badly designed functions :-) It's an
algorithmic complexity issue: the function has to iterate on *all* alive
Python objects: complexity of O(n). I propose to remove to code to
simplify the complexity to O(1) :-)
Ok, let's take an example with Python 2.7: the command "python -bb -m
testtools.run trove/tests/unittests/common/test_exception.py" takes 972
ms. Remove the mock workaround, the command now taks 1 ms: it's now 972x
faster.
=> removing the slow workaround makes test ~1000x faster!
IMHO it's worth to start here, instead of starting to investigate why
running tests on Python 3 seems slower.
I'm not aware of such huge performance difference between Python 2 and
Python 3 when running unit tests on other OpenStack services. The issue
is specific to Trove, and IMHO it comes from the mock workaround.
Victor
More information about the OpenStack-dev
mailing list