Skip to content

Conversation

@BaDos
Copy link
Contributor

@BaDos BaDos commented Jun 15, 2020

Description

Added patches that contain performance improvements for Redis from Magento 2.3.5 and 2.3-develop branch.

Fixed Issues (if relevant)

  1. https://jira.corp.magento.com/browse/MCLOUD-6139
  2. https://jira.corp.magento.com/browse/MCLOUD-6211

Manual testing scenarios

For Magento 2.3.0 and 2.3.1 need to smoke testing product functionality.
There are steps for testing for Magento 2.3.0 - 2.3.5

  1. Edit composer.json
"repositories": {
        "repo2": {
            "type": "composer",
            "url": "https://repo.magento.com/"
        },
        "ece-tools": {
            "type": "vcs",
            "url": "https://github.com/magento/ece-tools.git"
        },
        "mcp": {
            "type": "vcs",
            "url": "git@github.com:magento/magento-cloud-patches.git"
        },
        "docker":{
            "type": "vcs",
            "url": "git@github.com:magento/magento-cloud-docker.git"
        }
  },
"require": {
        "magento/magento-cloud-metapackage": ">=2.3.3 <2.3.4",
        "magento/magento-cloud-patches": "dev-MCLOUD-6139 as 1.0.99",
        "magento/ece-tools": "dev-MCLOUD-6327 as 2002.1.99"
},
  1. Run composer update
  2. Commit changes of composer.json and composer.lock
  3. Push to trigger redeploy
  4. Check that frontend works
  5. Check app/etc/env.php
'cache' =>
  array (
    'frontend' =>
    array (
      'default' =>
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' =>
        array (
          'server' => 'redis.internal',
          'port' => 6379,
          'database' => 1,
        ),
        'id_prefix' => 'f53_',
      ),
      'page_cache' =>
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' =>
        array (
          'server' => 'redis.internal',
          'port' => 6379,
          'database' => 2,
        ),
        'id_prefix' => 'f53_',
      ),
    ),
  ),
  1. Add .magento.env.yaml
stage:
  deploy:
    CACHE_CONFIGURATION:
      _merge: false
      frontend:
        default:
          backend: '\Magento\Framework\Cache\Backend\RemoteSynchronizedCache'
          backend_options:
            remote_backend: '\Magento\Framework\Cache\Backend\Redis'
            remote_backend_options:
              persistent: 0
              server: 'redis.internal'
              database: '1'
              port: '6379'
              password: ''
              compress_data: '1'
            local_backend: 'Cm_Cache_Backend_File'
            local_backend_options:
              cache_dir: '/dev/shm/'
          frontend_options:
            write_control: false
      type:
        default:
          frontend: 'default'
  1. Commit .magento.env.yaml
  2. Push to trigger redeploy
  3. Check that frontend works
  4. Check app/etc/env.php
'cache' =>
  array (
    'frontend' =>
    array (
      'default' =>
      array (
        'backend' => '\\Magento\\Framework\\Cache\\Backend\\RemoteSynchronizedCache',
        'backend_options' =>
        array (
          'remote_backend' => '\\Magento\\Framework\\Cache\\Backend\\Redis',
          'remote_backend_options' =>
          array (
            'persistent' => 0,
            'server' => 'redis.internal',
            'database' => '1',
            'port' => '6379',
            'password' => '',
            'compress_data' => '1',
          ),
          'local_backend' => 'Cm_Cache_Backend_File',
          'local_backend_options' =>
          array (
            'cache_dir' => '/dev/shm/',
          ),
        ),
        'frontend_options' =>
        array (
          'write_control' => false,
        ),
      ),
    ),
    'type' =>
    array (
      'default' =>
      array (
        'frontend' => 'default',
      ),
    ),
  ),

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

Copy link

@BarnyShergold BarnyShergold left a comment

Choose a reason for hiding this comment

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

PR description needs full information - a ticket link is not sufficient as many reviewers do not have access to the the JIRA tickets

">=2.3.4 <2.3.6": "MCLOUD-5837__fix_filesystem_load_balancer_issue__2.3.4.patch"
},
"Cache Locking performance issue": {
"2.3.3": "MDVA-27538__fix_performance_issue_in_cache_locking_mechanism__2.3.3.patch",

Choose a reason for hiding this comment

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

If this is a "Create Patch" PR - why are these being removed? Are the Redis patches replacing these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The patches in this PR contain the same improvements and more.

+ try {
+ if ($this->fileDriver->isExists($lockFile)) {
+ $fileResource = $this->fileDriver->fileOpen($lockFile, 'w+');
+ if ($this->tryToLock($fileResource)) {

Choose a reason for hiding this comment

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

Conditional will do -
$result = !$this->tryToLock($fileResource);

+ *
+ * @var string
+ */
+ private $lockName = 'lock-';

Choose a reason for hiding this comment

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

Should be a constant as it never changes

+ *
+ * @var int
+ */
+ private $connectionTimeout = 2;

Choose a reason for hiding this comment

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

Should be a constant as it never changes

+ *
+ * @var int
+ */
+ private $sleepCycle = 100000;

Choose a reason for hiding this comment

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

Should be a constant as it never changes

+ $cacheKey = self::ATTRIBUTES_CACHE_ID . '-' . $entityTypeCode . '-preload';
+ if ($this->isCacheEnabled() && ($attributes = $this->_cache->load($cacheKey))) {
+ $attributes = $this->serializer->unserialize($attributes);
+ if ($attributes) {

Choose a reason for hiding this comment

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

Test for array

+ * Load value with given id from cache
+ *
+ * @param string $id Cache id
+ * @param string $id Cache id

Choose a reason for hiding this comment

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

Remove whitespace

+ /**
+ * @inheritDoc
+ */
+ public function doOperation(): void

Choose a reason for hiding this comment

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

WHy has this been removed?

+ /**
+ * @inheritDoc
+ */
+ public function getName(): string

Choose a reason for hiding this comment

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

WHy has this been removed?

+ public function getName(): string
+ public function getName()
+ {
+ return 'App action list generation';

Choose a reason for hiding this comment

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

Pure text should be a constant

@BaDos
Copy link
Contributor Author

BaDos commented Jun 23, 2020

Hi @BarnyShergold
Thank you for your comments, but we do not change code in patches. This code from Magento Core.
If we change something it will be difficult to support patches in the future.
Sometimes support team provides some hotfixes to customers and if we change some part of code in patches it can be conflicts between patches.

Patches contain the same code as Magento Core.

@BarnyShergold
Copy link

@BaDos - I've only commented on NEW code added by the patches - this should surely be subject to the same code rules as standard code? It's why i've not commented on code that should be refactored - it's core.

I spent 3hrs going through all 10 files.

billygilbert
billygilbert previously approved these changes Jun 23, 2020
@BaDos
Copy link
Contributor Author

BaDos commented Jun 23, 2020

@BarnyShergold, these are diffs from core Magento, where this code was fixed already. To be able to change the content of patches we would need to change the same in core first. If there are so many changes required though, I assume this is something that may need to be looked at by core team, since the patches used here are taken from latest core code.

@BaDos BaDos changed the title MCLOUD-6139: Redis P1 improvement - Create patches for 2.3.0 - 2.3.4 MCLOUD-6139 - MCLOUD-6211: Redis improvement - Create patches for 2.3.0 - 2.3.5 Jun 23, 2020
@BarnyShergold
Copy link

@BaDos - AH I see how these patches are being created now.... Seems I wasted some of my own time - however the comments should still stand, so is there a mechanism to have these reported against the CORE code?

You've corrected the pull request description so can you tell me then - when these PRs for patches are submitted, what exactly are we reviewers reviewing?

If you can answer that - then I'll be happy to approve the PR and put it down to "lesson learned" 😄

@billygilbert
Copy link

@BaDos - AH I see how these patches are being created now.... Seems I wasted some of my own time - however the comments should still stand, so is there a mechanism to have these reported against the CORE code?

You've corrected the pull request description so can you tell me then - when these PRs for patches are submitted, what exactly are we reviewers reviewing?

If you can answer that - then I'll be happy to approve the PR and put it down to "lesson learned" 😄

@BarnyShergold When I review these, I am usually checking for:

  1. Version constraints look proper
  2. Modules that the patch is checking are appropriate
  3. Patch construction is appropriate (pathing, headers for the patch, etc.)

Copy link

@BarnyShergold BarnyShergold left a comment

Choose a reason for hiding this comment

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

Based on the CORRECT way to review patches, the only query I have that remains is the one for patches.json

"2.3.0 - 2.3.1": "MAGECLOUD-3054__add_zookeeper_and_flock_locks__2.3.0.patch"
"2.3.0": "MAGECLOUD-3054__add_zookeeper_and_flock_locks__2.3.0.patch",
"2.3.1": "MAGECLOUD-3054__add_zookeeper_and_flock_locks__2.3.1.patch",
">=2.3.2 <2.3.5": "MCLOUD_6139__improvement_flock_locks__2.3.2.patch"

Choose a reason for hiding this comment

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

If this is now 2.3.0 - 2.3.5 - This should be ">=2.3.2 <2.3.6" ?

Copy link
Contributor Author

@BaDos BaDos Jun 24, 2020

Choose a reason for hiding this comment

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

This patch MCLOUD_6139__improvement_flock_locks__2.3.2.patch contains changes for Magento 2.3.2 - 2.3.4-px where x is some number. So, we cannot use a constraint like this 2.3.2 - 2.3.4 and we use this one >=2.3.2 <2.3.5

Choose a reason for hiding this comment

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

Okay that's fine - just wanted to check that was the reason!

oshmyheliuk
oshmyheliuk previously approved these changes Jun 24, 2020
BarnyShergold
BarnyShergold previously approved these changes Jun 25, 2020
@BaDos BaDos dismissed stale reviews from BarnyShergold and oshmyheliuk via 5d0ce2e July 27, 2020 17:42
@mveeramneni mveeramneni self-assigned this Jul 29, 2020
@mveeramneni
Copy link

QA Approved

@shiftedreality shiftedreality merged commit 7dbcd55 into develop Jul 29, 2020
@shiftedreality shiftedreality deleted the MCLOUD-6139 branch July 29, 2020 17:59
@BarnyShergold BarnyShergold self-assigned this Jul 30, 2020
magento-devops-reposync-svc pushed a commit that referenced this pull request Mar 1, 2022
MCLOUD-8486: Release Cloud Tools
andriyShevtsov pushed a commit that referenced this pull request Sep 8, 2025
MCLOUD-8486: Release Cloud Tools
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants