Skip to content

Fix slowdown on Python 3 #290

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

Merged
merged 1 commit into from
Apr 7, 2021
Merged

Conversation

Totktonada
Copy link
Member

@Totktonada Totktonada commented Apr 5, 2021

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

@Totktonada Totktonada requested review from avtikhon and ligurio April 5, 2021 03:24
@LeonidVas LeonidVas self-requested a review April 5, 2021 07:21
Copy link

@LeonidVas LeonidVas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, you can add a link on PEP
LGTM.

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
@Totktonada Totktonada force-pushed the Totktonada/fix-slowdown-on-python-3 branch from fbc68c7 to 344d404 Compare April 5, 2021 12:18
@Totktonada
Copy link
Member Author

Additionally, you can add a link on PEP
LGTM.

Good idea. Done.

Copy link
Member

@ligurio ligurio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

@avtikhon avtikhon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timings checked on self-hosted and Github Actions hosts, patch LGTM.

@Totktonada
Copy link
Member Author

Thank you all for reviews, testing and measurements!

@Totktonada Totktonada merged commit 1263cb5 into master Apr 7, 2021
@Totktonada Totktonada deleted the Totktonada/fix-slowdown-on-python-3 branch April 7, 2021 07:39
Totktonada added a commit to tarantool/tarantool that referenced this pull request Apr 7, 2021
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
Totktonada added a commit to tarantool/tarantool that referenced this pull request Apr 7, 2021
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)
Totktonada added a commit to tarantool/tarantool that referenced this pull request Apr 7, 2021
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)
Totktonada added a commit to tarantool/tarantool that referenced this pull request Apr 7, 2021
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.)
@Totktonada
Copy link
Member Author

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.

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.

python3: "sql" test suite passing slowed down
4 participants