During D7 -> D7 user migrations, the password of the user being created is run through the drupal password hashing function user_hash_password unnecessarily. The result of that function is saved to the user table, then directly overwritten by the DrupalUser7Migration->complete() function.

On an import of 1000 users, here's the xhprof results for this function:

user_hash_password
Calls:1,000
INCL. WALL TIME (MICROSEC) 4,240,400
INCL. CPU (MICROSECS) 4,341,848

According to https://api.drupal.org/api/drupal/modules%21user%21user.module/function/... you can skip this step by not passing in a value for 'pass'. I'd recommend since the value is being overwritten anyways, that the DrupalUser7Migration rename the pass field during prepareRow(), to prevent hashing, and then restore the pass field during complete().

In tests, this shaved 4 seconds per 1000 users off of migration time. Considering I'm doing a migration of 4M users..... that's a pretty solid savings.

Comments

netw3rker created an issue. See original summary.

netw3rker’s picture

Status: Active » Needs review
netw3rker’s picture

StatusFileSize
new1.43 KB

updated patch to have proper file paths.

netw3rker’s picture

StatusFileSize
new1.42 KB

Whoops.. that patch not only skips password hashing, but also deleted the password entirely. Here's an updated patch that preserves the password.

Chris Charlton’s picture

I'm surprised D7-to-D7 migration had this flaw. Glad I checked here.