Fix slowdown on Python 3#290
Conversation
Don't parse command line arguments each time `Options()` is called. The metaclass syntax was changed in Python 3 (see [1]) and it is tricky to add a metaclass in a Python version agnostic way. Still possible, but the code would be hard to understand. So I get rid of the Singleton metaclass and use __new__() to implement this logic. Aside of the Option class, we had another singleton: Colorer. However it is instanciated once (this instance is exposed as color_stdout) and it does not matter, whether it is a singleton or not. A brief testing on tarantool's test suite (with --long --force) gives me ~8 minutes after the fix instead of ~11 minutes before the fix. However it worth to note that we have a lot of tests, which are marked as fragile and so run without parallelization. Otherwise the difference would be lower, I guess. [1]: https://www.python.org/dev/peps/pep-3115/ Fixes #279
fbc68c7 to
344d404
Compare
Good idea. Done. |
There was a problem hiding this comment.
Thanks for the patch!
Change declares performance speedup, but there are no any numbers attached to check it. So I decided to measure overall time required to run tests for sql test suite (because initially performance degradation has been discovered with tests in that suite) and all tests with and without patch.
time ../../test/test-run.py --builddir=/home/sergeyb/sources/MRG/tarantool/build --vardir=/home/sergeyb/sources/MRG/tarantool/build/test/var --suite sql
| iteration | wo patch | with patch |
|---|---|---|
| 1 | 51,909s | 16,175s |
| 2 | 51,338s | 16,295s |
| 3 | 57,364s | 16,358s |
| 4 | 51,278s | 16,267s |
| 5 | 50,738s | 16,564s |
time ../../test/test-run.py --builddir=/home/sergeyb/sources/MRG/tarantool/build --vardir=/home/sergeyb/sources/MRG/tarantool/build/test/var
| iteration | wo patch | with patch |
|---|---|---|
| 1 | 9m35,228s | 7m23,025s |
| 2 | 9m32,369s | 7m3,614s |
LGTM
avtikhon
left a comment
There was a problem hiding this comment.
Timings checked on self-hosted and Github Actions hosts, patch LGTM.
|
Thank you all for reviews, testing and measurements! |
List of changes in test-run: * readme: add memcached to users ([PR #285][1]) * test: add integration tests ([PR #273][2]) * test: enable in continuous integration ([PR #273][2]) * Fix slowdown on Python 3 ([PR #290][3]) Updated .luacheckrc to exclude newly added 'core = tarantool' tests (ones that check test-run itself). [1]: tarantool/test-run#285 [2]: tarantool/test-run#273 [3]: tarantool/test-run#290
List of changes in test-run: * readme: add memcached to users ([PR #285][1]) * test: add integration tests ([PR #273][2]) * test: enable in continuous integration ([PR #273][2]) * Fix slowdown on Python 3 ([PR #290][3]) Updated .luacheckrc to exclude newly added 'core = tarantool' tests (ones that check test-run itself). [1]: tarantool/test-run#285 [2]: tarantool/test-run#273 [3]: tarantool/test-run#290 (cherry picked from commit 8b3ec7b)
List of changes in test-run: * readme: add memcached to users ([PR #285][1]) * test: add integration tests ([PR #273][2]) * test: enable in continuous integration ([PR #273][2]) * Fix slowdown on Python 3 ([PR #290][3]) Updated .luacheckrc to exclude newly added 'core = tarantool' tests (ones that check test-run itself). [1]: tarantool/test-run#285 [2]: tarantool/test-run#273 [3]: tarantool/test-run#290 (cherry picked from commit 8b3ec7b)
List of changes in test-run: * readme: add memcached to users ([PR #285][1]) * test: add integration tests ([PR #273][2]) * test: enable in continuous integration ([PR #273][2]) * Fix slowdown on Python 3 ([PR #290][3]) Updated .luacheckrc to exclude newly added 'core = tarantool' tests (ones that check test-run itself). [1]: tarantool/test-run#285 [2]: tarantool/test-run#273 [3]: tarantool/test-run#290 (cherry picked from commit 8b3ec7b) (The .luacheckrc change was excluded from the backport to 1.10: there is no .luacheckrc here.)
|
Updated the test-run submodule in tarantool in 2.8.0-199-g8b3ec7b92, 2.7.1-182-gafc84a5d2, 2.6.2-178-geedd55789, 1.10.9-110-gef7938933. |
Don't parse command line arguments each time
Options()is called.The metaclass syntax was changed in Python 3 (see 1) and it is tricky
to add a metaclass in a Python version agnostic way. Still possible, but
the code would be hard to understand. So I get rid of the Singleton
metaclass and use __new__() to implement this logic.
Aside of the Option class, we had another singleton: Colorer. However it
is instanciated once (this instance is exposed as color_stdout) and it
does not matter, whether it is a singleton or not.
A brief testing on tarantool's test suite (with --long --force) gives me
~8 minutes after the fix instead of ~11 minutes before the fix. However
it worth to note that we have a lot of tests, which are marked as
fragile and so run without parallelization. Otherwise the difference
would be lower, I guess.
Fixes #279