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

Performance tuning #51

Merged
merged 5 commits into from
Sep 28, 2018
Merged

Performance tuning #51

merged 5 commits into from
Sep 28, 2018

Conversation

grigi
Copy link
Member

@grigi grigi commented Sep 27, 2018

tortoise.models.__init__ restructure give 25-30% speedup in select benchmark.
Usage of pypika>=0.15.6 gives 53% speedup in insert benchmark.

I also cleared up a few lint warnings.
As per findings in https://github.com/tortoise/orm-benchmarks
(The benchmark is currently only using SQLite, but both these changes should be generic)

@coveralls
Copy link

coveralls commented Sep 27, 2018

Pull Request Test Coverage Report for Build 201

  • 31 of 40 (77.5%) changed or added relevant lines in 9 files are covered.
  • 310 unchanged lines in 11 files lost coverage.
  • Overall coverage decreased (-0.4%) to 90.313%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tortoise/backends/base/client.py 1 2 50.0%
tortoise/models.py 14 16 87.5%
tortoise/backends/mysql/client.py 0 2 0.0%
tortoise/backends/asyncpg/client.py 0 4 0.0%
Files with Coverage Reduction New Missed Lines %
tortoise/backends/base/executor.py 1 95.56%
tortoise/backends/mysql/init.py 2 100.0%
tortoise/models.py 2 94.06%
tortoise/backends/asyncpg/init.py 2 100.0%
tortoise/backends/base/client.py 7 91.07%
tortoise/backends/asyncpg/schema_generator.py 8 100.0%
tortoise/backends/mysql/schema_generator.py 13 100.0%
tortoise/backends/asyncpg/executor.py 13 100.0%
tortoise/backends/mysql/executor.py 29 100.0%
tortoise/backends/asyncpg/client.py 113 80.37%
Totals Coverage Status
Change from base Build 191: -0.4%
Covered Lines: 1859
Relevant Lines: 2001

💛 - Coveralls

@grigi grigi requested a review from abondar September 27, 2018 13:48
@@ -172,7 +173,7 @@ def acquire_connection(self):
async def commit(self):
try:
await self.transaction.commit()
except asyncpg.exceptions._base.InterfaceError as exc:
except (AttributeError, asyncpg.exceptions._base.InterfaceError) as exc:
Copy link
Member

Choose a reason for hiding this comment

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

What is the case here? You managed to catch it without transaction?

Copy link
Member Author

Choose a reason for hiding this comment

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

That was because the linter (correctly) complained that it was possible for self.transaction to not exist. Which is now forcefully set to None instead. AttributeError is if it is a None value.

I should probably make it clearer? Or is it perferred for it to raise a NPE?

Now that I think of it, a NPE would point out that something happened that should never be able to happen...

@abondar abondar merged commit 2010833 into master Sep 28, 2018
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.

3 participants