Move memory management from MigrateExecutable to an event subscriber

Created on 15 October 2018, over 5 years ago
Updated 31 October 2023, 8 months ago

Problem/Motivation

This issue is postponed on #3000050: Replace \Drupal\Component\Utility\Environment::checkMemoryLimit with a PHP memory checking helper class and service β†’ .

MigrateExecutable has a lot of code devote to managing and reclaiming memory, since memory usage is quite relevant to migration. There's nothing wrong with this code per se, but we'd like to remove MigrateExecutable entirely. To that end, let's move all the memory management code into a new internal class (Drupal\migrate\MemoryManager) and have MigrateExecutable's constructor instantiate it.

The new MemoryManager class will be explicitly internal because it is not an API. Eventually we may want to add an interface to it (and possibly plugin-ize it), at which point we can remove the internal designation, but that's all way out of scope for this issue. For now, we just want to remove as much code from MigrateExecutable as we can.

Cool enough I implemented it and replaced my wonky hook_row_alter :-D

I don't like the setMessage but our message "service" logic is just all over and I wasn't sure how to handle it.

Remaining tasks

  • Inject the new EnvironmentMemory class from #3000050: Replace \Drupal\Component\Utility\Environment::checkMemoryLimit with a PHP memory checking helper class and service β†’ into the MemoryManager class and remove redundant methods like getUsageInBytes().
  • Instead of setting integer properties in the dispatched event, pass the EnvironmentMemory object. Update the event subscriber.
  • Update the MemoryManager test to use a mocked version of EnvironmentMemory.
  • Implement the suggestion in #79.2. Or argue against it.
  • Respond to the suggestion in #80.
  • Use returnCallback() as suggested in #82 or open a follow-up issue to do this. See also the last part of #83.
πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
MigrationΒ  β†’

Last updated 39 minutes ago

Created by

πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

Live updates comments and jobs are added and updated live.
  • API clean-up

    Refactors an existing API or subsystem for consistency, performance, modularization, flexibility, third-party integration, etc. May imply an API change. Frequently used during the Code Slush phase of the release cycle.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024