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]Cache whether a DB supports transaction level #18691

Merged
merged 19 commits into from Feb 23, 2022

Conversation

peterhashair
Copy link
Contributor

@peterhashair peterhashair commented Jan 26, 2022

Description:

Fixes: #18138
Cache whether a DB supports transaction on all the DB adapter to improve perfomance.

Review

add check
@peterhashair peterhashair marked this pull request as ready for review January 26, 2022 23:43
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

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

Code looks fine. Left a comment for improving the tests

tests/PHPUnit/Integration/Db/TransactionLevelTest.php Outdated Show resolved Hide resolved
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

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

Looks good to me.
@tsteur do you want to have a last quick view before this is merged?

@sgiehl sgiehl added this to the 4.8.0 milestone Feb 1, 2022
@sgiehl sgiehl added the c: Performance For when we could improve the performance / speed of Matomo. label Feb 1, 2022
Copy link
Member

@tsteur tsteur left a comment

Choose a reason for hiding this comment

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

In the original issue in #18138 I mention this:

We should cache this eg on the $this->db as it's DB dependent as if someone configures different DBs for writer and reader for example then we cannot reuse / cache the same result.

@peterhashair @sgiehl the current solution wouldn't 100% work for us.

We want to cache it per DB (in case writer and reader are somehow different) and also to have better cache when many new instances of this class are created. Otherwise it be only cached in the instance itself. We are creating this class very often so it wouldn't really help.

core/Db/TransactionLevel.php Outdated Show resolved Hide resolved
@peterhashair
Copy link
Contributor Author

@tsteur right, so this $supportsUncommitted should be in the Db.php.

move supportsUncommitted to db level
append $supportsUncommitted to global Db
@sgiehl
Copy link
Member

sgiehl commented Feb 4, 2022

@peterhashair most tests are now failing with messages like Undefined property: Piwik\Db\Adapter\Pdo\Mysql::$supportsUncommitted. Maybe it needs to be added to the adapters as well...

append to mysqli supportsUncommitted
@peterhashair peterhashair changed the title Cache whether a DB supports transaction level [Performance]Cache whether a DB supports transaction level Feb 8, 2022
@peterhashair peterhashair added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Feb 8, 2022
@peterhashair
Copy link
Contributor Author

@sgiehl I think that one is good to go?

@sgiehl
Copy link
Member

sgiehl commented Feb 10, 2022

From my point of view this looks good to merge.

Copy link
Member

@tsteur tsteur left a comment

Choose a reason for hiding this comment

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

There might be still an issue. Also can we add a test for the cache by setting the property on the db object in a test and then we get expected result or something?

core/Db/TransactionLevel.php Show resolved Hide resolved
update function
@peterhashair peterhashair added the Needs Review PRs that need a code review label Feb 13, 2022
update transaction
Peter added 2 commits February 16, 2022 10:13
revert back to previous change
update cache level key
@peterhashair
Copy link
Contributor Author

@sgiehl right, sorry wasn't thinking, update again, if that makes sense.

core/Db/TransactionLevel.php Show resolved Hide resolved
core/Db/TransactionLevel.php Outdated Show resolved Hide resolved
core/Db/TransactionLevel.php Outdated Show resolved Hide resolved
core/Db/TransactionLevel.php Show resolved Hide resolved
Peter added 2 commits February 17, 2022 10:15
update supportsUncommitted
add some comments
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

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

Left a comment. Otherwise guess it looks good now, as the status backup doesn't seem to be an issue.

core/Db/TransactionLevel.php Outdated Show resolved Hide resolved
Co-authored-by: Stefan Giehl <stefan@matomo.org>
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

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

Should be good to merge now. @tsteur do you want to have another look before merging?

@sgiehl sgiehl removed the Needs Review PRs that need a code review label Feb 22, 2022
Copy link
Member

@tsteur tsteur left a comment

Choose a reason for hiding this comment

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

@peterhashair @sgiehl I believe there are still few issues. Could we get the these resolved?

core/Db/TransactionLevel.php Outdated Show resolved Hide resolved
core/Db.php Outdated Show resolved Hide resolved
core/Tracker/Db.php Show resolved Hide resolved
remove $supportsUncommitted reset
Copy link
Member

@tsteur tsteur left a comment

Choose a reason for hiding this comment

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

I haven't tested it but looks all good to me now 👍

@peterhashair peterhashair merged commit d994558 into 4.x-dev Feb 23, 2022
@peterhashair peterhashair deleted the m-18138-cache-translation branch February 23, 2022 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Performance For when we could improve the performance / speed of Matomo. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache whether a DB supports transaction level or not
3 participants