Problem/Motivation

Right now the only way to develop migrations is drush cr after every file save. This is painful.

Proposed resolution

Separate out migrate plugin definitions into their own cache backend so that it can be cache.backend.null while in development.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx created an issue. See original summary.

chx’s picture

Status: Needs review » Needs work

The last submitted patch, 2: 2694391_2.patch, failed testing.

chx’s picture

Version: 8.2.x-dev » 8.1.x-dev
Status: Needs work » Needs review
benjy’s picture

The last patch had an extraneous line in the file, just fixed that. Patch looks good to me.

benjy’s picture

Status: Needs review » Reviewed & tested by the community

RTBC, I didn't actually write any of this patch.

catch’s picture

Status: Reviewed & tested by the community » Needs review

Why not use a null cache backend with cache.discovery for this?

benjy’s picture

Why would we needlessly disable all caching? I would have thought that its more likely the migrations haven't changed vs have in all scenarios apart from during development of a migration.

Also, it could slow down the UI that provides a list of migrations or other tools unless they provide their own caching.

catch’s picture

It's not all caching, it's cache.discovery. I don't see how disabling cache.discovery for migrations is any different to disabling for development of anything else that uses plugins.

benjy’s picture

Yeah I meant cache discovery. If the UI does something like $manager->getDefinitions() to list all the migration plugins, won't that have to hit the filesystem every time the page loads?

chx’s picture

> Why not use a null cache backend with cache.discovery for this?

Because even in development that would be a very severe performance hit.

chx’s picture

FileSize
903 bytes

Here's something even better: memory caching it. A (very common) use case is tinker -- rerun -- repeat -- yay works never touch it again. The UI can change back to the chained backend with adding a service provide w/ alter , it's really easy. There are no other pages where this hits.

chx’s picture

FileSize
913 bytes

Except I did wrong there and arguments need to be discovery_migration instead of discovery. Foolish me.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

After thinking about it for a while I think its fine to have its own entry for migrations. They are special in the way that unlike other plugins, you continuously edit the metadata of them.
There is no other plugin type where you have to deal with that all the time.

catch’s picture

Assigned: Unassigned » benjy

Just using memory all the time for this is a better justification for the separate cache service. Giving benjy another chance to look since he didn't like removing caching before.

alexpott’s picture

Assigned: benjy » catch

Given @catch's comment in #9 assigning to @catch. For my perspective this change makes sense. Creating migration plugins should never be a performance sensitive task and making life easier for developers seems sensible.

benjy’s picture

My concern was that if you had a long running migration, like a large upgrade using batch, every new request would cause every migration to be rediscovered from disk? That might be a small performance hit for a one-off, but could it have a sizeable impact on long running / large upgrades.

Anyway, if everyone else here doesn't see it as an issue i've got no problem with this, I can change it back from the UI as needed anyway.

dawehner’s picture

For me personally a separate cache bin is totally enough + an entry in sites/example.settings.local.php

chx’s picture

I talked to benjy and pointed out that while rediscovery happens, reparsing not because file cache. This might or might not be enough. If #18 is what I can get then I will live with it of course however my experience is you spend much more time writing these things than running them also running them is slow enough and rediscovery won't be much worse however this will depend a lot on the system because if the system has enough memory for the filesystem to cache the files it'll be very fast on the other hand if you have the database on the same system and LRUs the plugin dirs out of FS cache that's bad but who runs on a single system where you have so much stuff these things matter

Fabianx’s picture

+++ b/core/modules/migrate/migrate.services.yml
@@ -17,6 +17,12 @@ services:
+      - { name: cache.bin, default_backend: cache.backend.memory }

Why set the default backend to memory?

I thought this was meant for local overriding in settings.local.php?

Is that not enough for developers to avoid the drush cr?

Not opposed to the change, but just wondering.

chx’s picture

We might've crossposted? Read up one please.

my experience is you spend much more time writing these things than running them

dawehner’s picture

I agree with chx on this point. If your migration is slow because of the scanning of the definitions, you have kind of a luxury problem.

  • catch committed 14dac80 on 8.2.x
    Issue #2694391 by chx, benjy, catch, dawehner: Separate cache bin for...

  • catch committed 7426879 on 8.1.x
    Issue #2694391 by chx, benjy, catch, dawehner: Separate cache bin for...
catch’s picture

Status: Reviewed & tested by the community » Fixed

If migrate was stable I'd want profiling here, since it's not I've gone ahead and committed to both 8.x branches.

I think we should profile a migrate batch request to see how bad this is, but that's worth doing in general and we might find other, worse things. Opened #2722287: Profile migrate UI batch request for that.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

alexpott’s picture

Status: Closed (fixed) » Needs work

This patch needs to be reverted. After much work I've found that it causes #2737599: Remote git bisect for random failure in \Drupal\migrate_drupal_ui\Tests\d7\MigrateUpgrade7Test. Once reverted we need to work out why on this issue.

  • alexpott committed d4c4193 on 8.2.x
    Revert "Issue #2694391 by chx, benjy, catch, dawehner: Separate cache...

  • alexpott committed 84f8bfd on 8.1.x
    Revert "Issue #2694391 by chx, benjy, catch, dawehner: Separate cache...
alexpott’s picture

In one of the random fail issues @heddn said that this change also caused #2736789: Default of 'migration' database key is ONLY thing that works

catch’s picture

Assigned: catch » Unassigned

So one thing to try would be a patch that uses the memory backend for discovery and see if we get even more random failures.

  • catch committed 14dac80 on 8.3.x
    Issue #2694391 by chx, benjy, catch, dawehner: Separate cache bin for...
  • alexpott committed d4c4193 on 8.3.x
    Revert "Issue #2694391 by chx, benjy, catch, dawehner: Separate cache...

  • catch committed 14dac80 on 8.3.x
    Issue #2694391 by chx, benjy, catch, dawehner: Separate cache bin for...
  • alexpott committed d4c4193 on 8.3.x
    Revert "Issue #2694391 by chx, benjy, catch, dawehner: Separate cache...
dawehner’s picture

Status: Needs work » Needs review
FileSize
1.21 KB
1.53 KB

Well, we have random failures, so let's try to help people with it, by still having a settings.local.php entry.

Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 34: 2694391-34.patch, failed testing.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

iMiksu’s picture

I was checking whether the patch needs a reroll, and it had some offset. Updated patch.

patching file core/modules/migrate/migrate.services.yml
Hunk #1 succeeded at 21 (offset 4 lines).
patching file sites/example.settings.local.php
iMiksu’s picture

Status: Needs work » Needs review
Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/sites/example.settings.local.php
@@ -67,6 +67,16 @@
+ * While working on migrations it can be a hassle, as one has to clear caches
+ * all the time.
+ *
+ * By commenting out this bit, you never store migration caches.

This documentation could be improved. Something like:
Uncomment the code below to only store migrations in memory and not in the database. This makes it easier to develop custom migrations.

yogeshmpawar’s picture

Status: Needs work » Needs review
FileSize
1.51 KB
650 bytes

Documentation improved as per comment #41, Also added interdiff.

Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 87fdc92 and pushed to 8.3.x. Thanks!

  • alexpott committed 87fdc92 on 8.3.x
    Issue #2694391 by chx, dawehner, Yogesh Pawar, benjy, iMiksu, catch,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.