Expand the range of data tracked by the timer instrument during a migration

Last updated on
5 June 2025

This documentation needs work. See "Help improve this page" in the sidebar.

This page was written for Drupal 7, but still contain great general information about migrating. See #3332592: Add support for migrate instrument (performance measurement) for --instrument in Drupal 11.

The timer instrument is useful while developing a migration as a way to determine which stages of your migration are slow and could use optimization. The migrate module attempts to collect as much data as it can, but by patching Drupal core, you can determine which hooks and fields are slowing down your migration, as well as being sure exactly which hooks are being invoked.

The attached patch can be applied to your Drupal core codebase to extend the range of data collected by the timer instrument to include all hooks invoked from:

  • module_invoke()
  • module_invoke_all()
  • drupal_alter()
  • _field_invoke()
  • _field_invoke_multiple()
  • field_attach_insert()
  • field_attach_update()
  • node_invoke()
  • user_module_invoke()

It also adds timers for:

  • The actual db writes of nodes and revisions

To see the timings, add the --instrument=timer option to your drush import and rollback commands:

drush mi ExampleNode --instrument=timer
drush mr ExampleNode --instrument=timer

Note: The attached patch is against the latest 7.x Drupal code as of August 29, 2013 (following the 7.23 release). As of June 15, 2015 the patch still applies cleanly to Drupal 7.35.

Use in drush make:

projects[drupal][patch][] = https://www.drupal.org/files/migrate-instrumentation-d7-7.24-dev_0.patch

Upd. There is also a patch for the latest stable Drupal 7.39 code. Alternatively use the following line in drush make:

projects[drupal][patch][] = https://www.drupal.org/files/migrate-instrumentation-d7-7.39-stable_0.patch

Help improve this page

Page status: Needs work

You can: