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

IBX-819: Shortened persistence cache tags to save memory usage #3114

Merged
merged 23 commits into from
Sep 7, 2021

Conversation

konradoboza
Copy link
Member

@konradoboza konradoboza commented Jul 27, 2021

Question Answer
JIRA issue IBX-819
Bug/Improvement yes
New feature no
Target version 7.5
BC breaks no
Tests pass yes
Doc needed yes

JIRA excerpt:

According to my tests, we might achieve ~16% savings in memory usage by shortening the persistence cache tags. It is also recommended by Redis documentation. Also, their usage should be refactored for easier maintenance.

We need to clearly state that the Redis cache needs to be flushed after upgrading the project to the version that will contain changes proposed within this PR. Otherwise, the persistence cache will get corrupted and its purging will be done against wrong keys.

Related PR: ezsystems/LegacyBridge#184

TODO:

  • Implement feature / fix a bug.
  • Implement tests.
  • Fix new code according to Coding Standards ($ composer fix-cs).
  • Ask for Code Review.

@adamwojs
Copy link
Member

What about backward compatibility?

@konradoboza
Copy link
Member Author

We need to introduce at least a toggle enabling/disabling short tags usage for keeping BC. Ideally, generating tags should be delegated to some dedicated abstraction but this would require some further work. Until it is done, I will make sure that tests are lit green at least.

@konradoboza konradoboza force-pushed the ibx-819-shortening-persistence-cache-tags branch 2 times, most recently from 611f624 to fb839da Compare August 5, 2021 19:37
@konradoboza konradoboza force-pushed the ibx-819-shortening-persistence-cache-tags branch from fb839da to 387fd38 Compare August 6, 2021 09:38
@konradoboza konradoboza added the Doc needed The changes require some documentation label Aug 6, 2021
@konradoboza konradoboza marked this pull request as ready for review August 10, 2021 11:50
@konradoboza konradoboza requested a review from Steveb-p August 27, 2021 11:31
@konradoboza
Copy link
Member Author

All the remarks applied @Steveb-p, dropped usage of use or at least got rid of $cacheIdentifierGenerator wherever it was possible.

eZ/Publish/Core/Persistence/Cache/ContentHandler.php Outdated Show resolved Hide resolved
->method('generateKey')
->withConsecutive(...$keyGeneratingArguments)
->willReturnOnConsecutiveCalls(...$keyGeneratingResults);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The code for configuring the cache identifier generator is repeated multiple times throughout the PR, so ideally we'd want to get rid of duplication.

From my point of view even a trait would do, with property, getter and configure'ish method.

{
$object = new SPILanguage(['id' => 5, 'languageCode' => 'eng-GB']);

// string $method, array $arguments, string $key, array? $tagGeneratingArguments, array? $tagGeneratingResults, array? $keyGeneratingArguments, array? $keyGeneratingResults, mixed? $data, bool $multi
Copy link
Contributor

Choose a reason for hiding this comment

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

For the future, this belongs to phpdoc as @return declaration:

/**
 * @return array<array{string, string, string, array,... etc.}>
 */

(for static analysis validation)

@Steveb-p
Copy link
Contributor

As discussed, the remaining two code review remarks are entirely optional. Due to time contraints I'm ok with skipping those, as they're partially out of scope / would require postponing the merger by too much while bringing not enough value.

@micszo micszo self-assigned this Sep 1, 2021
Copy link
Member

@micszo micszo left a comment

Choose a reason for hiding this comment

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

Tested on eZ Platform EE v2.5.23 with Legacy bridge on platform.sh and locally with redis on eZ Commerce v2.5.12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

9 participants